{"record":{"id":"aec65a7c0fafcc56","repo":"stanfordnlp/CoreNLP","slug":"unknown-inference-type-flags-inferencetype","errorCode":null,"errorMessage":"Unknown inference type: \" + flags.inferenceType + \". Your options are Viterbi|Beam.","messagePattern":"Unknown inference type: \" \\+ flags\\.inferenceType \\+ \"\\. Your options are Viterbi\\|Beam\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ie/crf/CRFClassifier.java","lineNumber":1185,"sourceCode":"    return classifyMaxEnt(document, model);\n  }\n\n  private List<IN> classifyMaxEnt(List<IN> document, SequenceModel model) {\n    if (document.isEmpty()) {\n      return document;\n    }\n\n    if (flags.inferenceType == null) {\n      flags.inferenceType = \"Viterbi\";\n    }\n\n    BestSequenceFinder tagInference;\n    if (flags.inferenceType.equalsIgnoreCase(\"Viterbi\")) {\n      tagInference = new ExactBestSequenceFinder();\n    } else if (flags.inferenceType.equalsIgnoreCase(\"Beam\")) {\n      tagInference = new BeamBestSequenceFinder(flags.beamSize);\n    } else {\n      throw new RuntimeException(\"Unknown inference type: \" + flags.inferenceType + \". Your options are Viterbi|Beam.\");\n    }\n\n    int[] bestSequence = tagInference.bestSequence(model);\n\n    if (flags.useReverse) {\n      Collections.reverse(document);\n    }\n    for (int j = 0, docSize = document.size(); j < docSize; j++) {\n      IN wi = document.get(j);\n      String guess = classIndex.get(bestSequence[j + windowSize - 1]);\n      wi.set(CoreAnnotations.AnswerAnnotation.class, guess);\n      int index = classIndex.indexOf(guess);\n      double guessProb = ((TestSequenceModel) model).labelProb(j, index);\n      wi.set(CoreAnnotations.AnswerProbAnnotation.class, guessProb);\n    }\n    if (flags.useReverse) {\n      Collections.reverse(document);\n    }","sourceCodeStart":1167,"sourceCodeEnd":1203,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/crf/CRFClassifier.java#L1167-L1203","documentation":"During CRF document inference, CRFClassifier selects a BestSequenceFinder from flags.inferenceType: \"Viterbi\" maps to ExactBestSequenceFinder and \"Beam\" to BeamBestSequenceFinder(flags.beamSize), both matched case-insensitively. Any other value throws this RuntimeException rather than silently defaulting, since the wrong inference algorithm would silently change labeling behavior.","triggerScenarios":"Setting the inferenceType property to anything besides Viterbi or Beam (e.g. \"vit\", \"exact\", \"gibbs\", \"viterbi-search\") on a run that goes through this CRF inference path.","commonSituations":"Typos; copying inference options from other NLP toolkits; confusing these flags with the Gibbs sampling options, which are configured separately.","solutions":["Set inferenceType to \"Viterbi\" or \"Beam\" (case-insensitive).","If using Beam, also set beamSize for BeamBestSequenceFinder.","Remove the property only after confirming the flags default is a supported value.","For Gibbs sampling use the dedicated sampler flags (useUniformPrior, annealingType), not inferenceType."],"exampleFix":"// before\nprops.setProperty(\"inferenceType\", \"viterbi-search\");\n// after\nprops.setProperty(\"inferenceType\", \"Viterbi\");","handlingStrategy":"validation","validationCode":"Set<String> allowed = new HashSet<>(Arrays.asList(\"viterbi\", \"beam\"));\nString t = props.getProperty(\"inferenceType\", \"Viterbi\");\nif (!allowed.contains(t.toLowerCase(Locale.ROOT))) {\n  throw new IllegalArgumentException(\"inferenceType must be Viterbi or Beam, got: \" + t);\n}","typeGuard":null,"tryCatchPattern":"try {\n  classifier.train(files);\n} catch (RuntimeException e) {\n  if (String.valueOf(e.getMessage()).contains(\"Unknown inference type\")) {\n    props.setProperty(\"inferenceType\", \"Viterbi\");\n    // rebuild classifier and retry\n  } else throw e;\n}","preventionTips":["Only use the documented inferenceType values Viterbi and Beam.","Validate the properties file against SeqModelFlags defaults before long runs.","Spelling must be exact; case is ignored."],"tags":["java","config","crf","nlp"],"backgroundTag":"invalid-enum-value","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"}