>_DevAutomation Labs
Insights

What is RAG, and when is it worth it?

The pattern behind "an AI that knows our documents" — and the parts that decide whether it is useful or merely impressive.

DevAutomation Labs 6 min read

What is retrieval-augmented generation?

RAG is a pattern where the system searches your own documents first, then answers using only what it found, citing the source.

The model is not trained on your material and does not memorize it. At question time the system retrieves the handful of passages most likely to contain the answer, hands those to the model as context, and asks it to answer from them.

The practical consequence is that answers are checkable. Each response points back to the passage it came from, so someone can verify it rather than trust it. For contracts, policies and compliance material, that difference is the entire value.

Why not just use a general AI assistant?

Because a general assistant has never seen your documents, and will produce a confident answer anyway.

A general model does not know your contract terms, your internal policy, or last year's procedure. Asked regardless, it will still answer — fluently. RAG constrains the system to material you supplied and makes the source visible, so a wrong answer becomes obvious rather than plausible.

The retrieval is the hard part, not the model

If the right passage is not retrieved, no model can answer correctly. Most disappointing RAG systems are retrieval failures wearing a model's clothes.

Three things decide quality, and none of them is which model you picked:

  • How documents are split. Chop a table in half and neither half answers anything. Chunking has to respect the document's real structure.
  • Whether search finds the right thing. Semantic similarity alone misses exact identifiers — part numbers, clause references. Hybrid retrieval that combines keyword and semantic search is usually necessary, not a refinement.
  • What happens when nothing matches. The system must be able to say it does not know. A RAG system that always answers has simply moved where it makes things up.

Permissions are part of the design

Retrieval has to respect the access rules you already have, so people only see answers drawn from documents they were already allowed to read.

Document search is one of the easiest places to widen access by accident. If the index is built without permissions and filtered afterwards, you have built a leak with a filter in front of it. Permissions belong in the retrieval step.

When you do not need RAG

When the answer lives in a database rather than prose, or when a good search box would do.

If the question is "what is the balance on account 4417", that is a query, not a retrieval problem — and a direct lookup will be faster, cheaper and exactly right.

RAG earns its cost where answers are buried in prose across many documents and people currently find them by asking a colleague who happens to know. See RAG over documents.

Keep reading

Have a document set in mind?

Bring it to a free 30-minute call and we will tell you whether RAG is the right shape for it.