{"record":{"id":"567e18da6400f5e0","repo":"stanfordnlp/CoreNLP","slug":"no-minimizer-assigned","errorCode":null,"errorMessage":"No minimizer assigned!","messagePattern":"No minimizer assigned!","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ie/crf/CRFClassifier.java","lineNumber":1949,"sourceCode":"      ((SGDWithAdaGradAndFOBOS<?>) minimizer).terminateOnAvgImprovement(flags.terminateOnAvgImprovement, flags.tolerance);\n      ((SGDWithAdaGradAndFOBOS<?>) minimizer).setTerminateOnEvalImprovementNumOfEpoch(flags.terminateOnEvalImprovementNumOfEpoch);\n      ((SGDWithAdaGradAndFOBOS<?>) minimizer).suppressTestPrompt(flags.suppressTestDebug);\n    } else if (flags.useSGDtoQN) {\n      minimizer = new SGDToQNMinimizer(flags.initialGain, flags.stochasticBatchSize,\n                                       flags.SGDPasses, flags.QNPasses, flags.SGD2QNhessSamples,\n                                       flags.QNsize, flags.outputIterationsToFile);\n    } else if (flags.useSMD) {\n      minimizer = new SMDMinimizer<>(flags.initialGain, flags.stochasticBatchSize, flags.stochasticMethod,\n              flags.SGDPasses);\n    } else if (flags.useSGD) {\n      minimizer = new InefficientSGDMinimizer<>(flags.initialGain, flags.stochasticBatchSize);\n    } else if (flags.useScaledSGD) {\n      minimizer = new ScaledSGDMinimizer(flags.initialGain, flags.stochasticBatchSize, flags.SGDPasses,\n          flags.scaledSGDMethod);\n    } else if (flags.l1reg > 0.0) {\n      minimizer = ReflectionLoading.loadByReflection(\"edu.stanford.nlp.optimization.OWLQNMinimizer\", flags.l1reg);\n    } else {\n      throw new RuntimeException(\"No minimizer assigned!\");\n    }\n\n    if (minimizer instanceof HasEvaluators) {\n      if (minimizer instanceof QNMinimizer) {\n        ((QNMinimizer) minimizer).setEvaluators(flags.evaluateIters, flags.startEvaluateIters, evaluators);\n      } else\n        ((HasEvaluators) minimizer).setEvaluators(flags.evaluateIters, evaluators);\n    }\n\n    return minimizer;\n  }\n\n  /**\n   * Creates a new CRFDatum from the preprocessed allData format, given the\n   * document number, position number, and a List of Object labels.\n   *\n   * @return A new CRFDatum\n   */","sourceCodeStart":1931,"sourceCodeEnd":1967,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/crf/CRFClassifier.java#L1931-L1967","documentation":"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.","triggerScenarios":"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).","commonSituations":"Minimal property files assuming a default optimizer; copying flags from other CRF implementations; conflicting flags that disable the intended branch.","solutions":["Set useQN=true for the standard QN/L-BFGS minimizer (the usual choice).","Or choose a stochastic option: useSGD, useSGDtoQN, useStochasticQN, or useScaledSGD (with its gain/batch flags).","Or set l1reg > 0 to load OWLQNMinimizer via reflection.","Inspect all use* flags to confirm exactly one minimizer branch is active."],"exampleFix":"// before\nprops.setProperty(\"useSMD\", \"true\"); // no branch matches\n// after\nprops.setProperty(\"useQN\", \"true\");","handlingStrategy":"validation","validationCode":"boolean qn = \"true\".equals(props.getProperty(\"useQN\"));\nboolean sgd = \"true\".equals(props.getProperty(\"useSGD\"));\nboolean sgDtoQN = \"true\".equals(props.getProperty(\"useSGDtoQN\"));\nboolean stochQN = \"true\".equals(props.getProperty(\"useStochasticQN\"));\nboolean scaledSGD = \"true\".equals(props.getProperty(\"useScaledSGD\"));\ndouble l1 = Double.parseDouble(props.getProperty(\"l1reg\", \"0.0\"));\nif (!(qn || sgd || sgDtoQN || stochQN || scaledSGD || l1 > 0.0)) {\n  props.setProperty(\"useQN\", \"true\"); // default to QN/L-BFGS\n}","typeGuard":null,"tryCatchPattern":"try {\n  classifier.train(files);\n} catch (RuntimeException e) {\n  if (\"No minimizer assigned!\".equals(e.getMessage())) {\n    props.setProperty(\"useQN\", \"true\");\n    // rebuild and retry\n  } else throw e;\n}","preventionTips":["Always set at least one minimizer flag; useQN is the standard choice.","Set l1reg > 0 when OWLQN is intended and disable other use* flags.","Validate minimizer flags before launching long training jobs."],"tags":["java","config","optimizer","crf"],"backgroundTag":"missing-required-config-field","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}