Shipping RAG to Production: The Engineering Playbook
A working RAG demo is easy. A RAG system that stays accurate, fast, and cheap under real traffic is a different problem. Here's the production playbook we use for retrieval pipelines that hold up.
Retrieval Is the Product
Most teams obsess over the model and ignore retrieval. In practice, retrieval quality determines 80% of answer quality. Garbage context in, confident nonsense out.
- Chunking: Semantic, section-aware chunks beat fixed 512-token windows every time
- Hybrid search: Combine dense vectors with BM25 keyword search, then rerank
- Reranking: A cross-encoder reranker on the top 50 candidates lifts accuracy more than swapping to a bigger LLM
- Metadata filters: Tenant, recency, and source-type filters prevent cross-context bleed
The Cost Curve Nobody Plans For
RAG costs scale with traffic in ways teams underestimate:
- Cache embeddings aggressively — re-embedding the same query is pure waste
- Cache full answers for high-frequency questions
- Route easy queries to a small model, hard ones to a frontier model
- Set hard token budgets per request and truncate context intelligently
Evaluation You Can Trust
You cannot improve what you do not measure. Build an eval set before you ship:
- Golden questions: 100-200 real questions with verified answers
- Retrieval metrics: Recall@k for whether the right chunk was retrieved at all
- Faithfulness: Does the answer stick to the retrieved context?
- Regression gates: Block deploys that drop accuracy below threshold
Guardrails Are Not Optional
- Detect and reject prompt-injection in retrieved documents
- Strip PII before it reaches the model
- Require source attribution on every answer
- Fall back to "I don't know" when confidence is low — silence beats a confident lie
The Takeaway
RAG in production is a retrieval, caching, and evaluation problem far more than a model problem. Get those three right and the system feels reliable. Skip them and you ship a demo that embarrasses you in week two.