[Feature]: evidence-aligned retrieval for fine-grained document QA
Issue Origin
Observed or reproduced in a real environment
Problem Statement
I would like to discuss how L2 document candidates should be scored when the text responsible for vector recall is not available to the reranker.
In the resource ingestion path used in this evaluation, OpenViking defaults to embedding the body content of an L2 text resource, while the scalar field named abstract is populated from the generated file summary (embedding_config.py,embedding_utils.py).
During thinking-mode recursive search, child candidates are recalled using the query vector and then reranked using only result["abstract"](hierarchical_retriever.py). When reranking succeeds, its scores replace the child vector scores rather than being blended with them. The MCP find and search tools then expose the URI, score, and abstract; the Agent sees the body only after selecting a URI and calling read(mcp_endpoint.py).
For exact-fact questions, this can cause a candidate recalled because of a detail in its body to be demoted when that detail is absent from its abstract:
exact fact occurs in the L2 body
-> body embedding recalls the L2 candidate
-> thinking-mode reranker scores its generated abstract
-> abstract does not contain the exact fact
-> candidate may be demoted before the Agent can read it
Using abstracts is a useful tradeoff for semantic navigation: they are shorter, cheaper to rerank, and often better suited to overview queries. The concern here is specifically whether abstract-only reranking should be the final relevance signal for L2 document candidates when the matching body evidence is not visible to the reranker.
Proposed Solution
My initial proposal is to add a parallel, fine-grained evidence retrieval path without replacing the existing hierarchy:
- Keep the current L0/L1/L2 hierarchy and abstract-based retrieval for broad, ambiguous, thematic, and navigation-oriented queries.
- For each readable L2 body, build a secondary index of structure-aware short chunks (approximately 400 tokens with a 60-token overlap).
- Embed each short chunk and rerank
section_path + chunk_text, so vector recall, reranking, and returned evidence are based on the same underlying text. - Return the verbatim chunk together with its source URI and available section, page, line, and character locators. The source L2 URI remains the canonical document that can be opened with
read. - Allow the Agent or retrieval policy to choose between an overview path and an evidence path, while retaining hierarchical fallback when fine-grained retrieval is insufficient.
Conceptually, the two paths would serve different retrieval intents:
overview/navigation query -> hierarchy + abstracts -> relevant document or section
exact-fact query -> short body chunks -> localized source evidence
This approach adds storage and indexing cost, and chunk records would need to follow the source resource's lifecycle, access control, updates, and deletion. However, it avoids sending an entire L2 body to the reranker and does not require removing L2 resources from the existing hierarchical index.
Alternatives Considered
- Rerank the complete L2 body. This exposes the matching evidence, but may be expensive and may exceed the reranker's input limit.
- Rerank
abstract + truncated body. This is simpler, but evidence outside the retained body window remains invisible. - Blend the body-vector score with the abstract rerank score. This can reduce demotion caused by missing summary details, but the two score distributions may require calibration.
- Exclude L2 candidates from reranking. This preserves their vector scores but loses the benefit of reranking at the evidence level.
Feature Area
Core (Client/Engine)
Use Case
To test whether shorter evidence units help, I built a local prototype that implements the parallel evidence path described above. I compared three retrieval configurations:
retrieveChunk: one-shot flat RAG over body chunks retrieved directly from the query.open-viking: an Agent using the original OpenViking MCP tools (find,search,read,list,grep, andglob).fine-grained-viking: an Agent using fine-grained evidence search together with the originalread,list,grep, andglobtools.
The first four datasets below are also covered by OpenViking's RAG benchmark (benchmark/RAG).
The last two are the 143-example QASPER and 196-example SyllabusQA multi-document, multi-hop QA sets released with
DeepRead (arXiv:2602.05014). DeepRead constructs these questions across multiple documents and manually filters the generated examples.
| Method | LoCoMo | FinanceBench | QASPER | SyllabusQA | QASPER (DeepRead) | SyllabusQA (DeepRead) |
|---|---|---|---|---|---|---|
retrieveChunk |
68.6 | 51.1 | 85.4 | 64.4 | 52.7 | 46.0 |
| Original OpenViking MCP tools | 57.9 | 71.5 | 77.3 | 73.6 | 53.0 | 59.9 |
fine-grained-viking |
71.5 | 75.0 | 84.6 | 78.2 | 58.8 | 63.0 |
Example API (Optional)
Additional Context
Related LoCoMo Benchmark Behavior
The documented LoCoMo full-evaluation configuration retrieves 50 candidates, reads the full content of every selected URI, reranks that full content (falling back to abstract only on read failure), keeps the top 10, and applies a 30,000-character answer-context budget
(run_eval.py,
retrieval path,
README.md).
This benchmark uses the retrieved full content for a second relevance ordering instead of relying on the initially returned abstract.
Related Issues
- #2739 addresses L2 reranker input length and adds truncation/fallback behavior.
- #3004 discusses excluding L2 candidates from reranking.
This proposal does not require excluding L2 from reranking and is not only about limiting reranker input length. It asks how L2 relevance should be scored when the evidence responsible for recall is unavailable to the reranker.
Questions for Maintainers
- Is body-based vector recall followed by abstract-only reranking for L2 resources an intentional design choice?
- Does a parallel short-chunk evidence index fit OpenViking's retrieval model and roadmap?
- If not, would the project prefer another approach, such as reranking L2 body windows or blending the body-vector and abstract-rerank scores?
Feature Area
Retrieval / Search
Version Note
The prototype was developed on a local branch based on OpenViking commit
fbea47e (June 16, 2026). I rechecked the relevant code path against main at
b1c029e (August 12, 2026) before writing this proposal.
Contribution
- [x] I am willing to contribute to implementing this feature
A few implementation-contract notes from having worked in this exact path recently, since any fix here has to survive both retrieval modes and the reranker's own prompt surface:
1. The mismatch is structural: recall feature ≠ rerank feature, with replacement semantics. Body embedding recalls the candidate; the thinking-mode reranker then scores only result["abstract"], and its score replaces the vector score (hierarchical_retriever.py). So the pipeline is a feature hand-off where the second stage systematically can't see what justified the first stage's recall. Any fix should either align the features (rerank on body-derived text) or change the semantics from replacement to a blend/fallback — replacing a score computed from different evidence is the core defect, and the exact-fact demotion is its sharpest symptom.
2. If rerank inputs move toward body content, budget for the injection surface. The reranker is an LLM; body text is untrusted exactly like the extraction/overview inputs being fenced in #4641/#4664. Whatever text feeds the rerank prompt should get the same DATA-only treatment, otherwise this fix quietly opens a new prompt-injection path that arrives precisely through the candidates an attacker wants promoted.
3. Keep QUICK and THINKING behavior consistent (or deliberately document the divergence). We just fixed a real bug where file-level vectors were ACL-gated in THINKING but not in QUICK (#4625) — the same class of drift will happen here if evidence alignment lands on one mode first. The acceptance test matrix should run the fixed corpus through both modes and assert the same candidate survives.
4. A cheap intermediate worth considering: when the reranker demotes a candidate below the vector score by more than a margin, keep the higher of the two (or a floor on the vector score) for candidates the vector path ranked highly. That preserves "recalled because of a body detail" without paying per-candidate body reads, and it's a one-place change in the replacement logic. It doesn't solve evidence alignment, but it removes the worst failure mode (exact fact recalled then buried) while the deeper options are designed.
On the deeper options: dual-channel vectors (body + abstract both embedded) doubles write cost but makes the hand-off coherent; chunk-level evidence is the principled endgame but is a storage-shape change. Which direction the maintainers prefer probably depends on how much rerank-time read latency (#1) they're willing to accept — that'd be my first question before committing to a design.
Independent measurement from a real corpus: the same mismatch is reproducible, and it is not limited to THINKING-mode search.
We run a self-hosted 0.5.0 server (single account, local vectordb, rerank.provider=openai) over a ~28-book resource library where each chapter is one L2 file. We reproduced the described behaviour and found the blast radius slightly wider than the original report suggests.
1) Mechanism in 0.5.0 (file:line)
openviking/retrieve/hierarchical_retriever.py:123-125—mode = RetrieverMode.THINKING if self._rerank_client else RetrieverMode.QUICK, thenuse_rerank = mode == THINKING and self._rerank_client is not None and not image_query. So once a reranker is configured the default path is THINKING, andPOST /api/v1/search/findreranks as well — the mismatch is not confined tosearch.:183—search_limit = limit * self.RERANK_CANDIDATE_MULTIPLIER(candidate pool = 2 × limit).:227-229— the rerank documents are literally[str(candidate.get("abstract", "")) for candidate in candidates].:224-235— rerank scores replace the vector scores (_final_score); the threshold is applied after the replacement.- Log pairing on our instance: inside one 25-minute window, 287
route=/api/v1/search/findrequests, allstatus=200, alongside 290[HierarchicalRetriever] Rerank enabled (provider=openai)lines. (The only non-200 in that window is a404fromov attrs geton a card id that does not exist — not a search call, listed here so the window is not misread as 100% clean.)
2) The premise holds on our corpus: recalled by body, scored by a text that cannot contain the answer
8 questions whose answer is a specific quantity that exists only in the chapter body — e.g. “how many years do both prisoners get if both confess” → 8 years; “what did the assembly line cut the pen cost to” → 50 yuan:
- fact present in the L2 body: 8/8
- fact present in the returned
abstract: 0/8
3) Single-variable measurement of how much survives
Same 8 questions, same -n 8, same scope; the only change is the tag filter:
| configuration | hits@8 | ranks |
|---|---|---|
one book subtree + book=<id> tag filter |
8/8 | 1,1,1,1,5,1,1,5 |
whole viking://resources without the tag filter |
2/8 | –,3,–,–,–,1,–,– |
whole viking://resources without tag filter, -n 50 (contrast) |
6/8 | 36,3,11,14,–,1,15,– |
Window sweep with the tag filter in place: -n 1/2/3 → 6/8 (both rank-5 candidates drop out); -n 5/10 → 8/8.
Two observations for the design discussion:
- What protects us here is the tag filter, not the subtree scope: widening the scope from one book to the entire resource tree changes nothing (8/8, identical ranks) as long as the filter is present.
- The symptom is therefore not “exact-fact queries fail”; it is “a candidate recalled by a body detail moves down ~4 positions”, which turns into a hard miss as soon as the consumer uses a narrow window (1–3) or drops the narrowing filter.
4) Suggested acceptance test
For any corpus of L2 documents, build questions whose answer appears in the body but not in the generated summary, then assert the target document survives at a fixed -n, and that this holds with and without the narrowing filter. Our set is 8 questions on one book; the two contrast rows above are the red/green pair. If the cheap intermediate from @now-ing's comment (keep the higher of vector rerank score, or floor the vector score) lands first, I would expect the rank-5 rows to collapse to rank 1–2 and the unfiltered row to stop losing 6 of 8.
We can re-run exactly this against a build containing a candidate fix, and post the before/after ranks.