Skip to content

Apply retrieval and reranking depth after candidate filtering - #1635

Open
Afloat16 wants to merge 1 commit into
FlagOpen:masterfrom
Afloat16:fix/filtered-search-depth-20261112
Open

Afloat16 wants to merge 1 commit into
FlagOpen:masterfrom
Afloat16:fix/filtered-search-depth-20261112

Conversation

@Afloat16

Copy link
Copy Markdown

Problem

The configured search or reranking depth is applied before excluded candidates are removed. Dense retrieval can return fewer eligible documents when a query ID also occurs in the corpus. BRIGHT retrieval has the same issue for its per-query exclusion lists, and reranking can discard a valid candidate at the depth boundary when an identical ID occupies an earlier slot.

Changes

  • Retrieve one additional dense candidate when identical IDs are excluded, then cap the eligible output at the requested depth.
  • For BRIGHT, retrieve enough candidates for the largest relevant exclusion list (plus an optional identical ID), bounded by the corpus size. Keep the existing N/A sentinel behavior.
  • Remove identical IDs from the reranker candidate sequence before selecting its configured depth.

Validation

Added 30 tests using local tiny BERT models, the native embedder/reranker, and FAISS. Retrieval results are compared with a full NumPy similarity ranking after applying the same eligibility rules. Cases cover depths 1, 2, and larger than the corpus; multiple BRIGHT exclusions; queries with and without corpus IDs; and enabled/disabled identical-ID filtering.

  • New tests against the unchanged upstream base: 14 failed, 16 passed.
  • New tests with this change plus the existing Trainer/import checks: 38 passed, 1 skipped.
  • Ruff on the new test module and git diff --check passed.

This change fixes candidate selection depth. It does not change embedding scores, reranking scores, or exclusion policy.

This branch has not been deployed

No deployments
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.

1 participant