stanfordnlp/CoreNLP · error · RuntimeException

Error reading SVM model (line

Error message

Error reading SVM model (line 

What it means

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.

Solutions

  1. Regenerate the model with the matching svm_light version
  2. Check the model file is not truncated or manually edited
  3. Ensure the model was trained with the expected options (e.g., no qid features beyond what is handled)
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/edu/stanford/nlp/classify/SVMLightClassifierFactory.java:168 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/2071536b23408b26. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/classify/SVMLightClassifierFactory.java:168

          // Each in featureIndex:num class
          String[] indexNum = piece.split(":");
          String featureIndex = indexNum[0];
          // 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.
          if(! featureIndex.equals("qid")){
            double count = Double.parseDouble(indexNum[1]);
            supportVector.incrementCount(Integer.valueOf(featureIndex), count);
          }
        }
        supportVectors.add(new Pair<>(alpha, supportVector));
      }

      in.close();

      return new Pair<>(threshold, getWeights(supportVectors));
    }
    catch (Exception e) {
      e.printStackTrace();
      throw new RuntimeException("Error reading SVM model (line " + modelLineCount + " in file " + modelFile.getAbsolutePath() + ")");
    }
  }

  /**
   * Takes all the support vectors, and their corresponding alphas, and computes a weight
   * vector that can be used in a vanilla LinearClassifier.  This only works because
   * we are using a linear kernel.  The Counter is over the feature indices (+1 cos for
   * some reason svm_light is 1-indexed), not features.
   */
  private static ClassicCounter<Integer> getWeights(List<Pair<Double, ClassicCounter<Integer>>> supportVectors) {
    ClassicCounter<Integer> weights = new ClassicCounter<>();
    for (Pair<Double, ClassicCounter<Integer>> sv : supportVectors) {
      ClassicCounter<Integer> c = new ClassicCounter<>(sv.second());
      Counters.multiplyInPlace(c, sv.first());
      Counters.addInPlace(weights, c);
    }
    return weights;
  }

View on GitHub (pinned to 1b7edd19c4)