stanfordnlp/CoreNLP · warning
Could not create l1 minimizer! Reverting to l2.
Error message
Could not create l1 minimizer! Reverting to l2.
What it means
Logged (not thrown) fallback message in KBPStatisticalExtractor.initFactory: when the minimizer option is L1, the code reflectively instantiates edu.stanford.nlp.optimization.OWLQNMinimizer via MetaClass. If that fails for any reason (Exception), it logs "Could not create l1 minimizer! Reverting to l2." and substitutes a QNMinimizer(15) — training continues with L2 regularization instead of L1.
Solutions
- Check the classpath contains edu.stanford.nlp.optimization.OWLQNMinimizer (full stanford-corenlp jar, not a subset).
- Log/inspect the swallowed exception by reproducing MetaClass.create("...OWLQNMinimizer").createInstance(sigma) to see the real cause.
- If L1 is not required, accept the L2 fallback or explicitly configure minimizer type L2 to silence the fallback.
- Verify the sigma value passed to the constructor is compatible with the OWLQNMinimizer(double) signature in your CoreNLP version.
Example fix
// before: silent fallback hides the cause
catch (Exception e) { log.err("Could not create l1 minimizer! Reverting to l2."); return new QNMinimizer(15); }
// after: surface the cause
catch (Exception e) { log.err("Could not create l1 minimizer! Reverting to l2.", e); return new QNMinimizer(15); } Defensive patterns
Strategy: try-catch
Validate before calling
boolean l1Available() {
try { Class.forName("edu.stanford.nlp.optimization.OWLQNMinimizer"); return true; }
catch (ClassNotFoundException e) { return false; }
} Try / catch
try { new OWLQNMinimizer(sigma); } catch (Throwable t) { log.warn("L1 minimizer unavailable (" + t + "); using L2 QNMinimizer"); useQN(); } Prevention
- Ship the full stanford-corenlp jar and models on the classpath
- Check for OWLQNMinimizer with Class.forName at startup when requesting L1
- Disable shrink/proguard rules for edu.stanford.nlp.optimization.*
- Treat the fallback log line as a signal to inspect the real exception
When it happens
Trigger: Training KBP statistical models with minimizer type L1 when OWLQNMinimizer cannot be created reflectively — class not on classpath, constructor signature/sigma argument mismatch, or a security/initialization Exception inside MetaClass.create(...).createInstance(sigma).
Common situations: Running with a trimmed/partial CoreNLP jar that omits optimization classes; version drift where OWLQNMinimizer's constructor changed; shading/proguard builds stripping the class.
Related errors
- Error loading flags.readerAndWriter: '%s'
- Error loading flags.plainTextDocumentReaderAndWriter: '%s'
- Unknown class ${className}
- Couldn't instantiate CategoryMergingGrammarCompactor.
- Loading: ${postProcessorClass} failed with: ${e.getMessage()
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/a53d0f355c67e37c.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/ie/KBPStatisticalExtractor.java:591
minimizerFactory = () -> new QNMinimizer(15);
break;
case SGD:
minimizerFactory = () -> new SGDMinimizer<>(sigma, 100, 1000);
break;
case HYBRID:
factory.useHybridMinimizerWithInPlaceSGD(100, 1000, sigma);
minimizerFactory = () -> {
SGDMinimizer<DiffFunction> firstMinimizer = new SGDMinimizer<>(sigma, 50, 1000);
QNMinimizer secondMinimizer = new QNMinimizer(15);
return new HybridMinimizer(firstMinimizer, secondMinimizer, 50);
};
break;
case L1:
minimizerFactory = () -> {
try {
return MetaClass.create("edu.stanford.nlp.optimization.OWLQNMinimizer").createInstance(sigma);
} catch (Exception e) {
log.err("Could not create l1 minimizer! Reverting to l2.");
return new QNMinimizer(15);
}
};
break;
default:
throw new IllegalStateException("Unknown minimizer: " + minimizer);
}
factory.setMinimizerCreator(minimizerFactory);
return factory;
}
/**
* Train a multinomial classifier off of the provided dataset.
* @param dataset The dataset to train the classifier off of.
* @return A classifier.
*/
public static Classifier<String, String> trainMultinomialClassifier(View on GitHub (pinned to 1b7edd19c4)