AI & vibe coding · Explainer

RAG explained
like you're five

RAG, retrieval-augmented generation, means letting an AI look things up before it answers. Like an open-book exam: instead of answering from memory, the system first searches a trusted collection — your documents, policies or product data — finds the most relevant passages, and gives them to the model to write an answer, ideally with citations. RAG keeps answers current and grounded in your own information without retraining the model, and reduces made-up answers.

By , FounderUpdated 3 min read

Share

Quick answer: What is RAG (retrieval-augmented generation)?

  1. Simple version — an open-book exam for AI.
  2. Steps — retrieve relevant passages, then generate an answer from them.
  3. Why — current, private and verifiable answers without retraining.
  4. Pieces — chunking, embeddings, search, prompt, citations.
  5. Quality — retrieval quality decides answer quality; evaluate both.

Key takeaways

  • Most 'chat with your documents' products are RAG systems.
  • Bad retrieval leads to confident wrong answers — measure it.
  • Hybrid search (keywords + meaning) often beats either alone.
  • Citations let users verify and build trust.
  • RAG and fine-tuning solve different problems; many systems use RAG first.

Imagine two students taking an exam. One has to answer from memory. The other can bring the textbook, find the right page, and write the answer with the page number. The second student is less likely to make things up — and you can check their work. That's retrieval-augmented generation (RAG): letting an AI look things up before it answers. The idea was formalised in a 2020 research paper by Patrick Lewis and colleagues1.

What is RAG (retrieval-augmented generation)? At a glance: Simple version; Steps; Why; Pieces; Quality.
At a glance: What is RAG (retrieval-augmented generation)?

The five-year-old version

Diagram of 4 steps for the five-year-old version: 1. You ask a question.; 2. The system looks in its books for the pages that talk about it.; 3. It reads those pages.; 4. It answers using those pages.
The five-year-old version
  1. You ask a question.
  2. The system looks in its books for the pages that talk about it.
  3. It reads those pages.
  4. It answers using those pages — and tells you which pages it used.

The builder's version

How a RAG system works
StageWhat happensKey decisions
IngestDocuments are cleaned and split into chunksChunk size and overlap; keep headings and metadata
EmbedEach chunk is turned into an embedding (a vector of meaning)Embedding model; language support
IndexEmbeddings stored in a vector index (plus keyword index)Hybrid search; filters by user or permission
RetrieveThe question is embedded; similar chunks are foundHow many results; re-ranking
GenerateRetrieved chunks + question go to the modelInstructions to answer only from sources; citations

Why RAG beats asking the model alone

Why RAG beats asking the model alone: Current; Private; Verifiable; Cheaper.
Why RAG beats asking the model alone

Current

Update the documents and answers update — no retraining.

Private

Use your own internal knowledge securely, with permissions.

Verifiable

Citations let users check the source.

Cheaper

Usually far simpler than training or fine-tuning a model.

Where RAG goes wrong

Checklist: Where RAG goes wrong — Bad chunks; Missed retrieval; Stale or conflicting documents; Permission leaks; Prompt injection.
Where RAG goes wrong
  • Bad chunks — splitting mid-thought loses meaning
  • Missed retrieval — the right passage isn't found, so the answer is wrong
  • Stale or conflicting documents — garbage in, confident garbage out
  • Permission leaks — retrieving documents a user shouldn't see
  • Prompt injection — malicious text inside documents steering the model3

Evaluate it

Measure retrieval (did we find the right passages?) separately from generation (did we answer correctly from them?). Build a test set of real questions with known answers and sources, and re-run it whenever you change chunking, embeddings, prompts or models. Anthropic's guidance for building AI systems stresses starting simple and measuring before adding complexity2.

RAG powers most "chat with your documents" features — see how to add AI to an existing app and how to build a chatbot for your business.

Key terms, defined

RAG — retrieval-augmented generation. Embedding — a numeric representation of meaning. Vector database — stores embeddings for similarity search. Chunk — a piece of a document used for retrieval. Hybrid search — combining keyword and meaning-based search. Citation — a reference to the source passage.

Frequently asked questions

What does RAG stand for?

Retrieval-augmented generation — combining a retrieval step (finding relevant information) with a generation step (an AI model writing an answer using that information).

Who invented RAG?

The term was introduced in a 2020 research paper by Patrick Lewis and colleagues, 'Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks'.

What's the difference between RAG and fine-tuning?

RAG gives the model relevant information at question time, so knowledge stays current and traceable. Fine-tuning changes the model's behaviour or style through training. Use RAG for knowledge; consider fine-tuning for consistent formats or specialised behaviour.

What is a vector database?

A database that stores embeddings — numeric representations of meaning — so it can find passages similar in meaning to a question, not just matching words.

Does RAG stop hallucinations?

It reduces them by grounding answers in sources, but doesn't eliminate them. Good retrieval, instructions to answer only from sources, citations and evaluation all help.

When should I use RAG?

When answers depend on information the model doesn't have or that changes — company documents, product catalogues, policies, support articles, recent data.

Sources

  1. Lewis et al. — Retrieval-augmented generation for knowledge-intensive NLP tasks (2020)
  2. Anthropic — Building effective agents
  3. OWASP — Top 10 for Large Language Model Applications
  4. Checked October 23, 2026. Figures that change — fees, salaries, prices — are reviewed every six months; if something is out of date, tell us.
Pass it on

Know someone who'd enjoy this?

Send it to them — one tap, no sign-up. Good ideas travel best between friends.

Keep exploring

Where to go from here

Join free

Get the ideas, not the noise.

Sign up with Google and we’ll send you short UX psychology tips by email — why people tap, stall and leave, and what to do about it. Unsubscribe anytime. Prefer something to keep? Get the free Laws of UX guide as a PDF.

Get the free Laws of UX PDFFree · no spam · unsubscribe anytime
AI products

Make your AI feature something users trust.

A behavioral UX audit of your app or SaaS product: why users hesitate, stall and leave, and a prioritized fix list. Fixed price, 2–4 weeks.

Free certification

Turn what you know into a credential.

Free, test-based UX, UI and product certifications. Answer real product scenarios, graded on our server, and earn a founder-signed certificate anyone can verify and you can add to LinkedIn.

  • Credential ID
  • QR verification
  • LinkedIn-ready
Free PDF · 74 pages · 2 editions

The Laws of UX, in one field guide

60 research-backed principles in 6 categories — what each one means, why it works on the human brain and how to use it on your own screens. Written by Sushant Singh, founder of Science of Apps, who has scaled consumer apps to lacs of users and spent 10+ years leading product across startups and digital businesses in the US, EU & India.

Pick your edition
Free. No card, no paywall — just your email.
Free PDF · 74 pages

Get Laws of UX by email

Choose your edition

You’ll also get occasional UX psychology tips. Unsubscribe anytime. Privacy policy

Free PDF · 90 pages · 2 editions

100+ Subscription Paywalls, decoded

110 real paywalls from top apps, taken apart, rated out of 5 and decoded with the Laws of UX — plus the frameworks, copy and checklists to ship your own. By Sushant Singh, founder of Science of Apps.

  • 110 paywalls rated
  • 34 Laws of UX
  • 12 frameworks

Which paywall scored 4.8 out of 5, and which scored 2.6? It’s all inside.

Pick your edition
Free. No card, no paywall — just your email.
Free PDF · 90 pages

Get 100+ Paywalls, Decoded by email

Choose your edition

You’ll also get occasional UX psychology tips. Unsubscribe anytime. Privacy policy