stanfordnlp/CoreNLP · critical · RuntimeIOException
Could not load affinity model at " + affinityModels + ": "…
Error message
Could not load affinity model at " + affinityModels + ": " + e.getMessage()
What it means
When entailments are enabled and affinity models are not ignored, the OpenIE constructor builds NaturalLogicWeights from the configured affinity model paths. An IOException during that load is rethrown as a RuntimeIOException including the underlying message. This fails during annotator construction, before any annotation runs.
Solutions
- Verify the affinity model files exist and are readable at the configured paths.
- Set the openie.ignore_affinity property to true if you don't need entailment weights, bypassing affinity model loading.
- Ensure the CoreNLP models jar matching your version is on the classpath and re-download corrupt model files.
- Catch RuntimeIOException during pipeline construction and surface the nested message for diagnosis.
Example fix
// before
props.setProperty("annotators", "tokenize,ssplit,pos,lemma,depparse,natlog,openie"); // needs affinity models
// after
props.setProperty("openie.ignore_affinity", "true"); // or provide valid openie.affinity_models paths Defensive patterns
Strategy: try-catch
Validate before calling
if (!props.containsKey("openie.ignore_affinity") && props.getProperty("openie.affinity_models") != null) {
for (String p : props.getProperty("openie.affinity_models").split(";")) {
java.io.File f = new java.io.File(p);
if (!f.isFile()) throw new IllegalArgumentException("Affinity model missing: " + p);
}
} Try / catch
try {
openie = new OpenIE(props);
} catch (RuntimeIOException e) {
log.error("Affinity model load failed: " + e.getMessage());
} Prevention
- Download affinity models when enabling entailment
- Set openie.ignore_affinity=true if you don't need entailment weights
- Verify model paths and CoreNLP version compatibility before startup
When it happens
Trigger: Constructing OpenIE with -openie.affinity_models pointing at a missing/corrupt affinity model file (unless -openie.ignore_affinity is set), or with models incompatible with the current CoreNLP version.
Common situations: Enabling entailment without downloading the affinity models; wrong file paths; classpath missing the models jar; version mismatch between affinity model files and library.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Could not load clause splitter model at " + splitterModel
- Error leading weights from
- Error loading classifier from
- Error while loading a tagger model (probably missing model…
- Failed to load segmenter
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/e66a56a81d19cba3.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/naturalli/OpenIE.java:199
clauseSplitter = Optional.empty();
} else {
if (noModel) {
log.info("Not loading a splitter model");
clauseSplitter = Optional.of(ClauseSplitterSearchProblem::new);
} else {
clauseSplitter = Optional.of(ClauseSplitter.load(splitterModel));
}
}
} catch (IOException e) {
//throw new RuntimeIOException("Could not load clause splitter model at " + splitterModel + ": " + e.getClass() + ": " + e.getMessage());
throw new RuntimeIOException("Could not load clause splitter model at " + splitterModel, e);
}
// Create the forward entailer
try {
this.weights = ignoreAffinity ? new NaturalLogicWeights(affinityProbabilityCap) : new NaturalLogicWeights(affinityModels, affinityProbabilityCap);
} catch (IOException e) {
throw new RuntimeIOException("Could not load affinity model at " + affinityModels + ": " + e.getMessage());
}
forwardEntailer = new ForwardEntailer(entailmentsPerSentence, weights);
// Create the relation segmenter
segmenter = new RelationTripleSegmenter(allNominals);
}
/**
* Find the clauses in a sentence, where the sentence is expressed as a dependency tree.
*
* @param tree The dependency tree representation of the sentence.
* @param assumedTruth The assumed truth of the sentence. This is almost always true, unless you are
* doing some more nuanced reasoning.
*
* @return A set of clauses extracted from the sentence. This includes the original sentence.
*/
@SuppressWarnings("unchecked")
public List<SentenceFragment> clausesInSentence(SemanticGraph tree, boolean assumedTruth) {View on GitHub (pinned to 1b7edd19c4)