Retrieval-augmented generation, usually shortened to RAG, gives a language model access to your own documents. When a user asks a question, the system retrieves relevant passages and asks the model to answer using them. It is the foundation of most enterprise knowledge assistants.
A basic version can be built in an afternoon. Getting it right takes much longer, and most of the work is not about the model.
Why prototypes disappoint
Typical problems once a RAG prototype meets real users:
- It retrieves the wrong passages, so answers are confidently wrong.
- It misses information that is in a table, an image or a poorly formatted document.
- It mixes old and new versions of the same policy.
- It shows content users should not see.
- Nobody knows how accurate it is, so trust erodes after a few bad answers.
Each of these is an engineering problem with an engineering solution.
Get the documents right
Retrieval can only find what is properly prepared. That means:
- Extracting text faithfully from PDFs, tables and scans
- Splitting documents into passages that keep their meaning, with headings and context attached
- Recording metadata such as source, date, owner and version
- Removing duplicates and outdated versions, or marking them clearly
This preparation is often the largest single piece of work, and the one with the biggest effect on quality.
Get retrieval right
- Hybrid search combines meaning-based search with keyword search, which catches exact terms like product codes and policy numbers.
- Re-ranking reorders candidate passages so the most relevant reach the model.
- Filtering by metadata, such as date or department, narrows results before ranking.
- Access control at retrieval time ensures users only get answers from content they are allowed to see.
Make answers checkable
Ask the model to answer only from retrieved passages, cite them, and say so when the sources do not contain an answer. Show the citations to users so they can verify answers in a click. An assistant that says “I could not find this” is far more trustworthy than one that guesses.
Measure everything
Build an evaluation set of real questions with expected answers and sources, reviewed by subject matter experts. Measure:
| Measure | Question it answers |
|---|---|
| Retrieval recall | Did we find the right passages? |
| Answer accuracy | Is the answer correct? |
| Faithfulness | Is the answer supported by the sources? |
| Refusal quality | Does it decline when it should? |
Run the evaluation on every change to prompts, models, chunking or retrieval settings. Improvements in one place often cause regressions in another.
Operate it like a product
After launch, collect user feedback, review samples of real conversations, track costs and keep the document index current. Assign an owner who reviews quality regularly.
In a good RAG system, the model is the easy part. The quality comes from documents, retrieval, evaluation and people who keep all three healthy.