feat(retrieval): add diversity-aware ranking and duplicate suppression - #3943
Open
Syt3s wants to merge 1 commit into
Open
feat(retrieval): add diversity-aware ranking and duplicate suppression#3943Syt3s wants to merge 1 commit into
Syt3s wants to merge 1 commit into
Conversation
Syt3s
force-pushed
the
feat/diversity-aware-retrieval
branch
from
August 12, 2026 13:21
8d6c5c8 to
1fd8a75
Compare
Author
|
Hi @zhoujh01, this PR adds diversity-aware retrieval to reduce duplicate results and improve source coverage. It has been rebased onto the latest main, and all Python, TypeScript, and Rust checks are passing. Could you please review it when you have a chance? Thank you! |
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.
feat(retrieval): add diversity-aware ranking and duplicate suppression
Description
This PR adds opt-in diversity-aware ranking to
findand list-modesearch. It combines boundedcandidate over-fetching, MMR, source-group limits, logical-resource folding, and semantic
near-duplicate suppression while preserving the existing retrieval path when the option is omitted.
The public request contract is:
{ "diversity": { "strategy": "combined", "lambda": 0.7, "group_by": "source_root", "max_per_group": 2, "candidate_multiplier": 4, "similarity_threshold": 0.98 } }Human Involvement
The contributor selected the requirement, reviewed the proposed scope, requested implementation and
acceptance, selected the branch, and directed the implementation workflow and documentation format.
Related Issue
Fixes #3942
Type of Change
Changes Made
DiversityOptionsvalidation with publiclambdaaliasing, bounded candidateexpansion, and unknown-field rejection.
folding, dense cosine near-duplicate folding, and relevance/group fallback when embedding fails.
peer resources, agent skills, and L0/L1/L2 URI variants.
deduplicated_fromresult serialization and dictionary round trips.candidate_limitto hierarchical retrieval without changing the default public limit path.candidate pool at 500.
rejects it with HTTP 422.
combined ranking.
Testing
Commands and results:
Offline evaluation:
The duplicate rate decreased by 100%, source coverage and relevance metrics improved, and measured
fake-embedder p95 overhead remained below 1 ms.
Checklist
There are no dependent changes or external runtime dependencies required by this PR.