Artificial intelligence

What is RAG (retrieval-augmented generation)?

Short answer

RAG means finding and retrieving relevant passages from your company’s documents before a language model answers, and basing the answer on those passages. This way the model responds with current, company-specific information and the risk of made-up answers goes down.

In detail

How does it work?

Documents are split into chunks and written to an index that can be searched by meaning. When a user asks a question, the system finds the most relevant chunks and asks the language model together with those chunks; the model grounds its answer in these sources. This way, company knowledge that wasn’t in the model’s training can be used.

What determines quality?

What matters is clean and up-to-date documents, sensible chunking, search quality and showing the source of the answer. A system that retrieves the wrong chunk can produce a fluent but wrong answer. That’s why you need to add source links to answers and test regularly with evaluation questions.

When RAG, and when fine-tuning?

RAG is suitable if information changes often or you need to show sources. Fine-tuning is considered when you need to teach the model a style or a specific task. For most enterprise knowledge-retrieval work, RAG is more practical and easier to keep up to date.

Follow-up questions

Does RAG completely prevent hallucination?
It reduces it but doesn’t completely prevent it. If the right source isn’t found, the model can still give a wrong answer; so it should be designed to be able to say “I don’t know” and to show its sources.
Will my documents leave my environment?
It depends on the setup. If the language model and the index run in your own environment, the data doesn’t leave it; if a hosted model is used, the relevant chunks are sent to that service.

Platform interfaces change over time; check the platform’s official help pages for current steps.