Hybrid retrieval combines lexical search, which excels at exact terms and rare identifiers, with vector search, which captures semantic similarity. Candidate rankings can be fused and optionally reranked before bounded context reaches a model. Retrieval quality, answer groundedness, and citation correctness are separate measurements; a fluent answer does not prove any of them.
Use a funnel:
Reciprocal rank fusion uses rank positions instead of raw scores:
The specific constant/candidate counts are evaluation parameters, not universal truth. The actual schema must ensure authorization in both branches.
Reranking may use a cross-encoder/model or deterministic features. Log candidate IDs and ranks, not sensitive content by default. Context construction should cap total tokens, avoid redundant adjacent chunks, preserve document/section structure, and separate instructions from retrieved text.
Hybrid retrieval turns PostgreSQL into a governed evidence service: relational policy and versions select eligible content, specialized indexes find candidates, evaluation chooses configuration, and citation lineage supports audit. The generator remains downstream and untrusted.
Build labeled queries covering exact IDs, paraphrases, negation, stale versions, and no-answer cases. Measure lexical, vector, fused, and reranked recall@k/precision or ranking metric. Validate every generated citation resolves to a retrieved, authorized chunk/version and actually supports the claim.
Create a 20-question dataset with exact codes and semantic paraphrases; compare three retrieval variants.
Acceptance criterion: the chosen variant wins on declared metrics within latency/cost budget and has zero unauthorized/stale citations.