stanfordnlp/CoreNLP · error · RuntimeException

No minimizer assigned!

Error message

No minimizer assigned!

What it means

getMinimizer() builds a minimizer from flags in a strict branch order: in-place SGD/QN variants, plain SGD, SGD-to-QN, stochastic QN, scaled SGD, and OWLQN when flags.l1reg > 0. If none of these branches matches, no optimizer can be assigned and this RuntimeException is thrown, since training requires a minimizer.

Solutions

  1. Set useQN=true for the standard QN/L-BFGS minimizer (the usual choice).
  2. Or choose a stochastic option: useSGD, useSGDtoQN, useStochasticQN, or useScaledSGD (with its gain/batch flags).
  3. Or set l1reg > 0 to load OWLQNMinimizer via reflection.
  4. Inspect all use* flags to confirm exactly one minimizer branch is active.

Example fix

// before
props.setProperty("useSMD", "true"); // no branch matches
// after
props.setProperty("useQN", "true");
Defensive patterns

Strategy: validation

Validate before calling

boolean qn = "true".equals(props.getProperty("useQN"));
boolean sgd = "true".equals(props.getProperty("useSGD"));
boolean sgDtoQN = "true".equals(props.getProperty("useSGDtoQN"));
boolean stochQN = "true".equals(props.getProperty("useStochasticQN"));
boolean scaledSGD = "true".equals(props.getProperty("useScaledSGD"));
double l1 = Double.parseDouble(props.getProperty("l1reg", "0.0"));
if (!(qn || sgd || sgDtoQN || stochQN || scaledSGD || l1 > 0.0)) {
  props.setProperty("useQN", "true"); // default to QN/L-BFGS
}

Try / catch

try {
  classifier.train(files);
} catch (RuntimeException e) {
  if ("No minimizer assigned!".equals(e.getMessage())) {
    props.setProperty("useQN", "true");
    // rebuild and retry
  } else throw e;
}

Prevention

When it happens

Trigger: Launching CRF training with no minimizer flag set (no useQN/useSGD/useSGDtoQN/useStochasticQN/useScaledSGD and l1reg<=0), or setting only unsupported flags (e.g. useSMD).

Common situations: Minimal property files assuming a default optimizer; copying flags from other CRF implementations; conflicting flags that disable the intended branch.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


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

Appendix: source

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

      ((SGDWithAdaGradAndFOBOS<?>) minimizer).terminateOnAvgImprovement(flags.terminateOnAvgImprovement, flags.tolerance);
      ((SGDWithAdaGradAndFOBOS<?>) minimizer).setTerminateOnEvalImprovementNumOfEpoch(flags.terminateOnEvalImprovementNumOfEpoch);
      ((SGDWithAdaGradAndFOBOS<?>) minimizer).suppressTestPrompt(flags.suppressTestDebug);
    } else if (flags.useSGDtoQN) {
      minimizer = new SGDToQNMinimizer(flags.initialGain, flags.stochasticBatchSize,
                                       flags.SGDPasses, flags.QNPasses, flags.SGD2QNhessSamples,
                                       flags.QNsize, flags.outputIterationsToFile);
    } else if (flags.useSMD) {
      minimizer = new SMDMinimizer<>(flags.initialGain, flags.stochasticBatchSize, flags.stochasticMethod,
              flags.SGDPasses);
    } else if (flags.useSGD) {
      minimizer = new InefficientSGDMinimizer<>(flags.initialGain, flags.stochasticBatchSize);
    } else if (flags.useScaledSGD) {
      minimizer = new ScaledSGDMinimizer(flags.initialGain, flags.stochasticBatchSize, flags.SGDPasses,
          flags.scaledSGDMethod);
    } else if (flags.l1reg > 0.0) {
      minimizer = ReflectionLoading.loadByReflection("edu.stanford.nlp.optimization.OWLQNMinimizer", flags.l1reg);
    } else {
      throw new RuntimeException("No minimizer assigned!");
    }

    if (minimizer instanceof HasEvaluators) {
      if (minimizer instanceof QNMinimizer) {
        ((QNMinimizer) minimizer).setEvaluators(flags.evaluateIters, flags.startEvaluateIters, evaluators);
      } else
        ((HasEvaluators) minimizer).setEvaluators(flags.evaluateIters, evaluators);
    }

    return minimizer;
  }

  /**
   * Creates a new CRFDatum from the preprocessed allData format, given the
   * document number, position number, and a List of Object labels.
   *
   * @return A new CRFDatum
   */

View on GitHub (pinned to 1b7edd19c4)