Skip to content

Commit fccf218

Browse files
davidkyleprwhelan
andauthored
[ML] Record errors relating to the output of a model as conflict (#125135)
Co-authored-by: Pat Whelan <[email protected]>
1 parent 9447abe commit fccf218

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/nlp/QuestionAnsweringProcessor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public InferenceResults processResult(TokenizationResult tokenization, PyTorchIn
125125
if (pyTorchResult.getInferenceResult().length % 2 != 0) {
126126
throw new ElasticsearchStatusException(
127127
"question answering result has invalid dimension, number of dimensions must be a multiple of 2 found [{}]",
128-
RestStatus.INTERNAL_SERVER_ERROR,
128+
RestStatus.CONFLICT,
129129
pyTorchResult.getInferenceResult().length
130130
);
131131
}
@@ -138,7 +138,7 @@ public InferenceResults processResult(TokenizationResult tokenization, PyTorchIn
138138
if (numberOfSpans != tokensList.size()) {
139139
throw new ElasticsearchStatusException(
140140
"question answering result has invalid dimensions; the number of spans [{}] does not match batched token size [{}]",
141-
RestStatus.INTERNAL_SERVER_ERROR,
141+
RestStatus.CONFLICT,
142142
numberOfSpans,
143143
tokensList.size()
144144
);
@@ -153,7 +153,7 @@ public InferenceResults processResult(TokenizationResult tokenization, PyTorchIn
153153
if (starts.length != ends.length) {
154154
throw new ElasticsearchStatusException(
155155
"question answering result has invalid dimensions; start positions [{}] must equal potential end [{}]",
156-
RestStatus.INTERNAL_SERVER_ERROR,
156+
RestStatus.CONFLICT,
157157
starts.length,
158158
ends.length
159159
);
@@ -222,7 +222,7 @@ static void topScores(
222222
if (start.length != end.length) {
223223
throw new ElasticsearchStatusException(
224224
"question answering result has invalid dimensions; possible start tokens [{}] must equal possible end tokens [{}]",
225-
RestStatus.INTERNAL_SERVER_ERROR,
225+
RestStatus.CONFLICT,
226226
start.length,
227227
end.length
228228
);

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/nlp/TextClassificationProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static InferenceResults processResult(
9999
if (result.length != labels.size()) {
100100
throw new ElasticsearchStatusException(
101101
"Expected exactly [{}] values in text classification result; got [{}]",
102-
RestStatus.INTERNAL_SERVER_ERROR,
102+
RestStatus.CONFLICT,
103103
labels.size(),
104104
result.length
105105
);
@@ -108,7 +108,7 @@ static InferenceResults processResult(
108108
Map<Integer, List<TokenizationResult.Tokens>> windowedSeq = tokenization.getTokensBySequenceId();
109109
// TODO adjust logic when batch is allowed
110110
if (windowedSeq.size() > 1) {
111-
throw new ElasticsearchStatusException("Unexpected batch input for text classification", RestStatus.INTERNAL_SERVER_ERROR);
111+
throw new ElasticsearchStatusException("Unexpected batch input for text classification", RestStatus.CONFLICT);
112112
}
113113
double[] normalizedScores = new double[labels.size()];
114114
for (int i = 0; i < pyTorchResult.getInferenceResult()[0].length; i++) {

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/nlp/TextSimilarityProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public InferenceResults processResult(TokenizationResult tokenization, PyTorchIn
9999
if (result.length != 1) {
100100
throw new ElasticsearchStatusException(
101101
"Expected exactly [1] value in text_similarity result; got [{}]",
102-
RestStatus.INTERNAL_SERVER_ERROR,
102+
RestStatus.CONFLICT,
103103
result.length
104104
);
105105
}

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/nlp/ZeroShotClassificationProcessor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public InferenceResults processResult(TokenizationResult tokenization, PyTorchIn
147147
if (pyTorchResult.getInferenceResult()[0].length != labels.length) {
148148
throw new ElasticsearchStatusException(
149149
"Expected exactly [{}] values in zero shot classification result; got [{}]",
150-
RestStatus.INTERNAL_SERVER_ERROR,
150+
RestStatus.CONFLICT,
151151
labels.length,
152152
pyTorchResult.getInferenceResult().length
153153
);
@@ -160,7 +160,7 @@ public InferenceResults processResult(TokenizationResult tokenization, PyTorchIn
160160
if (vals.length != 3) {
161161
throw new ElasticsearchStatusException(
162162
"Expected exactly [{}] values in inner zero shot classification result; got [{}]",
163-
RestStatus.INTERNAL_SERVER_ERROR,
163+
RestStatus.CONFLICT,
164164
3,
165165
vals.length
166166
);
@@ -177,7 +177,7 @@ public InferenceResults processResult(TokenizationResult tokenization, PyTorchIn
177177
if (vals.length != 3) {
178178
throw new ElasticsearchStatusException(
179179
"Expected exactly [{}] values in inner zero shot classification result; got [{}]",
180-
RestStatus.INTERNAL_SERVER_ERROR,
180+
RestStatus.CONFLICT,
181181
3,
182182
vals.length
183183
);

0 commit comments

Comments
 (0)