Enterprise RAG succeeds or fails on what it retrieves, not just which LLM it uses. Vector search can miss exact employee IDs, contract numbers, and terminology. Keyword search can miss semantically related documents. Hybrid retrieval combines their strengths.
Reference Architecture
The system has two pipelines: offline indexing prepares documents, while the runtime query pipeline retrieves evidence and generates answers. Security and governance support both pipelines.
1. Indexing: The Foundation of Retrieval Quality
Chunking and metadata design are as important as embedding selection. Split documents by headings and sections to preserve context. Index department, document type, creation date, and access permissions with each chunk. Store the same chunks in both a vector database and a BM25 keyword index.
2. Queries: Hybrid Search and Re-ranking
Run keyword and vector retrieval in parallel, merge their candidates, and re-rank the results. Vector similarity and BM25 scores use different scales, so a simple weighted sum can be unreliable.
Reciprocal Rank Fusion
RRF combines rankings rather than raw scores, reducing calibration work. A cross-encoder re-ranker then evaluates the merged candidates to improve the relevance of the final context.
Practical tip: Start with the top three to five relevant results. Extra context can introduce noise and increase hallucinations and latency; prioritize precise evidence over volume.
3. Generation That Reduces Hallucinations
- Require source document IDs with answers so users can verify them.
- Instruct the model to say evidence is unavailable when retrieval is insufficient.
- Map answer statements to cited chunks and retain the mapping in audit logs.
4. Security and Governance
Filter retrieval candidates using the requesting user's access permissions. Mask personally identifiable information before indexing and log queries and responses for auditing. These controls belong in the initial design.
Hybrid retrieval, re-ranking, source attribution, and access filtering form the foundation for moving an internal RAG system from demonstration to production.