{"record":{"id":"e66a56a81d19cba3","repo":"stanfordnlp/CoreNLP","slug":"could-not-load-affinity-model-at-affinitymodel","errorCode":null,"errorMessage":"Could not load affinity model at \" + affinityModels + \": \" + e.getMessage()","messagePattern":"Could not load affinity model at \" \\+ affinityModels \\+ \": \" \\+ e\\.getMessage\\(\\)","errorType":"exception","errorClass":"RuntimeIOException","httpStatus":null,"severity":"critical","filePath":"src/edu/stanford/nlp/naturalli/OpenIE.java","lineNumber":199,"sourceCode":"        clauseSplitter = Optional.empty();\n      } else {\n        if (noModel) {\n          log.info(\"Not loading a splitter model\");\n          clauseSplitter = Optional.of(ClauseSplitterSearchProblem::new);\n        } else {\n          clauseSplitter = Optional.of(ClauseSplitter.load(splitterModel));\n        }\n      }\n    } catch (IOException e) {\n      //throw new RuntimeIOException(\"Could not load clause splitter model at \" + splitterModel + \": \" + e.getClass() + \": \" + e.getMessage());\n      throw new RuntimeIOException(\"Could not load clause splitter model at \" + splitterModel, e);\n    }\n\n    // Create the forward entailer\n    try {\n      this.weights = ignoreAffinity ? new NaturalLogicWeights(affinityProbabilityCap) : new NaturalLogicWeights(affinityModels, affinityProbabilityCap);\n    } catch (IOException e) {\n      throw new RuntimeIOException(\"Could not load affinity model at \" + affinityModels + \": \" + e.getMessage());\n    }\n    forwardEntailer = new ForwardEntailer(entailmentsPerSentence, weights);\n\n    // Create the relation segmenter\n    segmenter = new RelationTripleSegmenter(allNominals);\n  }\n\n  /**\n   * Find the clauses in a sentence, where the sentence is expressed as a dependency tree.\n   *\n   * @param tree The dependency tree representation of the sentence.\n   * @param assumedTruth The assumed truth of the sentence. This is almost always true, unless you are\n   *                     doing some more nuanced reasoning.\n   *\n   * @return A set of clauses extracted from the sentence. This includes the original sentence.\n   */\n  @SuppressWarnings(\"unchecked\")\n  public List<SentenceFragment> clausesInSentence(SemanticGraph tree, boolean assumedTruth) {","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/naturalli/OpenIE.java#L181-L217","documentation":"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.","triggerScenarios":"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.","commonSituations":"Enabling entailment without downloading the affinity models; wrong file paths; classpath missing the models jar; version mismatch between affinity model files and library.","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."],"exampleFix":"// before\nprops.setProperty(\"annotators\", \"tokenize,ssplit,pos,lemma,depparse,natlog,openie\"); // needs affinity models\n// after\nprops.setProperty(\"openie.ignore_affinity\", \"true\"); // or provide valid openie.affinity_models paths","handlingStrategy":"try-catch","validationCode":"if (!props.containsKey(\"openie.ignore_affinity\") && props.getProperty(\"openie.affinity_models\") != null) {\n  for (String p : props.getProperty(\"openie.affinity_models\").split(\";\")) {\n    java.io.File f = new java.io.File(p);\n    if (!f.isFile()) throw new IllegalArgumentException(\"Affinity model missing: \" + p);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  openie = new OpenIE(props);\n} catch (RuntimeIOException e) {\n  log.error(\"Affinity model load failed: \" + e.getMessage());\n}","preventionTips":["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"],"tags":["model-loading","io","openie","affinity-model","resource"],"backgroundTag":"file-not-found","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}