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

New vector_rescore parameter as a quantized index type option #124581

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

benwtrent
Copy link
Member

This adds a new parameter to the quantized index mapping that allows default oversampling and rescoring to occur.

This doesn't adjust any of the defaults. It allows it to be configured. When the user provides rescore_vector: {oversample: <number>} in the query it will overwrite it.

For example, here is how to use it with bbq:

PUT rescored_bbq
{
  "mappings": {
    "properties": {
      "vector": {
        "type": "dense_vector",
        "index_options": {
          "type": "bbq_hnsw",
          "rescore_vector": {"oversample": 3.0}
        }
      }
    }
  }
}

Then, when querying, it will auto oversample the k by 3x and rerank with the raw vectors.

POST _search
{
  "knn": {
    "query_vector": [...],
    "field": "vector"
  }
}

@benwtrent benwtrent requested a review from carlosdelest March 11, 2025 17:38
@elasticsearchmachine elasticsearchmachine added needs:triage Requires assignment of a team area label v9.1.0 labels Mar 11, 2025
@benwtrent benwtrent added >enhancement :Search Relevance/Vectors Vector search v8.19.0 and removed needs:triage Requires assignment of a team area label labels Mar 11, 2025
@elasticsearchmachine elasticsearchmachine added the Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch label Mar 11, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-relevance (Team:Search Relevance)

@elasticsearchmachine
Copy link
Collaborator

Hi @benwtrent, I've created a changelog YAML for you.

@benwtrent benwtrent added auto-backport Automatically create backport pull requests when merged and removed Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch labels Mar 11, 2025
@elasticsearchmachine elasticsearchmachine added the Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch label Mar 11, 2025
Copy link
Member

@carlosdelest carlosdelest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 🎉 Left some small doc comments

Comment on lines 2245 to 2250
Float oversample = indexOptions instanceof QuantizedIndexOptions quantizedIndexOptions
? quantizedIndexOptions.rescoreVector != null ? quantizedIndexOptions.rescoreVector.oversample() : null
: null;
if (queryOversample != null) {
oversample = queryOversample;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit - I find hard to follow multiple ternary operators

Suggested change
Float oversample = indexOptions instanceof QuantizedIndexOptions quantizedIndexOptions
? quantizedIndexOptions.rescoreVector != null ? quantizedIndexOptions.rescoreVector.oversample() : null
: null;
if (queryOversample != null) {
oversample = queryOversample;
}
Float oversample = null;
if (queryOversample != null) {
oversample = queryOversample;
} else if (queryOversample indexOptions instanceof QuantizedIndexOptions quantizedIndexOptions) {
oversample = quantizedIndexOptions.rescoreVector != null ? quantizedIndexOptions.rescoreVector.oversample() : null
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will refactor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged >enhancement :Search Relevance/Vectors Vector search Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch v8.19.0 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants