1. The Hybrid Retrieval Equation
We combine PostgreSQL `tsvector` BM25 full-text search with pgvector cosine embeddings. Using Reciprocal Rank Fusion (RRF), documents matching both exact keywords and conceptual semantics score significantly higher than either search mode could deliver independently.
2. The Reranking Filter Stage
Passing the top 20 candidate chunks through a compact cross-encoder model (such as BGE-Reranker-Large) scores the precise token-level interaction between the user question and document passage. This cuts prompt token costs by 65% while eliminating context poisoning.
- Vector embeddings alone cannot reliably resolve exact alphanumeric part numbers or serial codes.
- Rerankers are the single highest ROI addition to any production RAG retrieval pipeline.
- Force deterministic JSON outputs using constrained decoding schema grammars.