Teams moving Retrieval-Augmented Generation (RAG) from a demo to a production service hit a handful of decisions that separate a useful assistant from a noisy one. Five design choices—chunking, embedding model, vector store, hybrid search, and evaluation—control the precision, recall, and latency real users experience.
Why the jump from prototype to production matters
Most tutorials get a RAG pipeline running in a few dozen lines of code, then stop short of the engineering rigor needed for live traffic.
1. Chunking strategy – the first quality gate
Chunk size matters most. Large chunks drown the signal with unrelated text; tiny chunks strip away the surrounding context the model needs to generate coherent answers. Fixed-size splitting ignores the natural structure of the source material.
Practical rule-of-thumb
- Split on logical boundaries: headers in documents, paragraph breaks in articles, function definitions in code.
- Keep chunks small enough for precise retrieval but retain the larger parent section for the LLM’s generation step. This “parent-child” pattern lets the retriever surface a pinpointed snippet while the generator sees enough context to stay factual.
2. Embedding models – how similarity is judged
The embedding model turns text into vectors that the similarity search engine compares. A strong general-purpose model such as OpenAI’s text-embedding-3-large gives a solid baseline for most domains. If the corpus lives in a highly specialized field—legal opinions, medical records, technical specifications—test a domain-specific model, but only after you measure a tangible lift on your own data.
When to switch
- Switch only if you see a measurable gain in the relevance scores that matter for your application (e.g., higher context precision).
3. Vector database – scaling the store
Pick a vector store that fits your existing infrastructure and the expected number of vectors.
- pgvector runs inside PostgreSQL and handles up to about a million vectors comfortably. It’s ideal for teams already operating a relational database and needing a low-maintenance solution.
- Qdrant shines in the 1 M–100 M range, delivering higher throughput and lower latency for larger corpora.
- Pinecone provides a fully managed cloud service, removing the operational burden of self-hosting.
4. Hybrid search and reranking – balancing meaning and exactness
Pure vector search excels at semantic similarity but can miss exact keyword matches users expect. Hybrid search layers a traditional BM25 keyword index on top of the vector index, then fuses the two result lists. Reciprocal Rank Fusion (RRF) assigns each candidate a score based on its rank in both lists and combines them, boosting items that appear high in either.
Reranking adds a final precision filter. After hybrid retrieval, feed the top-N (commonly 50) candidates to a cross-encoder—a model that scores a query-document pair jointly. The cross-encoder’s scores replace the original similarity numbers, letting you pick the most relevant chunk before passing it to the LLM. This extra step often yields a noticeable jump in answer quality, especially for long or noisy corpora.
5. Evaluation and abstention – measuring what matters
You cannot improve a system you do not measure. The RAGAS framework proposes four metrics that together capture the health of a RAG pipeline:
- Context Precision – proportion of retrieved chunks that actually contain the answer.
- Context Recall – share of all relevant chunks that were retrieved.
- Faithfulness – degree to which the generated answer stays within the retrieved context, avoiding hallucinations.
- Answer Relevance – how well the final answer satisfies the original query.
Track these metrics on a rolling test set that mirrors production traffic.
A final, often-overlooked safeguard is abstention. Instead of forcing the model to answer with low confidence, set a threshold on the faithfulness or relevance score that triggers a “I don’t know” response. Users prefer a clear admission of uncertainty to a confident but wrong answer, and the fallback reduces downstream support costs.
Treat each of these five areas as a decision point rather than a set-and-forget configuration, and you can move RAG from a flashy demo to a dependable production service. The payoff: a system that answers quickly, stays on topic, and knows when to stay silent.
