stanfordnlp/CoreNLP · error · RuntimeException

Unsupported inference type: " + flags.crfType

Error message

Unsupported inference type: " + flags.crfType

What it means

classify() dispatches inference by flags.crfType: only "maxent" (and optionally "cpc" in other paths) is supported. If crfType holds any other value while doGibbs is false, the classifier doesn't know which inference procedure to run and throws a RuntimeException naming the unknown type.

Solutions

  1. Set crfType to "maxent" (the standard value) in your training/classification properties.
  2. If the value came from a serialized model, retrain or edit the flags to a supported type.
  3. If Gibbs inference was intended, set doGibbs=true instead of inventing a crfType value.

Example fix

// before
props.setProperty("crfType", "maxent-logistic");
// after
props.setProperty("crfType", "maxent");
Defensive patterns

Strategy: validation

Validate before calling

if (!flags.doGibbs && !"maxent".equalsIgnoreCase(flags.crfType))
  throw new IllegalStateException("Unsupported crfType: " + flags.crfType);

Prevention

When it happens

Trigger: Calling classify(document) with flags.doGibbs=false and flags.crfType set to something other than "maxent" (case-insensitive), e.g. a typo like "maxent2" or a type only valid in newer/older code versions.

Common situations: Copying crfType values from blog posts or older Stanford code; serialized model flags carrying a crfType the current jar doesn't implement; typos in a properties file.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/ie/crf/CRFClassifier.java:1070

      CRFFeatureExporter<IN> featureExporter = new CRFFeatureExporter<>(this);
      featureExporter.printFeatures(flags.exportFeatures, docs);
      long elapsedMs = timer.stop();
      log.info("Time to export features: " + Timing.toSecondsString(elapsedMs) + " seconds");
    }
  }

  @Override
  public List<IN> classify(List<IN> document) {
    if (flags.doGibbs) {
      try {
        return classifyGibbs(document);
      } catch (Exception e) {
        throw new RuntimeException("Error running testGibbs inference!", e);
      }
    } else if (flags.crfType.equalsIgnoreCase("maxent")) {
      return classifyMaxEnt(document);
    } else {
      throw new RuntimeException("Unsupported inference type: " + flags.crfType);
    }
  }

  private List<IN> classify(List<IN> document, Triple<int[][][], int[], double[][][]> documentDataAndLabels) {
    if (flags.doGibbs) {
      try {
        return classifyGibbs(document, documentDataAndLabels);
      } catch (Exception e) {
        throw new RuntimeException("Error running testGibbs inference!", e);
      }
    } else if (flags.crfType.equalsIgnoreCase("maxent")) {
      return classifyMaxEnt(document, documentDataAndLabels);
    } else {
      throw new RuntimeException("Unsupported inference type: " + flags.crfType);
    }
  }

  /**

View on GitHub (pinned to 1b7edd19c4)