[RFC] Optional per-source candidate reservation before recall reranking
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start with the fusion and trimming code in hindsight_api/engine/search/fusion.py and hindsight_api/engine/search/recall_boost.py, then trace how recall selects candidates for real rerankers. The RFC proposes an opt-in per-source reservation, but leaves its count, configuration and edge-case behavior open. First evaluate source-head losses and compare candidate survival with final recall, answer quality, model cost and latency; done means evidence supports a policy and its scope.
Written by the indexing model from the issue text.
Description
Use Case
This RFC asks whether recall should optionally reserve a small number of candidates from each retrieval arm before a real cross-encoder or decision model reranks them.
The use case is a narrow factual query whose useful memory ranks highly in one arm but receives less cross-arm agreement than weaker candidates. The goal is to give the reranker an opportunity to judge that memory while keeping the total candidate cap fixed.
Problem Statement
The current pipeline combines semantic, BM25, graph and optional temporal results with RRF, then trims the merged pool to reranker_max_candidates. A candidate found by several arms can outrank a candidate found near the head of only one arm. Once the latter is trimmed, the reranker cannot recover it.
This can happen with recall_strategy_boosts={}. It is distinct from the excessive configured boost addressed by #3987: that PR changes boosted contributions and has no effect when boosts are empty.
There is relevant prior discussion:
- #3956 explicitly suggested “a per-arm floor within the cap”; #3987 implemented a rank-space boost instead.
- #1707 suggested reserving source quotas. #1947 added a BM25 match gate and an optional per-source upper cap, rather than a lower reservation.
- #6946 reports a useful fact at semantic rank 4, RRF rank 36, with a decision model receiving only 30 candidates. That report attributes the competing candidates to label/high-fanout entity noise. It motivates examining admission but is not proof that reservation is the best fix.
- #1907 uses interleave for consolidation's observation lookup. Its objective is to expose an existing merge target to the consolidation LLM. This RFC concerns the candidate set entering a real reranker for user-facing recall.
Evidence so far is a reproducible synthetic admission failure, not a measured improvement in retrieval or answer quality.
The following probe uses the repository's fusion and trimming functions. All arms contain the same 320 shared candidates in different orders; a candidate named answer appears only in the semantic arm. Each arm is truncated to the specified retrieval depth before fusion.
from hindsight_api.engine.search.fusion import reciprocal_rank_fusion
from hindsight_api.engine.search.recall_boost import trim_merged_candidates
from hindsight_api.engine.search.types import RetrievalResult
for arm_count, depth, answer_rank in [(3, 1000, 20), (4, 300, 10), (4, 1000, 1)]:
shared = [f"shared-{i}" for i in range(320)]
arms = []
for arm in range(arm_count):
offset = arm * (len(shared) // arm_count)
ids = shared[offset:] + shared[:offset]
if arm == 0:
ids.insert(answer_rank - 1, "answer")
arms.append([
RetrievalResult(id=i, text=i, fact_type="world")
for i in ids[:depth]
])
fused = reciprocal_rank_fusion(arms)
answer = next(c for c in fused if c.id == "answer")
kept = trim_merged_candidates(fused.copy(), 300, {}).kept
print(arm_count, depth, answer_rank, answer.rrf_rank,
any(c.id == "answer" for c in kept))
Output on checkout d8d03e044:
# arms, per-arm depth, semantic rank, RRF rank, survives 300-cap
3 1000 20 307 False
4 300 10 321 False
4 1000 1 321 False
Depth 300 and 1000 correspond to the default fixed mid/high retrieval budgets. The total reranker cap stays at 300. These are constructed cases, not representative production traffic or claims that high budget is generally worse.
How This Feature Would Help
Reservation would let a real reranker inspect some strong single-arm candidates it currently never sees. It could improve recall when the reranker recognizes them as useful.
It also displaces candidates that the existing prefilter would retain, so the net effect is unknown. Holding the candidate count fixed bounds the number of scored candidates, but does not guarantee equal token cost, model requests or latency.
The #3956 follow-up and #4008 are particularly relevant: after the admission fix in #3987, the reporter measured improved gold-target survival but no improvement in final recall, and isolated a separate post-rerank scoring issue. That was not a reservation experiment, but it demonstrates why admission metrics alone are insufficient.
Proposed Solution
An opt-in candidate-selection policy, initially disabled:
- Run retrieval, existing retrieval filters, per-source caps and fusion as today.
- If the merged pool exceeds the reranker cap
C, collect the topqcandidates from each active arm using the existingsource_ranks. Here an arm means semantic/BM25/graph/temporal after combining fact types. - Union those candidates by memory ID.
- Fill the remaining slots using the existing prefilter order, including configured strategy boosts when present.
- Pass at most
Ccandidates to the real reranker, preserving existing candidate metadata and scores.
For a uniform per-arm reservation and A active arms, a possible bound is q_eff = min(q, floor(C / A)). This guarantees that the reserved union cannot exceed C. Tiny caps, empty arms and overlapping candidates need explicitly defined behavior.
No particular reservation count is established. Values such as 5, 10 or 20 are experiment points. A fraction of the total cap, or unequal reservations by arm, are alternatives to discuss.
Scope: enable reservation only when a real cross-encoder or decision model will rerank the candidates. Leave pure RRF/passthrough and consolidation's interleave behavior unchanged. In pure RRF, keeping a low-ranked candidate in the pool does not ensure it reaches the final token-limited context.
Configuration could support a per-request override with a server/bank default, which would make paired trials easier than a server-wide setting. The existing strategy-boost setting is static and also controls the post-cross-encoder boost, so it is not an isolated admission-policy control.
If a store answers full_recall itself, the policy would need equivalent support or an explicit decline to the engine pipeline.
Alternatives Considered
- Fix the source of noisy candidates, especially label/high-fanout entity expansion in #6946. This could address the cause more directly.
- Adjust strategy boosts: useful for intentionally prioritizing an arm, but the current setting has no effect when empty and does not provide a per-arm floor.
- Per-source upper caps: already available; limit over-expansion without explicitly guaranteeing admission of each arm's head.
- Increase the reranker cap: may expose the useful candidate, at additional model cost.
- Interleave selection: could select the entire rerank pool in round-robin order, but changes more of the candidate set than a small reserved portion.
- Keep current behavior if measured single-arm losses are uncommon or reservation lowers final quality.
Priority
Nice to have — an RFC for evaluation and design discussion, not a request to change defaults without evidence.
Additional Context
Suggested evaluation:
- Start with frozen banks/queries with known relevant memories. Hold retrieval results, query timestamp, model configuration, candidate cap and output token budget fixed; initially set strategy boosts to empty.
- Measure how often relevant memories are retrieved by an arm but lost at the prefilter. If that rate is low, stop before adding policy complexity.
- Compare disabled reservation with a small sweep of counts or reserved fractions. Measure candidate survival and final Recall@K/nDCG, answer quality where applicable, model tokens/requests and latency.
- Cover semantic paraphrases, exact identifiers, graph/multi-hop and temporal questions; include different cap sizes and arm overlap. A wording-similarity task can detect harm without demonstrating graph-retrieval benefit.
- For a cross-encoder confirmed to score query-memory pairs independently, reuse scores across candidate-policy trials where valid. Decision-model ranking, pruning/dedup and any pool-dependent scoring require separate evaluation.
Questions for maintainers and users:
- Is source-head loss under the unboosted RRF prefilter frequent enough to justify a separate policy?
- Would a small reservation be preferable to reducing noisy graph/BM25 candidates?
- Should the reservation be a count, a fraction of
C, or different per arm? - Should experiments use per-request control with server/bank defaults?
- On failover to RRF, should recall re-trim the original fused pool using the existing policy? Keeping that pool would preserve the ability to do so.
- Are there existing datasets, traces or experiments that could validate this without starting a large evaluation from scratch?
Related: #1707, #1947, #3956, #3987, #4008, #1907, #6946.
- Dominant language
- Python
- Stars
- 45.2k
- Forks
- 5.9k
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vectorize-io/hindsight
-
core
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
vectorize-io/hindsight#7254 ·
-
Control Plane shows different calendar dates for the same occurrence in Constellation and TimelineOpencore
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
vectorize-io/hindsight#7240 · 1 comment ·
-
core
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
vectorize-io/hindsight#7233 ·
-
core
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
vectorize-io/hindsight#7231 ·
-
core
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
vectorize-io/hindsight#7228 · 1 comment ·
All issues in vectorize-io/hindsight
Similar issues
-
Test: to_hijri() accepts datetime.datetime and uses only the date partPossibly taken A pull request linked to this issue is open or already merged. Opengood first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
omarelshamy25x/shamy-hijri#63 · 3 comments ·
Maintainers usually reply within 1 day
-
polish
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
521xueweihan/HelloGitHub#4729 ·
-
[Bug]: Score parser reads parts of scientific notation as valid scoresPossibly taken @AshutoshSingh840 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
UKGovernmentBEIS/control-arena#992 ·
Maintainers usually reply within 3 days
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
mvalentsev/awesome-free-ai-coding#70 ·
Maintainers usually reply within 1 day