P

How the system answers a question

A question flows through retrieval (vector + keyword) then a single synthesis pass. Four AI components, all env-driven so swaps don't need a code change.

Query
user types a question
↓
EmbeddingEMBEDDING_MODEL
…
Vector leg of RRF
BM25
rank_bm25 · no LLM
Keyword leg of RRF
↓
RRF fusion
Reciprocal Rank Fusion
Merges the two rankings
↓
RerankerRERANKER_MODEL
…
Cross-encoder rescore → top-K
↓
+ Terminology
lexicon —
Consumer ↔ insurer wording bridges · edit on /lexicon
↓
SynthesisSYNTHESIS_MODEL
…
Reads chunks + terminology · writes grounded answer with citations
↓
Answer
structured response + cited excerpts
FAST_LLM_MODEL = … handles utility calls off the critical path: chunk enrichment, HyDE query expansion, CRAG retry decisions, self-query filter extraction, and the eval judge (judge runs at temp — for reproducibility; other utility calls keep the SDK default).
Why these four roles?

Embedding turns text into a semantic vector. Used both at ingest (per chunk) and at query time (per question). The vector store finds K nearest neighbours by cosine distance — that's the semantic-similarity leg.

BM25 is a keyword scoring algorithm (no model). Catches exact regulatory phrases and defined terms where semantic similarity misses. Combined with the vector results via Reciprocal Rank Fusion — parameter-free, outperforms linear score fusion on heterogeneous retrievers.

Reranker is a cross-encoder that re-scores the merged top candidates against the query directly — picks up nuance bi-encoder embeddings can't. Top-K after reranker reaches synthesis.

Synthesis is the "smart" LLM. Receives the chunks plus terminology bridges (from the lexicon) and writes a grounded structured answer with citations.

Fast LLM handles utility calls off the critical path: chunk enrichment at ingest, HyDE query expansion, CRAG retry decisions, self-query filter extraction, the eval judge.