Skip to content

Keep equal-score retrieval candidates stable across repeated queries - #1060

Merged
WaylandYang merged 2 commits into
deeplethe:devfrom
Maya-Kid:codex/deterministic-rrf-ties
Oct 3, 2026
Merged

WaylandYang merged 2 commits into
deeplethe:devfrom
Maya-Kid:codex/deterministic-rrf-ties

Conversation

@Maya-Kid

@Maya-Kid Maya-Kid commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Equal RRF scores inherited the randomized iteration order of a HashMap. With disjoint lexical/vector hits, repeating the same query could change both the evidence order and which candidate survives top_k; the shared helper also feeds concept mapping selection.

Break equal scores by ascending ID after descending score. Regressions cover ties across every cutoff (including zero), reversed channel order, and equal totals formed from different rank contributions. Both new tests failed before the fix.

Validation on this branch:

  • cargo +1.98.1 fmt --all --check
  • cargo +1.98.1 clippy --locked --workspace --all-targets -- -D warnings
  • cargo +1.98.1 test --locked --workspace: 1,411 passed, with dedicated PostgreSQL 16/pgvector and both database/PDF requirements enabled; 6 existing opt-in tests remain ignored
  • cargo +1.98.1 build --locked --workspace
  • Unchanged frontend at the same base: frozen pnpm 10.2.1 install, 228 tests, and production build passed

Signed-off-by: dada-yan <BinjunYann@gmail.com>

@WaylandYang WaylandYang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @Maya-Kid. Equal RRF scores took the order of a freshly seeded HashMap, so the same query could keep different candidates at the cutoff. Breaking the tie by id after the score is the right fix, and the test at every limit pins it. Landing it.

@WaylandYang
WaylandYang merged commit 711246c into deeplethe:dev Oct 3, 2026
6 checks passed
@WaylandYang WaylandYang mentioned this pull request Oct 3, 2026
@Maya-Kid
Maya-Kid deleted the codex/deterministic-rrf-ties branch October 15, 2026 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants