stanfordnlp/CoreNLP · error · RuntimeException
Error setting up training
Error message
Error setting up training
What it means
Clusterer.doTraining sets up output writers and loads dev-set documents; any Exception during this setup phase is wrapped in RuntimeException("Error setting up training"). It signals that statistical-coref clusterer training could not even begin (model file, progress file, or training data problems).
Solutions
- Ensure outputPath exists and is writable before training (create the directory, check 'progress' can be written)
- Verify the dev data path (StatisticalCorefTrainer.setDataPath("dev")) points to a directory with the expected conll/gold files
- Check the model file for the classifier is present and loadable
- Inspect e.getCause() to see whether it was the writer or the data loading that failed
Example fix
// before java edu.stanford.nlp.coref.statistical.ClustererTrain // outputPath=nonexistent/dir // after mkdir -p nonexistent/dir # and ensure dev data exists at configured dataPath java edu.stanford.nlp.coref.statistical.ClustererTrain
Defensive patterns
Strategy: validation
Validate before calling
java.io.File out = new java.io.File(outputPath);
if (!out.isDirectory() && !out.mkdirs()) throw new IllegalStateException("bad outputPath");
if (!out.canWrite()) throw new IllegalStateException("outputPath not writable");
java.io.File dev = new java.io.File(dataPath, "dev");
if (!dev.isDirectory()) throw new IllegalStateException("dev data missing at " + dev); Try / catch
try {
clusterer.doTraining();
} catch (RuntimeException e) {
if ("Error setting up training".equals(e.getMessage()))
throw new IllegalStateException("Training setup failed, cause: " + e.getCause(), e);
throw e;
} Prevention
- Create and permission-check the output directory before long training runs
- Verify dev/eval data files exist at the configured data path
- Keep the models/dcoref data layout intact
- Log e.getCause() to distinguish writer vs data-loading failures
When it happens
Trigger: Running statistical coref training where the output path/model file cannot be opened, the 'progress' writer cannot be created (e.g. unsupported charset or unwritable path), or ClustererDataLoader.loadDocuments fails to read dev data.
Common situations: Missing dev data files at the configured data path; outputPath property pointing to a non-existent directory; running the trainer outside the models/ directory layout it expects.
Related errors
- Error reading saved links
- Error creating data exporter
- RuntimeException wrapping IOException
- RuntimeIOException wrapping IOException
- Couldn't load
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/874c96ea4095fa83.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/coref/statistical/Clusterer.java:102
modelName + "/";
File outDir = new File(outputPath);
if (!outDir.exists()) {
outDir.mkdir();
}
PrintWriter progressWriter;
List<ClustererDoc> trainDocs;
try {
PrintWriter configWriter = new PrintWriter(outputPath + "config", "UTF-8");
configWriter.print(StatisticalCorefTrainer.fieldValues(this));
configWriter.close();
progressWriter = new PrintWriter(outputPath + "progress", "UTF-8");
Redwood.log("scoref.train", "Loading training data");
StatisticalCorefTrainer.setDataPath("dev");
trainDocs = ClustererDataLoader.loadDocuments(MAX_DOCS);
} catch (Exception e) {
throw new RuntimeException("Error setting up training", e);
}
double bestTrainScore = 0;
List<List<Pair<CandidateAction, CandidateAction>>> examples = new ArrayList<>();
for (int iteration = 0; iteration < RETRAIN_ITERATIONS; iteration++) {
Redwood.log("scoref.train", "ITERATION " + iteration);
classifier.printWeightVector(null);
Redwood.log("scoref.train", "");
try {
classifier.writeWeights(outputPath + "model");
classifier.printWeightVector(IOUtils.getPrintWriter(outputPath + "weights"));
} catch (Exception e) {
throw new RuntimeException();
}
long start = System.currentTimeMillis();
Collections.shuffle(trainDocs, random);
View on GitHub (pinned to 1b7edd19c4)