stanfordnlp/CoreNLP · error · IllegalArgumentException
Unknown model type " + modelType
Error message
Unknown model type " + modelType
What it means
After validating the -model property, ConvertModels.main dispatches on the Model enum; if the parsed modelType falls through all known branches it throws IllegalArgumentException('Unknown model type ' + modelType). This guards against enum values added to Model but not yet handled in main's switch/if chain.
Solutions
- Use a model type supported by this ConvertModels build (SENTIMENT, DVPARSER, EMBEDDING, COREF, FASTCOREF)
- Add a conversion branch for the new Model value in main
- Rebuild/upgrade to a CoreNLP version whose ConvertModels handles the model type
Example fix
// before java ... -model NEWTYPE -input m.gz -output m2.gz // after java ... -model COREF -input m.gz -output m2.gz // use a handled type, or patch main() to support NEWTYPE
Defensive patterns
Strategy: validation
Validate before calling
java.util.Set<String> handled = java.util.Set.of("SENTIMENT","DVPARSER","EMBEDDING","COREF","FASTCOREF");
if (!handled.contains(modelType)) {
throw new IllegalArgumentException("model type " + modelType + " has no conversion branch");
} Try / catch
try {
ConvertModels.main(args);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Unknown model type")) {
System.err.println("Model not supported by this ConvertModels build: " + e.getMessage());
System.exit(3);
}
throw e;
} Prevention
- Only pass model types supported by the deployed CoreNLP version
- Keep Model enum and main's dispatch in sync when extending the converter
- Pin a known-good CoreNLP version in conversion pipelines
When it happens
Trigger: Model enum contains a value with no conversion branch in main (e.g. a newly added model type), reaching the final else of main.
Common situations: Running a newer model enum value against an older ConvertModels version, or custom builds where Model was extended without updating main's dispatch.
Related errors
- Please specify -model, either SENTIMENT, DVPARSER…
- Someone didn't add a handler for a new docType.
- Arabic does not support feature type: " + feat.toString()
- CoNLLUOutputter: unknown dependencies type " +…
- Don't know anything about tagset
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/a79633d99d0f1fe6.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/neural/ConvertModels.java:467
ObjectInputStream in = IOUtils.readStreamFromString(inputPath);
NeuralCorefModel model = readCoref(in);
in.close();
IOUtils.writeObjectToFile(model, outputPath);
}
} else if (modelType == Model.FASTCOREF) {
if (stage == Stage.OLD) {
FastNeuralCorefModel model = ErasureUtils.uncheckedCast(IOUtils.readObjectFromURLOrClasspathOrFileSystem(inputPath));
ObjectOutputStream out = IOUtils.writeStreamFromString(outputPath);
writeFastCoref(model, out);
out.close();
} else {
ObjectInputStream in = IOUtils.readStreamFromString(inputPath);
FastNeuralCorefModel model = readFastCoref(in);
in.close();
IOUtils.writeObjectToFile(model, outputPath);
}
} else {
throw new IllegalArgumentException("Unknown model type " + modelType);
}
}
}
View on GitHub (pinned to 1b7edd19c4)