The short version
Test chunking on your documents and queries. Semantic chunking can help, but fixed-size methods can also perform well.
- Compare hybrid search with keyword and semantic search separately, especially for technical names and error codes
- Measure retrieval before generation - Track precision and recall on retrieved documents separately from response quality to identify where systems actually break
Building a RAG system? Starting with the language model is the wrong place.
For an answer grounded in your documents, the model needs the right evidence. I keep watching teams spend weeks tweaking prompts and generation parameters while their retrieval layer is actively broken. It’s frustrating.
Your RAG system is a retrieval system first. Generation is secondary. Understanding the broader LLMOps discipline helps you plan for what comes after the first demo.
Mid-2026 update: context windows grew enough to change when you need RAG at all. Anthropic’s larger current models, Sonnet 5 and Opus 5 up through Fable 5, all carry 1M-token context windows with no pricing premium beyond 200k tokens. For a small, stable corpus you can now skip retrieval and load the whole thing into context. The argument below survives at production scale: you pay for every token you send, access control lives at the retrieval layer, and handing the model the right 2,000 tokens beats making it wade through a million.
(November 2026 clarification: Anthropic’s March announcement covered Opus 4.6 and Sonnet 4.6, not the later model names above. Check the selected model’s context limit and pricing, including caching. Enforce permissions before any content reaches the model. Compare full-context prompting with retrieval on answer quality, latency and cost.)
Why retrieval is where RAG breaks
One mistake to avoid: focusing on the language model instead of document quality. Documents get chunked without thinking about semantic boundaries, embedded with whatever model is popular this week, then thrown in a vector database. The assumption is that similarity search will figure out the rest.
This diagram shows one possible pipeline. Compare its semantic chunking and reranking steps with simpler alternatives.
Similarity search alone does not guarantee useful evidence.
A demo can hide retrieval problems when it uses clean, carefully formatted test documents. Production data can include PDFs with tables, legal documents with nested clauses, code with inconsistent formatting, and support tickets written in a hurry.
Simple fixed-size chunking applied to this reality can produce nonsensical pieces. A chunk that starts mid-sentence and ends mid-thought. A table split across three chunks with no context. Critical information separated from the question it was meant to answer.
An embedding model cannot restore evidence that preprocessing discarded. Keep enough context for the question you’re trying to answer.
Chunking: the decision that shapes everything
Compare chunking methods on your own queries. Qu, Tu, and Bao’s study found that semantic chunking helped on some constructed datasets, but did not consistently outperform fixed-size methods across retrieval and answer-generation tasks. Document structure is worth testing, not a guarantee of higher accuracy.
Semantic chunking adds processing work. Keep it only if the improvement on your evaluation set justifies that cost.
Start with roughly 250 tokens per chunk. Count tokens with the tokenizer your system uses. Not because this is optimal, but because it’s a sensible baseline for testing. Too small and you lose context. Too large and you retrieve irrelevant information alongside the parts you actually need. I said sensible baseline above. It is more like an educated guess.
More important than chunk size: semantic completeness. A chunk should contain a complete thought. Break technical documentation at section boundaries. Respect clause structure in legal documents. Keep questions and answers together in support tickets. I think most teams underestimate how much this first architectural choice constrains everything downstream.
Test tables, clauses, and question-answer pairs before indexing the whole collection. Check whether the retrieved chunk contains enough context to answer correctly.
Anthropic’s September 2024 experiment reported relative reductions in top-20 retrieval failures of 35% with contextual embeddings, 49% with contextual BM25 added, and 67% with reranking added. Those test results are not production guarantees.
Another option is late chunking: a long-context embedding model processes a document, or the largest part that fits, before pooling token representations into chunks. That preserves surrounding context without a generative LLM call for each chunk, but still has model and compute limits.
Hybrid search and why pure semantic falls short
Semantic search can miss exact terminology. A query about “BM25 algorithm” might retrieve general ranking material; a query for an error code might return broad troubleshooting. Test these cases explicitly, including with different embedding models.
Hybrid search combines keyword and semantic signals. For example, Weaviate combines BM25F with vector search. The keyword component weights matching terms, while the vector component finds related meaning. Tokenization, filters, and result fusion still affect what reaches the model.
Include code snippets, error messages, product names, and acronyms in that comparison. Those queries can reveal missing exact matches.
One implementation runs keyword and vector searches and combines their ranked results. Pinecone documents reciprocal rank fusion as one option. Compare the combined result with each search alone; adding a second signal can also add irrelevant matches.
Weaviate and Pinecone both support hybrid retrieval. Their performance claims need a workload attached. Pinecone reported one customer deployment sustaining 600 queries per second across 135 million vectors, with 45ms median latency. AWS tested pgvector 0.8.0 on Aurora using 10 million synthetic product records. It reported up to 9.4 times faster queries than its 0.7.4 baseline and up to 100 times better result completeness for selective filters. Completeness here means returning the requested results, not making them 100 times more relevant. Neither test guarantees the same result on your data.
When you want to take this further, Blue Sheen helps firms work through this.
Test a reranker after initial retrieval. Cross-encoders score query-document pairs; late-interaction methods such as Omar Khattab and Matei Zaharia’s ColBERT offer another approach. Measure any quality gain against added computation. Milvus also offers Boost Ranker from version 2.6.2 and Decay Ranker in 2.6.x. These adjust scores using filters or numeric fields, such as recency; they serve a different purpose from a semantic reranking model.
Measuring what’s actually working
The hardest part of building a RAG system isn’t the code. It’s knowing whether it works. RAG evaluation has several dimensions because you’re measuring two distinct things: retrieval quality and generation quality.
Separate them.
For retrieval, measure precision and recall: how many retrieved chunks were relevant, and how many known relevant chunks you found. Ragas offers context precision, context recall, faithfulness, and response relevancy metrics. Its original paper described reference-free evaluation, but current metrics have different requirements: context recall needs a reference. Use the scores to investigate failures, then inspect the underlying examples.
Start with a curated test set. Take 50-100 real queries. Manually identify which documents should be retrieved for each. That’s your ground truth.
Track metrics that matter:
- Precision at k: the fraction of the top k results judged relevant
- Recall: the fraction of known relevant documents retrieved
- Mean reciprocal rank: the average of one divided by the first relevant result’s rank
- NDCG: graded relevance discounted by rank and normalized against an ideal ranking
Don’t just measure final responses. A RAG system can give good answers despite bad retrieval if it gets lucky, or give bad answers despite perfect retrieval if generation fails. You need to know which component is breaking and why.
For generation, check faithfulness: does the retrieved material support the answer? Check relevance too: does it address the question? Neither guarantees that the source itself is correct. Combine automated checks with user feedback and reviewed examples.
Building for production from day one
What production-ready architecture actually looks like.
Track document versions and process changes incrementally where possible. A changed section may require regenerating neighboring chunks or document-level context. Handle deletions and permission changes too, so old material does not remain searchable.
Track retrieval latency, embedding time, database query performance, and quality on reviewed queries. Set alerts against your agreed thresholds and inspect examples. Online precision needs relevance judgments; latency alone cannot tell you whether an answer is useful.
Define what happens when the knowledge base lacks an answer. Test refusal, clarification, or human escalation. A high similarity score alone is not proof that the retrieved text answers the question.
OWASP’s 2025 LLM08 category covers vector and embedding risks, including data leaks, inversion, and poisoning. In PoisonedRAG, researchers inserted five crafted texts per target question and steered answers in tested systems using three question-answering datasets. This is evidence of a specific attack path, not a success rate for every deployment. Enforce permissions before retrieval results reach the model, verify document provenance, and test RAG security beyond the retrieval layer.
Compare embedding quality, latency, and total cost on your workload, including hosting for open models. In its January 2026 evaluation, Voyage reported that voyage-4-large beat Gemini Embedding 001, Cohere Embed v4, and OpenAI v3 Large by 3.87%, 8.20%, and 14.05%, respectively, on average across 29 RTEB datasets using nDCG at 10. That is a vendor-reported benchmark with named comparators, not a promise for your corpus or a current ranking of every embedding model.
Vector database choice affects operations and cost. Pinecone and Weaviate offer managed services; Weaviate also has an open-source option. Qdrant reported renewing its SOC 2 Type II audit in June 2025; check the current report and scope during procurement. Chroma supports local, single-node, and distributed deployments. Zilliz announced a tiered-storage rate reduction from $0.30 to $0.04 per GB per month in 2025, about 87%. That was a storage price change, not an 87% reduction in the whole bill. Benchmark your data and check current pricing before choosing.
Treat retrieval as something to test throughout the life of the system. Keep checking whether the right evidence reaches the model and whether the answer uses it correctly.



