{"record":{"id":"2071536b23408b26","repo":"stanfordnlp/CoreNLP","slug":"error-reading-svm-model-line","errorCode":null,"errorMessage":"Error reading SVM model (line ","messagePattern":"Error reading SVM model \\(line ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/classify/SVMLightClassifierFactory.java","lineNumber":168,"sourceCode":"          // Each in featureIndex:num class\n          String[] indexNum = piece.split(\":\");\n          String featureIndex = indexNum[0];\n          // mihai: we may see \"qid\" as indexNum[0]. just skip this piece. this is the block id useful only for reranking, which we don't do here.\n          if(! featureIndex.equals(\"qid\")){\n            double count = Double.parseDouble(indexNum[1]);\n            supportVector.incrementCount(Integer.valueOf(featureIndex), count);\n          }\n        }\n        supportVectors.add(new Pair<>(alpha, supportVector));\n      }\n\n      in.close();\n\n      return new Pair<>(threshold, getWeights(supportVectors));\n    }\n    catch (Exception e) {\n      e.printStackTrace();\n      throw new RuntimeException(\"Error reading SVM model (line \" + modelLineCount + \" in file \" + modelFile.getAbsolutePath() + \")\");\n    }\n  }\n\n  /**\n   * Takes all the support vectors, and their corresponding alphas, and computes a weight\n   * vector that can be used in a vanilla LinearClassifier.  This only works because\n   * we are using a linear kernel.  The Counter is over the feature indices (+1 cos for\n   * some reason svm_light is 1-indexed), not features.\n   */\n  private static ClassicCounter<Integer> getWeights(List<Pair<Double, ClassicCounter<Integer>>> supportVectors) {\n    ClassicCounter<Integer> weights = new ClassicCounter<>();\n    for (Pair<Double, ClassicCounter<Integer>> sv : supportVectors) {\n      ClassicCounter<Integer> c = new ClassicCounter<>(sv.second());\n      Counters.multiplyInPlace(c, sv.first());\n      Counters.addInPlace(weights, c);\n    }\n    return weights;\n  }","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/classify/SVMLightClassifierFactory.java#L150-L186","documentation":"Thrown by SVMLightClassifierFactory.readModel while parsing an svm_light output model file: a support-vector line could not be parsed (unexpected format or missing fields) while reading alpha values and feature:count pairs.","triggerScenarios":"Thrown at src/edu/stanford/nlp/classify/SVMLightClassifierFactory.java:168 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Regenerate the model with the matching svm_light version","Check the model file is not truncated or manually edited","Ensure the model was trained with the expected options (e.g., no qid features beyond what is handled)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}