Skip to content
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

[8.x] Add new experimental rank_vectors mapping for late-interaction second order ranking (#118804) #119601

Merged
merged 2 commits into from
Jan 6, 2025

Conversation

benwtrent
Copy link
Member

Backports the following commits to 8.x:

… 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`.
@benwtrent benwtrent added :Search Relevance/Vectors Vector search >feature auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) backport release highlight Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch labels Jan 6, 2025
Copy link
Contributor

github-actions bot commented Jan 6, 2025

Documentation preview:

@elasticsearchmachine
Copy link
Collaborator

Hi @benwtrent, I've created a changelog YAML for you. Note that since this PR is labelled release highlight, you need to update the changelog YAML to fill out the extended information sections.

@elasticsearchmachine elasticsearchmachine merged commit 8555b35 into elastic:8.x Jan 6, 2025
15 checks passed
@benwtrent benwtrent deleted the backport/8.x/pr-118804 branch January 6, 2025 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) backport >feature release highlight :Search Relevance/Vectors Vector search Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch v8.18.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants