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

Normalize negative scores for text_similarity_reranker retriever #120930

Merged

Conversation

pmpailis
Copy link
Contributor

@pmpailis pmpailis commented Jan 27, 2025

It is valid for some rerankers to return negative scores, so in this PR we add a normalization step for the final scores, to ensure that all scores are >=0, as Lucene assumes that all scores should be positive.

The normalization function that we'll apply is the following:

score = max(score, 0) + min(exp(score), 1)

which will ensure that all positive scores lie in the [1, inf) while negative values will be projected to (0, 1)

Closes #120201

Copy link
Contributor

Documentation preview:

@pmpailis pmpailis added >bug :Search Relevance/Ranking Scoring, rescoring, rank evaluation. auto-backport Automatically create backport pull requests when merged v8.18.0 v8.17.2 v8.16.4 labels Jan 27, 2025
@elasticsearchmachine
Copy link
Collaborator

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

@pmpailis pmpailis marked this pull request as ready for review January 28, 2025 11:24
@elasticsearchmachine elasticsearchmachine added the Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch label Jan 28, 2025
@elasticsearchmachine
Copy link
Collaborator

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

Copy link
Member

@benwtrent benwtrent left a comment

Choose a reason for hiding this comment

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

This is looking good to me. One minor question on the scoredoc query.

Copy link
Member

@benwtrent benwtrent left a comment

Choose a reason for hiding this comment

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

🥾
🐛

Bug squashed

@pmpailis pmpailis merged commit 8e2044d into elastic:main Jan 28, 2025
16 checks passed
pmpailis added a commit to pmpailis/elasticsearch that referenced this pull request Jan 28, 2025
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
8.x
8.17 Commit could not be cherrypicked due to conflicts
8.16 Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 120930

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 >bug :Search Relevance/Ranking Scoring, rescoring, rank evaluation. Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch v8.16.4 v8.17.2 v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

text_similarity_reranker returns negative scores for some models
3 participants