fix(rerank): normalize NVIDIA logit scores - #2496
Merged
lyingbug merged 1 commit intoAug 3, 2026
Merged
Conversation
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.
中文
修复内容
logit映射为[0, 1]概率型RelevanceScore。复现说明
logit,例如23.0、5.0、2.0。RelevanceScore。聊天链把它们按概率型分数合成并截断到1,多个候选会出现相同的最终相关性,MMR 丢失模型的排序信息。23.0、0.0、-23.0分别转换为接近1、0.5、0的值,仍保留严格的相对顺序。NVIDIA 响应里的字段明确叫 logit,但代码直接映射到 RelevanceScore:[nvidia_reranker.go (line 42)]
随后不做转换地复制给公共结果:[nvidia_reranker.go (line 126)
聊天 pipeline 再把它代入:
composite := 0.6modelScore + 0.3baseScore + 0.1*sourceWeight
然后强制限制到 [0,1]:[rerank.go (line 439)。
假设原始召回分数 baseScore=0.5、普通知识库来源权重为 1:
logit = 23 → 0.6×23 + 0.3×0.5 + 0.1 = 14.05 → 截断为 1
logit = 5 → 0.6×5 + 0.3×0.5 + 0.1 = 3.25 → 截断为 1
logit = 2 → 0.6×2 + 0.3×0.5 + 0.1 = 1.45 → 截断为 1
logit = -23 → -13.55 → 截断为 0
原来 23 > 5 > 2,进入 MMR 后却全是 1。
验证
go test ./internal/models/rerank ./internal/application/service/chat_pipeline -count=1go vet ./internal/models/rerank未修改仓库文档。
English
Fix
logitresponse field to a probability-like[0, 1]RelevanceScore.Reproduction
logitvalues, for example23.0,5.0, and2.0.RelevanceScore. The chat pipeline then combined them as probability-like scores and capped them at1, giving multiple candidates the same final relevance and causing MMR to lose the model ranking signal.23.0,0.0, and-23.0become values near1,0.5, and0, respectively, while preserving strict relative order.Verification
go test ./internal/models/rerank ./internal/application/service/chat_pipeline -count=1go vet ./internal/models/rerankNo repository documentation was changed.
Checklist
git diff --check upstream/main...HEAD