What is RAG?
Fetch the relevant passages from your own documents at question time and put them in the prompt, so the answer is grounded in your sources.
Guide · AI
Retrieval-augmented generation is a simple idea wrapped in intimidating vocabulary: before answering, go and find the relevant text, then put it in the prompt. Everything hard about RAG is in the finding.
A language model knows what was in its training data and nothing about your documents, your database, or anything that happened after its cutoff. The two ways to fix that are fine-tuning, which bakes knowledge into weights and is expensive to update, and retrieval, which fetches the relevant text at question time and hands it to the model.
Retrieval wins for facts that change. Fine-tuning wins for behaviour and format. Most people who think they need fine-tuning need retrieval and a better prompt.
Chunk too small and a passage loses the context that made it meaningful — a paragraph that says "this is not permitted" without the sentence naming what "this" is. Chunk too large and the embedding averages several topics into a vector that is close to nothing in particular.
| Failure | What it looks like | Usual fix |
|---|---|---|
| Retrieval miss | The answer exists in the corpus but never reaches the prompt | Hybrid search — combine keyword and vector retrieval; add reranking |
| Right chunk, wrong slice | The retrieved passage is adjacent to the answer | Better chunk boundaries, overlap, retrieve neighbours of a hit |
| Model ignores context | Answer contradicts the supplied passages | Instruct explicitly to answer only from context; require citations per claim |
| Confident empty answer | Nothing relevant was retrieved and the model invents something | Give it permission to say the corpus does not contain the answer, and test that path |
The second-order lesson: evaluate retrieval separately from generation. If you only measure final answers you cannot tell whether the retriever failed or the model did, and you will tune the wrong half of the system.
Vector similarity is good at "find text that means something like this" and bad at relationships — prerequisites, dependencies, ordering, hierarchy. Ask "what do I need to understand before this concept?" and similarity search returns passages that mention the concept, not the ones that precede it.
That is where a graph helps: model the entities and the edges between them, walk the graph to assemble context, and use retrieval to fill in the text. This graph-augmented approach is the subject of one of the two SIGCSE Technical Symposium 2026 papers I co-authored — using knowledge graphs to build adaptive curriculum maps, so a tutoring system can reason about prerequisite structure rather than topical similarity.
The companion paper looked at bilingual coding for inclusive CS learning (DOI 10.1145/3770761.3777339), a mixed-methods IRB study of 60 participants that reported significant pre-to-post gains in learner confidence. More on the research →
FAQ
Fetch the relevant passages from your own documents at question time and put them in the prompt, so the answer is grounded in your sources.
Retrieval for facts that change; fine-tuning for behaviour and format. Most 'we need fine-tuning' problems are retrieval problems.
Too small loses context, too large blurs the vector. Split on structure, overlap slightly, keep tables and code intact, attach metadata.
Retrieval miss, adjacent-passage miss, model ignoring context, or invention on an empty retrieval. Measure retrieval separately to tell which.
Rescoring the vector-search candidates with a stronger model and keeping only the best few. Big precision win for little work.
When the question is about prerequisites, dependencies, or ordering — relationships that similarity search cannot represent.