Fixing bug setting index when parsing Google Vertex AI results#117287
Merged
ymao1 merged 6 commits intoelastic:mainfrom Nov 22, 2024
Merged
Fixing bug setting index when parsing Google Vertex AI results#117287ymao1 merged 6 commits intoelastic:mainfrom
ymao1 merged 6 commits intoelastic:mainfrom
Conversation
4360eb2 to
194f36d
Compare
Collaborator
|
Pinging @elastic/ml-core (Team:ML) |
Collaborator
|
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); |
Contributor
There was a problem hiding this comment.
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.
…arch into google-vertex-rerank-bug
jonathan-buttner
approved these changes
Nov 22, 2024
Contributor
jonathan-buttner
left a comment
There was a problem hiding this comment.
Thanks for the change!
Collaborator
💚 Backport successful
|
ymao1
added a commit
to ymao1/elasticsearch
that referenced
this pull request
Nov 22, 2024
…ic#117287) * Using record ID as index value when parsing Google Vertex AI rerank results * Update docs/changelog/117287.yaml * PR feedback
elasticsearchmachine
pushed a commit
that referenced
this pull request
Nov 22, 2024
…) (#117358) * Using record ID as index value when parsing Google Vertex AI rerank results * Update docs/changelog/117287.yaml * PR feedback
smalyshev
pushed a commit
to smalyshev/elasticsearch
that referenced
this pull request
Nov 22, 2024
…ic#117287) * Using record ID as index value when parsing Google Vertex AI rerank results * Update docs/changelog/117287.yaml * PR feedback
alexey-ivanov-es
pushed a commit
to alexey-ivanov-es/elasticsearch
that referenced
this pull request
Nov 28, 2024
…ic#117287) * Using record ID as index value when parsing Google Vertex AI rerank results * Update docs/changelog/117287.yaml * PR feedback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.