stanfordnlp/CoreNLP · error · IllegalArgumentException
Input array with 0 rows
Error message
Input array with 0 rows
What it means
ConvertModels.toMatrix converts a List<List<Double>> into a SimpleMatrix but rejects empty input: calling it with a list containing zero rows throws IllegalArgumentException('Input array with 0 rows'). The neural model conversion code requires at least one row to infer matrix dimensions.
Solutions
- Check the input list is non-empty before calling toMatrix
- Verify the source model file is not empty or corrupt
- Regenerate the feature lists so at least one row is produced
Example fix
// before
SimpleMatrix m = ConvertModels.toMatrix(rows); // rows may be empty
// after
if (rows.isEmpty()) { throw new IllegalStateException("no rows to convert"); }
SimpleMatrix m = ConvertModels.toMatrix(rows); Defensive patterns
Strategy: validation
Validate before calling
if (rows == null || rows.isEmpty()) {
throw new IllegalArgumentException("toMatrix requires at least one row");
} Try / catch
try {
SimpleMatrix m = ConvertModels.toMatrix(rows);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("0 rows")) {
logger.warning("empty model features; skipping conversion");
return;
}
throw e;
} Prevention
- Check list size before converting model feature tables
- Validate serialized model files are non-empty before conversion
- Fail fast in feature extraction if zero entries are produced
When it happens
Trigger: Calling toMatrix with an empty List (in.size()==0), typically via toTensor, f, antecedentMatrix, anaphorMatrix, pairFeaturesMatrix, or pairwiseFirstLayerBias when a model file yields no feature rows.
Common situations: Converting an empty/corrupt serialized model (e.g. empty word-vector or sentiment model file) during legacy-to-new model conversion, or a preprocessing step that filtered out all entries.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- Input array with 0 columns
- Input array with uneven columns
- Attempt to make ObjectBank with empty file list
- Can't parse a zero-length sentence!
- No matching files
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/0a2e4f1b20dba805.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/neural/ConvertModels.java:80
}
}
return out;
}
public static List<List<List<Double>>> fromTensor(SimpleTensor in) {
List<List<List<Double>>> out = new ArrayList<>();
for (int i = 0; i < in.numSlices(); ++i) {
out.add(fromMatrix(in.getSlice(i)));
}
return out;
}
public static SimpleMatrix toMatrix(List<List<Double>> in) {
if (in.size() == 0) {
throw new IllegalArgumentException("Input array with 0 rows");
}
if (in.get(0).size() == 0) {
throw new IllegalArgumentException("Input array with 0 columns");
}
for (int i = 1; i < in.size(); ++i) {
if (in.get(i).size() != in.get(0).size()) {
throw new IllegalArgumentException("Input array with uneven columns");
}
}
SimpleMatrix out = new SimpleMatrix(in.size(), in.get(0).size());
for (int i = 0; i < in.size(); ++i) {
List<Double> row = in.get(i);
for (int j = 0; j < row.size(); ++j) {
out.set(i, j, row.get(j));
}
}
View on GitHub (pinned to 1b7edd19c4)