{"record":{"id":"a53d0f355c67e37c","repo":"stanfordnlp/CoreNLP","slug":"could-not-create-l1-minimizer-reverting-to-l2","errorCode":null,"errorMessage":"Could not create l1 minimizer! Reverting to l2.","messagePattern":"Could not create l1 minimizer! Reverting to l2\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/edu/stanford/nlp/ie/KBPStatisticalExtractor.java","lineNumber":591,"sourceCode":"        minimizerFactory = () -> new QNMinimizer(15);\n        break;\n      case SGD:\n        minimizerFactory = () -> new SGDMinimizer<>(sigma, 100, 1000);\n        break;\n      case HYBRID:\n        factory.useHybridMinimizerWithInPlaceSGD(100, 1000, sigma);\n        minimizerFactory = () -> {\n          SGDMinimizer<DiffFunction> firstMinimizer = new SGDMinimizer<>(sigma, 50, 1000);\n          QNMinimizer secondMinimizer = new QNMinimizer(15);\n          return new HybridMinimizer(firstMinimizer, secondMinimizer, 50);\n        };\n        break;\n      case L1:\n        minimizerFactory = () -> {\n          try {\n            return MetaClass.create(\"edu.stanford.nlp.optimization.OWLQNMinimizer\").createInstance(sigma);\n          } catch (Exception e) {\n            log.err(\"Could not create l1 minimizer! Reverting to l2.\");\n            return new QNMinimizer(15);\n          }\n        };\n        break;\n      default:\n        throw new IllegalStateException(\"Unknown minimizer: \" + minimizer);\n    }\n    factory.setMinimizerCreator(minimizerFactory);\n    return factory;\n  }\n\n\n  /**\n   * Train a multinomial classifier off of the provided dataset.\n   * @param dataset The dataset to train the classifier off of.\n   * @return A classifier.\n   */\n  public static Classifier<String, String> trainMultinomialClassifier(","sourceCodeStart":573,"sourceCodeEnd":609,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/KBPStatisticalExtractor.java#L573-L609","documentation":"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.","triggerScenarios":"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).","commonSituations":"Running with a trimmed/partial CoreNLP jar that omits optimization classes; version drift where OWLQNMinimizer's constructor changed; shading/proguard builds stripping the class.","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."],"exampleFix":"// before: silent fallback hides the cause\ncatch (Exception e) { log.err(\"Could not create l1 minimizer! Reverting to l2.\"); return new QNMinimizer(15); }\n// after: surface the cause\ncatch (Exception e) { log.err(\"Could not create l1 minimizer! Reverting to l2.\", e); return new QNMinimizer(15); }","handlingStrategy":"try-catch","validationCode":"boolean l1Available() {\n  try { Class.forName(\"edu.stanford.nlp.optimization.OWLQNMinimizer\"); return true; }\n  catch (ClassNotFoundException e) { return false; }\n}","typeGuard":null,"tryCatchPattern":"try { new OWLQNMinimizer(sigma); } catch (Throwable t) { log.warn(\"L1 minimizer unavailable (\" + t + \"); using L2 QNMinimizer\"); useQN(); }","preventionTips":["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"],"tags":["reflection","classpath","fallback","kbp"],"backgroundTag":"class-not-found","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"}