Automathing Logo
Back to glossary

Applied AI / Glossary

Retrieval-Augmented Generation (RAG)

A method that retrieves your own documents and gives them to a model before it answers.

Definition

RAG connects a language model to a body of your content. When a question arrives, the system searches that content, pulls the passages most likely to matter, and puts them in front of the model so the answer is grounded in your material rather than in training data.

The problem RAG solves

A language model knows a great deal about the world and nothing about you. Ask it your refund policy and it will produce something that sounds like a refund policy, because that is what it was trained to do.

RAG closes that gap without retraining anything. The sequence is short: a question arrives, the system searches your content for the passages most likely to answer it, those passages are inserted into the prompt, and the model answers using them. The model's job shifts from recalling to reading, a task it is far better at.

This is why RAG became the default architecture for internal knowledge assistants, support tools, and any application where the answer must come from your material and be traceable back to it.

RAG vs. fine-tuning

The most common architecture question, usually answered wrongly on the first attempt.

RAGFine-tuning
Teaches the modelFacts, at answer timeStyle, format, behaviour
Updating contentChange the documentRetrain
Can cite sourcesYesNo
Handles fresh dataImmediatelyOnly at next training run
Access controlEnforceable per userBaked in for everyone
Cost to startLowHigher

The rule of thumb: RAG for what the model should know, fine-tuning for how it should behave. Teams reach for fine-tuning to fix factual errors and are surprised when it does not work, because the model becomes more fluent about your domain without becoming more correct. If a document changed this morning and the answer must reflect that, only retrieval can do it.

Why RAG systems disappoint, and what actually fixes them

Most disappointing RAG deployments are not model problems. They are retrieval problems: the model answered badly because it was handed the wrong passages.

Chunking that breaks meaning. Documents get split into pieces before indexing. Split badly, whether mid-table, mid-clause, or separating a heading from what it governs, and no search can recover the meaning. This is the single most common cause of poor results and the least discussed.

Search that matches words instead of intent. Pure keyword search misses paraphrases; pure vector search misses exact identifiers like part numbers and policy codes. Systems that work well usually combine both and re-rank the results.

A corpus nobody curated. Three versions of the same policy, two of them obsolete, all indexed. The retrieval works perfectly and returns the wrong one. RAG will faithfully surface your content problems.

No evaluation. Without a set of real questions with known-good answers, "it seems better" is the only available measure. Build the evaluation set before tuning anything, or you are guessing.

Ignoring permissions. If retrieval does not filter by who is asking, you have built a system that will cheerfully quote the salary review to whoever asks nicely.

How Automathing approaches it

We treat retrieval quality as the main engineering problem and the model as the easy part. That means investing in document structure and chunking before anything else, combining keyword and semantic search rather than betting on one, enforcing permissions at retrieval time rather than in the prompt, and building an evaluation set of real questions with known answers before tuning begins. When a RAG project underperforms, we look at what came back from the search before we look at the model.

What RAG needs from your content

RAG works well when the answer exists in writing somewhere. It works poorly when the real answer lives in someone's head, in a decision nobody documented, or in a spreadsheet whose meaning depends on knowing which column was abandoned in 2023.

Practically, a corpus is ready when documents have real structure, meaning headings, sections, and consistent formatting rather than scanned images of text; when there is one current version of each thing and the obsolete ones are out; when the terminology is consistent enough that the same concept is not called three names; and when access rules are explicit enough to enforce at retrieval time.

Getting there is often the bulk of the project, and it is worth doing regardless of whether AI is involved.

Frequently asked questions

What does RAG stand for?

Retrieval-Augmented Generation. Retrieval means searching your content, augmented means the results are added to the prompt, and generation is the model writing the answer from that material.

Is RAG better than fine-tuning?

They solve different problems, so the comparison only makes sense per use case. RAG is right when answers must come from current, specific, changeable information, which describes most business applications. Fine-tuning is right when you need consistent tone, format, or task behaviour at volume. Systems that need both use both, and RAG is almost always the one to build first.

Can RAG guarantee the model will not make things up?

It reduces the risk substantially but does not eliminate it. The model can still misread a passage, blend two sources, or fill a gap when retrieval returned nothing useful. Requiring citations, showing users the source passages, and having the system say "I don't know" when retrieval comes back empty all help, and measuring the residual rate on real questions tells you what you are living with.

How long does it take to build a RAG system?

A working prototype over a clean, well-structured document set is a matter of weeks. What extends it is the content: permissions to untangle, formats to normalize, duplicates to retire, and scanned documents needing OCR. When RAG projects run long, the cause is almost always the corpus rather than the AI.

Does RAG work with our existing document systems?

Generally yes. SharePoint, Google Drive, Confluence, a file share, or a database can all be indexed. The practical questions are whether the system can read the formats you actually store, whether it can respect the permissions those systems enforce, and how it learns that a document changed. Answer those three and the integration is usually straightforward.