Balancing 70/30 Hybrid Retrieval and the Graph Anchor

Vector, keyword, parent-child context, and verified graph paths are combined in layers so that similar content is never mistaken for proof of a call.

On this page · 12 sections

An engineering query contains two languages at once. A person asks, “Why does it still read the old value after a refresh?” while the code says refreshProjection, readMaterializedView, and a GraphQL field. Dense retrieval alone (that is, recall by vector semantic similarity) tends to miss exact symbols; keyword search alone cannot bridge the gap between a business description written in Chinese and an implementation written in English.

The first retrieval round in System RAG shadow splits vector and keyword into two lanes and merges them with weighted reciprocal rank fusion (RRF, that is, a weighted merge that uses only the rank within each lane). The fused result supplies the graph anchor, that is, the starting point for graph expansion, and Neo4j is responsible only for adding relationship paths that have evidence.

The Short Version

  • 70/30 fuses ranks, not raw scores: weighted RRF cares only about the order within each lane.
  • Exact identifiers belong to the keyword lane, which still accounts for only 30%. An exact candidate outside the dense top-K gets its real cosine score first and then enters RRF.
  • The child is the unit of precise retrieval; the parent serves only as context and gains no extra rank. The graph expands only from the highest-ranked hit that has graph_ids.
  • 70/30 is the versioned retrieval contract of the current System Shadow, not a universal conclusion for every path, and the weights have to be evaluated against an enterprise query set.

Knowledge Map for This Article

Knowledge map of hybrid retrieval: the query splits into a dense lane and an FTS + exact identifier lane, fused by exact candidate completion and weighted RRF 70/30, then passes through temporal rerank, parent context, top-hit graph_ids, and the Neo4j verified path into the Evidence Bundle; open the full-size SVG

The concepts to understand include dense/sparse retrieval, RRF, exact candidate completion, parent/child hydration, temporal reranking, graph anchoring, and retrieval evaluation.

70/30 Fuses Ranks, Not Raw Scores

Cosine similarity, BM25/FTS rank, and an exact-match score do not live on the same scale. Computing this directly:

0.7 * cosine + 0.3 * bm25

has no stable meaning, because the numeric range of BM25 shifts with the corpus, the analyzer, and the query. System Shadow uses:

score(d) = 0.70 / (k + dense_rank(d))
         + 0.30 / (k + keyword_rank(d))

The current index manifest requires k >= 1, and the configured value is 140. RRF cares only about the order within each lane, which reduces the problem of incomparable scoring systems.

70/30 is the versioned retrieval contract of the current System Shadow, not a universal conclusion for every path. The default external /v1/answer still keeps its own legacy/hybrid switch and exact-quota logic. Until cutover, the shadow formula cannot be described as something every live query already uses.

The weights also have to be evaluated against an enterprise query set rather than fixed forever because the numbers look tidy.

Exact Identifiers Belong to the Keyword Lane, Not a Third Weight

ISSUE-1234, RebuildProjectionJob, and a complete file path carry more identity value than an ordinary token. The system keyword index checks exact aliases first and then FTS; together they form the keyword rank, which still accounts for only 30%.

One difficulty is that an exact candidate may not be in the dense top-K. Inserting it straight into the final result would bypass 70/30. Giving it a fabricated dense rank would overstate its semantic relevance.

The current implementation asks Qdrant, by point ID, for the real cosine score of those candidates, places them back into the dense ordering, and then runs RRF. This is exact candidate completion: it guarantees the exact object a place in the race without changing the rules of the race.

Parent/Child Resolves the Conflict Between “Precise Hit” and “Readable Context”

A small chunk is good for hitting a method, a heading, or a table row, but handing it directly to the answering model often leaves it short of context. A large chunk has complete context, but may average several topics into one vector.

The current approach is:

  1. The child is the unit of precise retrieval.
  2. The payload retains parent_id.
  3. After a hit, the parent text is loaded from the keyword DB.
  4. The parent serves only as context and gains no extra rank from hydration.
  5. The external answer path can additionally include the preceding and following parent neighbors, marked as context_only.

This structure costs one more read than a fixed top-K, but avoids “double scoring because the context was widened.”

Parent/child also cannot repair bad chunking: if the parser has already dropped a table header or a code symbol, going back to the parent still cannot restore the evidence. It therefore depends on the typed IR from the earlier chapter.

Temporal Rerank: Relevant Does Not Mean Current

After RRF, System Shadow applies a source-specific temporal rerank:

  • Confluence recomputes freshness at query time from the effective updated timestamp, with a multiplier of 0.5 + 0.5 * freshness.
  • Code relies on currentness_valid: current uses 1.0, non-current uses 0.25.
  • Other sources do not get the same kind of time decay by default.

The time signal only adjusts ranking; it does not enter chunk or embedding identity. An old page can still serve as historical evidence, but it cannot easily outrank current code. A code hit of unknown currentness can help with location, but cannot become a high-confidence implementation conclusion.

