{"record":{"id":"ce68c01ccdc912bf","repo":"stanfordnlp/CoreNLP","slug":"error-running-testgibbs-inference","errorCode":null,"errorMessage":"Error running testGibbs inference!","messagePattern":"Error running testGibbs inference!","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ie/crf/CRFClassifier.java","lineNumber":1065,"sourceCode":"\n  @Override\n  public void dumpFeatures(Collection<List<IN>> docs) {\n    if (flags.exportFeatures != null) {\n      Timing timer = new Timing();\n      CRFFeatureExporter<IN> featureExporter = new CRFFeatureExporter<>(this);\n      featureExporter.printFeatures(flags.exportFeatures, docs);\n      long elapsedMs = timer.stop();\n      log.info(\"Time to export features: \" + Timing.toSecondsString(elapsedMs) + \" seconds\");\n    }\n  }\n\n  @Override\n  public List<IN> classify(List<IN> document) {\n    if (flags.doGibbs) {\n      try {\n        return classifyGibbs(document);\n      } catch (Exception e) {\n        throw new RuntimeException(\"Error running testGibbs inference!\", e);\n      }\n    } else if (flags.crfType.equalsIgnoreCase(\"maxent\")) {\n      return classifyMaxEnt(document);\n    } else {\n      throw new RuntimeException(\"Unsupported inference type: \" + flags.crfType);\n    }\n  }\n\n  private List<IN> classify(List<IN> document, Triple<int[][][], int[], double[][][]> documentDataAndLabels) {\n    if (flags.doGibbs) {\n      try {\n        return classifyGibbs(document, documentDataAndLabels);\n      } catch (Exception e) {\n        throw new RuntimeException(\"Error running testGibbs inference!\", e);\n      }\n    } else if (flags.crfType.equalsIgnoreCase(\"maxent\")) {\n      return classifyMaxEnt(document, documentDataAndLabels);\n    } else {","sourceCodeStart":1047,"sourceCodeEnd":1083,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/crf/CRFClassifier.java#L1047-L1083","documentation":"classify() supports Gibbs-sampling inference when flags.doGibbs is true; any exception thrown by classifyGibbs (e.g. from the transducer model, factor graphs, or class factory configuration) is wrapped in a RuntimeException with this message and the original cause attached.","triggerScenarios":"Calling classify(document) with flags.doGibbs=true when classifyGibbs throws — commonly a ClassCastException/InstantiationException creating the SeqClassifierFlags.sequenceModelClass or documentWriterClass, or a bad factorFactory.","commonSituations":"Setting doGibbs in properties without specifying a valid sequenceModelClass; class names that don't exist on the classpath; incompatible custom sequence model implementations after a CoreNLP upgrade.","solutions":["Inspect the cause chain (e.getCause()) — the real failure is inside classifyGibbs; fix that underlying error.","If Gibbs inference is not required, set flags.doGibbs=false to use the default maxent/Viterbi path.","Verify flags.sequenceModelClass (and related factory classes) name existing, loadable classes compatible with your CoreNLP version."],"exampleFix":"// before\nprops.setProperty(\"doGibbs\", \"true\"); // missing sequenceModelClass\n// after\nprops.setProperty(\"doGibbs\", \"true\");\nprops.setProperty(\"sequenceModelClass\", \"edu.stanford.nlp.sequences.FactoredSequenceModel\");","handlingStrategy":"try-catch","validationCode":"if (flags.doGibbs) {\n  Class.forName(flags.sequenceModelClass, true, getClass().getClassLoader());\n}","typeGuard":null,"tryCatchPattern":"try {\n  return classifier.classify(document);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"testGibbs\")) {\n    e.getCause().printStackTrace(); // real failure inside classifyGibbs\n    return classifier.classifyMaxEnt(document); // fallback\n  }\n  throw e;\n}","preventionTips":["Provide a valid sequenceModelClass whenever doGibbs is enabled.","Prefer the default maxent path unless Gibbs sampling is specifically needed.","Keep CoreNLP jar version consistent with the model's serialized flags."],"tags":["java","crf","inference","gibbs"],"backgroundTag":"module-init-failed","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"}