RAG gets you most of the way. Engineering gets you the rest

By Manish Bafna, SVP of Engineering, Responsive

Getting a RAG application off the ground can happen surprisingly quickly. Load documents into a vector store, build a prompt template, test it against a few questions, and within days there can be a convincing prototype.

That first stage matters because it proves the concept. But it can also create the impression that most of the difficult work is already done. In reality, getting a RAG system roughly 80% of the way can be relatively straightforward. Moving from there to something consistently accurate and dependable in production is where the real engineering begins.

The gaps that emerge are often subtle. A security questionnaire might correctly answer, “Do you encrypt data at rest?” but struggle with “Describe how stored customer data is protected”, despite both questions seeking similar information. An RFP response might reference last year’s SOC 2 report instead of the latest one. A question about EU data residency could return information about the US region, while a product query might pull from an outdated sales deck rather than an approved content library.
Individually, these may look like minor errors. In an RFP or security review, however, one inaccurate answer can undermine trust and potentially affect a deal.

Reliability starts before the model
A RAG pipeline broadly involves four stages: chunking, retrieval, augmentation and generation. While the model receives much of the attention, the quality of the final response depends on what happens at every stage before it.

These stages are interconnected. Poorly chunked documents make it harder to retrieve the right information. Weak retrieval means irrelevant or outdated material reaches the prompt. Poor context then leaves even a capable model with little chance of producing the right answer.

This is why, when an output is wrong, the problem often starts earlier in the pipeline rather than with the model itself.

Chunking: getting the context right
A common starting point is splitting documents into fixed chunks, perhaps every 1,000 tokens. That may work for a prototype, but it does not always hold up in production.

Chunks that are too small can lose essential context. A paragraph referring to “this policy”, for instance, is not particularly useful if the information identifying the policy sits elsewhere. Make chunks too large, however, and the relevant answer can become buried within broader material.

There is no universal chunk size. The right approach depends on the documents, their structure and the questions users are likely to ask. Testing against real queries is therefore more valuable than relying on a standard token count.

Retrieval: finding the right source
Even perfectly divided documents are of little value if the system cannot retrieve the right information.
Vector search is effective at identifying semantically similar content, but can struggle with specific terms such as error codes or product identifiers. Production systems may therefore combine semantic and keyword search, supported by techniques including query expansion and reranking.

Permissions and recency also matter. If information is surfaced to someone who should not have access to it, the problem becomes one of security. Similarly, when several versions of the same document exist, the system needs to distinguish the current approved version from an outdated draft.

Many cases of “the AI got it wrong” begin here. If the correct information never reaches the model, the model cannot use it.

Augmentation: more is not always better
Retrieving relevant information is only part of the task. Simply passing the top five search results directly into a prompt can introduce duplication, conflicting information and outdated material.

The objective should be to give the model the right context, rather than the most context. This means removing duplicates, addressing conflicting information, prioritising authoritative sources and including only what is relevant to the question.

Longer context windows can make it tempting to send everything to the model. But excessive context can increase cost and latency while creating more opportunities for the model to pick up irrelevant details. More context does not automatically mean better context.

Generation: knowing when not to answer

The final generation stage still requires careful engineering. Answers need to remain grounded in source material, citations should be included where appropriate, and outputs may need validation before they are passed into other systems.

Perhaps the most important decision is what happens when there is not enough information to answer a question.

A confident but inaccurate response can damage trust far more than an honest acknowledgement that the required information could not be found. Citations help too, allowing users to validate an answer while helping engineering teams determine whether an error originated in retrieval or generation.

Model selection should also be deliberate. Straightforward lookups can often use faster, lower-cost models, while more capable models can be reserved for complex questions requiring reasoning across multiple sources.

The fix is rarely just a bigger model
When a RAG system produces poor answers, moving to a larger or newer model may seem like the obvious solution. Sometimes it helps, but often the bigger improvements are available elsewhere.

Documents may have been chunked incorrectly. Retrieval may have missed the relevant passage. An outdated source may have been prioritised, or the prompt may simply contain too much duplicated information. There is no single change that takes a RAG system from 80% to 100%. Production reliability comes from many smaller improvements across the pipeline, tested against the questions that real users actually ask.

A demo proves that RAG can work. Engineering the final 20% is what determines whether it can be trusted to work in production.

AILLMsRAG
Comments (0)
Add Comment