Deep dive

Retrieval ranking

Routing, hybrid candidate generation, reciprocal rank fusion, and citation validation — the exact mechanics behind an answer.

Vector weight

0.65

Lexical weight

0.35

Final chunks

Top 10 + neighbors

1 · Query routing

A fast LLM call rewrites the question into a standalone query (resolving references from recent history) and selects a retrieval mode. If the call fails, a heuristic fallback inspects the wording for summary-style intent.

chunks

Page-specific, quote-seeking, or clause-seeking questions. Routed to hybrid chunk retrieval.

summaries

Document-wide synthesis (overviews, key findings). Routed to page and document summaries.

2 · Candidate generation

In chunks mode, two retrievers run against the document and their results are unioned into a candidate set.

  • Vector search over chunk embeddings — top 24, filtered to the document.
  • Convex full-text search over chunk text using extracted keyword terms — top 24.
  • Results are merged by chunk id into a single candidate pool.
Rendering diagram…
Routing and hybrid candidate generation feeding rank fusion.

3 · Reciprocal rank fusion

Candidates are scored by their rank in each list using reciprocal rank fusion, with the vector list weighted more heavily. A small bonus rewards chunks that literally contain query terms.

Scoring (per candidate)
score(chunk) =
    0.65 / (60 + vectorRank)     // semantic
  + 0.35 / (60 + lexicalRank)    // keyword
  + 0.10 * keywordOverlapRatio   // literal-term bonus

// k = 60, then keep the top 10 chunks
// Neighbor chunks around the strongest hits are added as extra context
Vector (semantic)0.65
Lexical (keyword)0.35
Literal bonus0.10

Relative contribution of each retriever to the fused score (k = 60).

4 · Citation validation

The top ten chunks are selected by score, nearby chunks around the strongest hits are added as extra context, and the final labeled sources are ordered by document position. The model returns a structured answer with quotes, and every quote is checked before it is shown.

  1. 01Quote matchEach quote is matched against its cited chunk exactly first, then with normalized markdown, punctuation, and high-threshold fuzzy matching.
  2. 02Resolve the pageThe citing page is derived from the chunk's page spans at the quote's offset.
  3. 03Snippet and capA ±100-character snippet is built, duplicates are removed, and at most four citations are kept.

Streaming, but verified

The answer streams token-by-token as the structured JSON arrives, while citations are validated from the complete response before being attached to the saved message.

Keyword extraction

The lexical query is built from extracted terms: the question is lowercased, tokenized, stripped of stop words and very short tokens, and capped at twelve terms. This keeps full-text search focused on meaningful, exact terms.