stanfordnlp/CoreNLP · error · RuntimeException
no prior specified
Error message
no prior specified
What it means
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.
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.
Example fix
// before
props.setProperty("useGibbsInference", "true");
// after
props.setProperty("useGibbsInference", "true");
props.setProperty("useUniformPrior", "true"); Defensive patterns
Strategy: validation
Validate before calling
if ("true".equals(props.getProperty("useGibbsInference", "false"))
&& !"true".equals(props.getProperty("useUniformPrior", "false"))
&& props.getProperty("priorModelFactory") == null) {
throw new IllegalArgumentException("Gibbs inference needs useUniformPrior=true or a priorModelFactory with prior flags enabled");
} Try / catch
try {
classifier.classify(docs);
} catch (RuntimeException e) {
if ("no prior specified".equals(e.getMessage())) {
props.setProperty("useUniformPrior", "true");
// reconfigure and retry
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- Error running testGibbs inference!
- Unsupported inference type: " + flags.crfType
- Unknown inference type: " + flags.inferenceType + ". Your…
- No annealing type specified
- No minimizer assigned!
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/667efa900e63d7d5.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/ie/crf/CRFClassifier.java:1231
public List<IN> classifyGibbs(List<IN> document, Triple<int[][][], int[], double[][][]> documentDataAndLabels)
throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException,
InstantiationException, IllegalAccessException, InvocationTargetException {
// log.info("Testing using Gibbs sampling.");
List<IN> newDocument = document; // reversed if necessary
if (flags.useReverse) {
Collections.reverse(document);
newDocument = new ArrayList<>(document);
Collections.reverse(document);
}
CRFCliqueTree<? extends CharSequence> cliqueTree = getCliqueTree(documentDataAndLabels);
PriorModelFactory<IN> pmf = (PriorModelFactory<IN>) Class.forName(flags.priorModelFactory).newInstance();
ListeningSequenceModel prior = pmf.getInstance(flags.backgroundSymbol, classIndex, tagIndex, newDocument, entityMatrices, flags);
if ( ! flags.useUniformPrior) {
throw new RuntimeException("no prior specified");
}
SequenceModel model = new FactoredSequenceModel(cliqueTree, prior);
SequenceListener listener = new FactoredSequenceListener(cliqueTree, prior);
SequenceGibbsSampler sampler = new SequenceGibbsSampler(0, 0, listener);
int[] sequence = new int[cliqueTree.length()];
if (flags.initViterbi) {
TestSequenceModel testSequenceModel = new TestSequenceModel(cliqueTree);
ExactBestSequenceFinder tagInference = new ExactBestSequenceFinder();
int[] bestSequence = tagInference.bestSequence(testSequenceModel);
System.arraycopy(bestSequence, windowSize - 1, sequence, 0, sequence.length);
} else {
int[] initialSequence = SequenceGibbsSampler.getRandomSequence(model);
System.arraycopy(initialSequence, 0, sequence, 0, sequence.length);
}
View on GitHub (pinned to 1b7edd19c4)