-
Notifications
You must be signed in to change notification settings - Fork 25.4k
Fixing bug setting index when parsing Google Vertex AI results #117287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
4360eb2
to
194f36d
Compare
Pinging @elastic/ml-core (Team:ML) |
Hi @ymao1, I've created a changelog YAML for you. |
throw new IllegalStateException(format(FAILED_TO_FIND_FIELD_TEMPLATE, RankedDoc.ID.getPreferredName())); | ||
} | ||
|
||
return new RankedDocsResults.RankedDoc(Integer.parseInt(parsedRankedDoc.id), parsedRankedDoc.score, parsedRankedDoc.content); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we catch the NumberFormatException
that could be thrown by parseInt
and provide a more friendly message about what went wrong?
Maybe add a test for an invalid integer too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in 68e2721
…arch into google-vertex-rerank-bug
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the change!
💚 Backport successful
|
…ic#117287) * Using record ID as index value when parsing Google Vertex AI rerank results * Update docs/changelog/117287.yaml * PR feedback
…) (#117358) * Using record ID as index value when parsing Google Vertex AI rerank results * Update docs/changelog/117287.yaml * PR feedback
…ic#117287) * Using record ID as index value when parsing Google Vertex AI rerank results * Update docs/changelog/117287.yaml * PR feedback
…ic#117287) * Using record ID as index value when parsing Google Vertex AI rerank results * Update docs/changelog/117287.yaml * PR feedback
For the Google Vertex AI rerank API, for an infer request with the following example inputs:
We create a request that looks like this, following the API specs
Note that for the ID, we use the index of the entry in the input array
elasticsearch/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/request/googlevertexai/GoogleVertexAiRerankRequestEntity.java
Lines 47 to 53 in 6d963d3
The API response is an array of records, sorted in descending order by score, for example
In our response parser, we were not using the record ID (index of the entry in the input array) as the index into our result array, resulting in results where the score did not match up to the entry in the input array.