{"record":{"id":"667efa900e63d7d5","repo":"stanfordnlp/CoreNLP","slug":"no-prior-specified","errorCode":null,"errorMessage":"no prior specified","messagePattern":"no prior specified","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ie/crf/CRFClassifier.java","lineNumber":1231,"sourceCode":"\n  public List<IN> classifyGibbs(List<IN> document, Triple<int[][][], int[], double[][][]> documentDataAndLabels)\n      throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException,\n      InstantiationException, IllegalAccessException, InvocationTargetException {\n    // log.info(\"Testing using Gibbs sampling.\");\n    List<IN> newDocument = document; // reversed if necessary\n    if (flags.useReverse) {\n      Collections.reverse(document);\n      newDocument = new ArrayList<>(document);\n      Collections.reverse(document);\n    }\n\n    CRFCliqueTree<? extends CharSequence> cliqueTree = getCliqueTree(documentDataAndLabels);\n\n    PriorModelFactory<IN> pmf = (PriorModelFactory<IN>) Class.forName(flags.priorModelFactory).newInstance();\n    ListeningSequenceModel prior = pmf.getInstance(flags.backgroundSymbol, classIndex, tagIndex, newDocument, entityMatrices, flags);\n\n    if ( ! flags.useUniformPrior) {\n      throw new RuntimeException(\"no prior specified\");\n    }\n\n    SequenceModel model = new FactoredSequenceModel(cliqueTree, prior);\n    SequenceListener listener = new FactoredSequenceListener(cliqueTree, prior);\n\n    SequenceGibbsSampler sampler = new SequenceGibbsSampler(0, 0, listener);\n    int[] sequence = new int[cliqueTree.length()];\n\n    if (flags.initViterbi) {\n      TestSequenceModel testSequenceModel = new TestSequenceModel(cliqueTree);\n      ExactBestSequenceFinder tagInference = new ExactBestSequenceFinder();\n      int[] bestSequence = tagInference.bestSequence(testSequenceModel);\n      System.arraycopy(bestSequence, windowSize - 1, sequence, 0, sequence.length);\n    } else {\n      int[] initialSequence = SequenceGibbsSampler.getRandomSequence(model);\n      System.arraycopy(initialSequence, 0, sequence, 0, sequence.length);\n    }\n","sourceCodeStart":1213,"sourceCodeEnd":1249,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/crf/CRFClassifier.java#L1213-L1249","documentation":"In the CRF Gibbs-sampling label path, the clique tree must be factored with a prior ListeningSequenceModel built from flags.priorModelFactory. If the resulting configuration has useUniformPrior=false, no valid prior exists and FactoredSequenceModel would be ill-defined, so the code throws this RuntimeException.","triggerScenarios":"Running CRF inference through the Gibbs sampler while flags.useUniformPrior is false and no effective prior is configured (priorModelFactory loaded but prior flags off, or no prior flags at all).","commonSituations":"Enabling Gibbs inference without the matching prior flag; copying training properties into a test-time setup missing useUniformPrior; configuring a prior factory but forgetting to enable prior usage.","solutions":["Set useUniformPrior=true in the properties.","Or configure a real prior (usePrior=true plus prior flags, or a working priorModelFactory with prior flags enabled).","If Gibbs sampling is not required, use the Viterbi/Beam inference path instead."],"exampleFix":"// before\nprops.setProperty(\"useGibbsInference\", \"true\");\n// after\nprops.setProperty(\"useGibbsInference\", \"true\");\nprops.setProperty(\"useUniformPrior\", \"true\");","handlingStrategy":"validation","validationCode":"if (\"true\".equals(props.getProperty(\"useGibbsInference\", \"false\"))\n    && !\"true\".equals(props.getProperty(\"useUniformPrior\", \"false\"))\n    && props.getProperty(\"priorModelFactory\") == null) {\n  throw new IllegalArgumentException(\"Gibbs inference needs useUniformPrior=true or a priorModelFactory with prior flags enabled\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  classifier.classify(docs);\n} catch (RuntimeException e) {\n  if (\"no prior specified\".equals(e.getMessage())) {\n    props.setProperty(\"useUniformPrior\", \"true\");\n    // reconfigure and retry\n  } else throw e;\n}","preventionTips":["Whenever enabling Gibbs sampling, also enable useUniformPrior or a working prior configuration.","Keep a canonical, reviewed properties template for CRF inference.","Dump flags from logs to verify prior settings before long runs."],"tags":["java","config","crf","gibbs"],"backgroundTag":"missing-required-config-field","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"}