Which Anchor Graph Expansion Starts From

Vector and keyword retrieval return related entities; a Neo4j query returns the relationships between entities. If the graph is expanded from every top-K candidate at once, the system can easily borrow a real path from a secondary candidate and splice it onto the primary answer.

The System Shadow controller uses only the highest-ranked hit that has graph_ids as the graph root, and takes only a small number of relevant graph IDs. The graph query then restricts the relation allowlist, direction, hops, and evidence. An incoming query (for example, “who calls it?”) uses the reverse pattern; other queries default to outgoing.

The default external API is a different, more general query runtime. After rewrite, a first-round graph search at depth 1 runs in parallel with vector/keyword; the controller then decides, based on complexity, whether to run the single permitted second round and a depth 1–3 expansion.

The System Shadow search_verified_paths currently allows at most 4 hops. Both paths emphasize bounded search, but their specific limits differ.

Why More Is Not Better for Context Compression

When there are many candidates, the external runtime can enable compression, keeping only the vector/keyword candidates whose query similarity exceeds a configured threshold. Graph evidence is protected by the graph-priority policy and keeps its verified/candidate labels.

More candidates raise the recall ceiling, but they also increase rerank latency, prompt length, and the chance of splicing in unrelated evidence. Research along the lines of “Lost in the Middle” also shows that a long context does not guarantee the model makes effective use of what sits in the middle. The current default rerank therefore first uses local rules to cut the set down to a few dozen, then runs a single Codex rerank that keeps at most a dozen or so. Deep batch rerank is reserved for targeted investigations.

How to Evaluate, Rather Than Admire One Good-Looking Answer

Hybrid retrieval should at least group its queries. Each group has its own metrics and its own typical failure:

Query category Primary metrics Common failure
Exact symbol/issue key MRR, top-1 exact, repo/commit match Dense ranks a similar class name above the real identifier
Chinese business description → English code Recall@K, verified anchor coverage Keyword has no cross-language ability
Cross-repository call chain Verified path coverage, false path rate Multiple anchors assemble a true but off-topic path
Historical design query Citation coverage, freshness calibration Old documents are uniformly discarded or uniformly pinned to the top
Unanswerable question Insufficient precision Retrieval can always find text that “looks like an answer”

Recall, rerank, and answer faithfulness have to be measured separately. A correct final answer does not mean the retriever did well, and a retriever that found the right page does not mean the generator cited it completely.

Failure Modes and Trade-offs

In each row, read the failure mode first, then the current strategy and what it costs.

Failure mode Current strategy Trade-off
Dense and FTS scores are incomparable Weighted RRF fuses by rank Loses the gap information between raw scores
Exact hit is not in the dense top-K Fetch its real dense score, then add it One more Qdrant point scoring call
Child is too short Hydrate parent/neighbor context More reads, but no extra scoring
Too many top-K anchors Expand the graph only from the highest-ranked entity Higher precision; may miss a real secondary branch
Graph depth is too deep External 1–3; shadow bounded hops Sacrifices some long-chain recall to control combinatorial explosion
Interference from old documents Source-specific temporal rerank Freshness parameters need offline calibration
Too many candidates Compression + prefilter + single rerank An overly strict threshold may drop weak signals

Verifiable Project Evidence

  • src/mt_rag/retrieval/ranking.py: HybridWeights, weighted RRF, and temporal rerank.
  • src/mt_rag/retrieval/system_index.py: exact dense completion, the keyword DB, parent context, and the system hybrid contract.
  • src/mt_rag/retrieval/hybrid.py: exact terms, lexical tokens, and the external hybrid/quota helpers.
  • src/mt_rag/query/controller.py: the highest-ranked hit anchor and the two-round limit.
  • src/mt_rag/system_graph/query.py: verified paths, direction, and the hop bound.
  • config/rag-runtime.json: the shadow 70/30 split, RRF K, compression, and external controller depth.
  • docs/02-runbooks/local-llm-service.md: external parallel search, context-only neighbors, and the rerank strategy.

References

The goal of hybrid retrieval is not to let every lane “win a little.” It is to let natural language, exact identity, and relationship evidence each do what they are good at, and to keep an explainable boundary at every point of fusion.

Related notes

  • 9 min readWriting

    Why Vector, Keyword, and Neo4j Use Different Stores

    Semantic similarity, exact identifiers, and relationship traversal are three different query problems; forcing them into one database sacrifices correctness and explainability.

  • 10 min readWriting

    Where the Cost of a Model Call Comes From, and Where It Can Go Wrong

    Token, Context, Prefill, Decode, and caching determine an Agent’s cost and latency; hallucination and Prompt Injection determine the floor of its risk. Without understanding these, none of the later architectural trade-offs has a basis.

Working on something similar?

I'm always happy to compare notes on distributed systems, delivery, and applied AI.

[email protected]