stanfordnlp/CoreNLP · warning

QNMinimizer terminated without converging

Error message

QNMinimizer terminated without converging

What it means

QNMinimizer (Stanford CoreNLP's L-BFGS quasi-Newton optimizer) finished its main loop through a 'default' branch of the termination-state switch, meaning it stopped for a reason other than achieving evaluation improvement or a normal convergence criterion. The optimizer marks the run as not successful and logs this warning. It indicates the optimization did not reach a proper minimum within its configured limits.

Solutions

  1. Increase the maximum number of iterations (useMaxIterations/useSummedObj etc. options passed to the trainer) so the optimizer has room to converge.
  2. Inspect training data for degenerate/duplicate features or extreme values that break numerical stability of the objective.
  3. Verify the objective (DiffFunction) never returns NaN or Infinity; fix the function or filter bad examples.
  4. Loosen the convergence tolerance (e.g., QNMinimizer's TOL / useEvalImprovement settings) if near-convergence is acceptable.
  5. Treat the returned weights with caution: since success=false, consider re-training with different initialization or regularization.

Example fix

// before
QNMinimizer minimizer = new QNMinimizer(15);
double[] result = minimizer.minimize(f, 100, initial, options); // may stop at 100 iters without converging

// after
QNMinimizer minimizer = new QNMinimizer(15);
minimizer.useMaxIterations();
double[] result = minimizer.minimize(f, 10000, initial, options); // more iterations to converge
Defensive patterns

Strategy: validation

Validate before calling

// Check the objective produces finite values at the initial point before minimizing
if (!Arrays.stream(f.domain().sampleNeighborhood(initial)).allMatch(v -> Double.isFinite(f.valueAt(v)))) {
  throw new IllegalStateException("Objective returns non-finite values; fix data/features before training");
}

Prevention

When it happens

Trigger: minimize() ran until an unhandled TerminationCondition state was reached, typically hitting maxIterations/maxTime without the convergence tests firing, or an objective function producing NaN/Inf evaluations that prevented the normal TERMINATE_EvalImprovement path from being taken.

Common situations: Training a CoreNLP model (e.g., classifier or parser) with too few iterations, a badly scaled or noisy objective, learning data with degenerate features, or a DiffFunction that returns NaN for bad parameter values.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/optimization/QNMinimizer.java:1125

    case TERMINATE_RELATIVENORM:
      if (!quiet) log.info("QNMinimizer terminated due to sufficient decrease in gradient norms: |g|/|g0| < TOL ");
      success = true;
      break;
    case TERMINATE_AVERAGEIMPROVE:
      if (!quiet) log.info("QNMinimizer terminated due to average improvement: | newest_val - previous_val | / |newestVal| < TOL ");
      success = true;
      break;
    case TERMINATE_MAXITR:
      if (!quiet) log.info("QNMinimizer terminated due to reached max iteration " + maxItr);
      success = true;
      break;
    case TERMINATE_EVALIMPROVE:
      if (!quiet) log.info("QNMinimizer terminated due to no improvement on eval ");
      success = true;
      x = rec.getBest();
      break;
    default:
      log.warn("QNMinimizer terminated without converging");
      success = false;
      break;
    }

    double completionTime = rec.howLong();
    if (!quiet) log.info("Total time spent in optimization: " + nfsec.format(completionTime) + 's');

    if (outputToFile) {
      infoFile.println(completionTime + "; Total Time ");
      infoFile.println(fevals + "; Total evaluations");
      infoFile.close();
      outFile.close();
    }

    qn.free();
    return x;

  } // end minimize()

View on GitHub (pinned to 1b7edd19c4)