What does RAG primarily help with in LLM-based applications?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
RAG retrieves relevant docs at query time and stuffs them into the prompt, grounding the LLM's answer in real, fresh, or private data instead of hoping it memorized the fact.
Imagine asking a smart friend a question about a niche topic they don't know much about. Without help, they'll guess (often confidently). Now give the same friend a few relevant pages from a textbook before they answer. They read the pages, then respond using both their general knowledge and the pages in front of them. That's RAG, short for Retrieval-Augmented Generation. The friend is the LLM. The pages are documents fetched from a vector database. The fetching happens automatically at query time, so the model always has fresh, specific information for whatever the user just asked.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
3 min: 5-step pipeline + RAG vs fine-tune + when each wins + production gotchas + one eval framework.
| Concern | RAG | Fine-tuning |
|---|---|---|
| Fresh / changing data | Just reindex, no retraining | Have to retrain (slow, expensive) |
| Style or format learning | Weak, prompt level only | Strong, baked into weights |
| Citable answers | Yes, chunks have provenance | No, weights have no source |
| Cost per query | Higher, retrieval adds tokens | Lower, no retrieval step |
| Best for | Private or recent facts | Behavior, voice, domain reasoning |
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Believing RAG and fine-tuning solve the same problem. RAG injects fresh facts; fine-tuning teaches style, format, or domain reasoning.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.