stanfordnlp/CoreNLP · error · RuntimeException

need to do training first!

Error message

need to do training first!

What it means

SupervisedSieve.doQuoteToMention requires a trained quotesClassifier, which is only set by calling loadModel(filename). If it is null the sieve throws RuntimeException("need to do training first!") at src/edu/stanford/nlp/quoteattribution/Sieves/QMSieves/SupervisedSieve.java:31. This is an initialization-order guard: the supervised quote-to-mention sieve cannot score mentions without its model.

Solutions

  1. Call sieve.loadModel("path/to/supervised_model") before invoking doQuoteToMention.
  2. Ensure the quoteattribution pipeline is configured with the supervised model path so it wires the classifier in.
  3. Add a null check that calls loadModel lazily with a default model path.
  4. If no supervised model is available, use a non-supervised sieve configuration instead.

Example fix

// before
SupervisedSieve sieve = new SupervisedSieve(...);
sieve.doQuoteToMention(doc); // throws
// after
SupervisedSieve sieve = new SupervisedSieve(...);
sieve.loadModel("models/quote_supervised.model");
sieve.doQuoteToMention(doc);
Defensive patterns

Strategy: validation

Validate before calling

if (sieve == null || sieveIsUninitialized) throw new IllegalStateException("call loadModel() before doQuoteToMention");

Try / catch

try {
  sieve.doQuoteToMention(doc);
} catch (RuntimeException e) {
  if (e.getMessage().contains("training first")) sieve.loadModel(defaultModelPath);
}

Prevention

When it happens

Trigger: Running the quote attribution pipeline with the supervised sieve enabled but never calling loadModel on the sieve, or loadModel failing silently / not being called before processAnnotation/doQuoteToMention runs.

Common situations: Using the quoteattribution annotator without supplying the trained supervised model file; building a custom pipeline that constructs SupervisedSieve directly; config missing the model path property.

Understand the failure class

Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/quoteattribution/Sieves/QMSieves/SupervisedSieve.java:31

/**
 * Created by mjfang on 7/7/16.
 */
public class SupervisedSieve extends QMSieve {

  private ExtractQuotesClassifier quotesClassifier;

  public SupervisedSieve(Annotation doc, Map<String, List<Person>> characterMap,
                         Map<Integer,String> pronounCorefMap, Set<String> animacyList) {
    super(doc, characterMap, pronounCorefMap, animacyList, "supervised");
  }

  public void loadModel(String filename) {
    quotesClassifier = new ExtractQuotesClassifier(filename);
  }

  public void doQuoteToMention(Annotation doc) {
    if (quotesClassifier == null) {
      throw new RuntimeException("need to do training first!");
    }
    SupervisedSieveTraining.FeaturesData fd = SupervisedSieveTraining.featurize(new SupervisedSieveTraining.SieveData(doc, this.characterMap, this.pronounCorefMap, this.animacySet), null, false);
    quotesClassifier.scoreBestMentionNew(fd, doc);
  }

}

View on GitHub (pinned to 1b7edd19c4)