-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Add new experimental rank_vectors mapping for late-interaction second order ranking #118804
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
Add new experimental rank_vectors mapping for late-interaction second order ranking #118804
Conversation
Documentation preview: |
Pinging @elastic/es-search-relevance (Team:Search Relevance) |
Hi @benwtrent, I've created a changelog YAML for you. Note that since this PR is labelled |
.../src/main/java/org/elasticsearch/xpack/rank/vectors/script/RankVectorsPainlessExtension.java
Show resolved
Hide resolved
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.
LGTM
private final DenseVectorFieldMapper.ElementType elementType; | ||
private final int dims; | ||
|
||
RankVectorsDVLeafFieldData(LeafReader reader, String field, DenseVectorFieldMapper.ElementType elementType, int dims) { |
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.
We really should make ElementType
its own class. We should start some refactoring of DenseVectorFieldMapper
after this PR lands.
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.
LGTM
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.
LGTM
…asticsearch into feature/rank-vectors-plugin
💚 Backport successful
|
… order ranking (elastic#118804) Late-interaction models are powerful rerankers. While their size and overall cost doesn't lend itself for HNSW indexing, utilizing them as second order "brute-force" reranking can provide excellent boosts in relevance. At generally lower inference times than large cross-encoders. This commit exposes a new experimental `rank_vectors` field that allows for maxSim operations. This unlocks the initial, and most common use of late-interaction dense-models. For example, this is how you would use it via the API: ``` PUT index { "mappings": { "properties": { "late_interaction_vectors": { "type": "rank_vectors" } } } } ``` Then to index: ``` POST index/_doc { "late_interaction_vectors": [[0.1, ...],...] } ``` For querying, scoring can be exposed with scripting: ``` POST index/_search { "query": { "script_score": { "query": { "match_all": {} }, "script": { "source": "maxSimDotProduct(params.query_vector, 'my_vector')", "params": { "query_vector": [[0.42, ...], ...] } } } } } ``` Of course, the initial ranking should be done before re-scoring or combining via the `rescore` parameter, or simply passing whatever first phase retrieval you want as the inner query in `script_score`.
…second order ranking (#118804) (#119601) * Add new experimental rank_vectors mapping for late-interaction second order ranking (#118804) Late-interaction models are powerful rerankers. While their size and overall cost doesn't lend itself for HNSW indexing, utilizing them as second order "brute-force" reranking can provide excellent boosts in relevance. At generally lower inference times than large cross-encoders. This commit exposes a new experimental `rank_vectors` field that allows for maxSim operations. This unlocks the initial, and most common use of late-interaction dense-models. For example, this is how you would use it via the API: ``` PUT index { "mappings": { "properties": { "late_interaction_vectors": { "type": "rank_vectors" } } } } ``` Then to index: ``` POST index/_doc { "late_interaction_vectors": [[0.1, ...],...] } ``` For querying, scoring can be exposed with scripting: ``` POST index/_search { "query": { "script_score": { "query": { "match_all": {} }, "script": { "source": "maxSimDotProduct(params.query_vector, 'my_vector')", "params": { "query_vector": [[0.42, ...], ...] } } } } } ``` Of course, the initial ranking should be done before re-scoring or combining via the `rescore` parameter, or simply passing whatever first phase retrieval you want as the inner query in `script_score`. * Update docs/changelog/119601.yaml
Late-interaction models are powerful rerankers. While their size and overall cost doesn't lend itself for HNSW indexing, utilizing them as second order "brute-force" reranking can provide excellent boosts in relevance. At generally lower inference times than large cross-encoders.
This commit exposes a new experimental
rank_vectors
field that allows for maxSim operations. This unlocks the initial, and most common use of late-interaction dense-models.For example, this is how you would use it via the API:
Then to index:
For querying, scoring can be exposed with scripting:
Of course, the initial ranking should be done before re-scoring or combining via the
rescore
parameter, or simply passing whatever first phase retrieval you want as the inner query inscript_score
.