Skip to main content

What is RAG, and why would you use it?

RAG · Intermediate 2

Short answer

Retrieval-augmented generation fetches relevant text from your own documents and gives it to the model with the question, so it answers from that text. Use it when the model needs private, recent or frequently changing information, and when you want answers with sources you can check.

Deeper answer

A basic pipeline: split documents into chunks, embed them, store them in an index; at question time, embed the query, retrieve the closest chunks, and prompt the model to answer only from them and cite which chunk it used.

RAG beats fine-tuning for facts that change, because you update documents instead of retraining. It also allows access control (retrieve only what the user may see) and citations. Its weak point is retrieval: if the right chunk is not found, the answer will be wrong or missing, so you evaluate retrieval separately from generation.

What a strong answer covers

Answer it out loud in the mock interview about 1 min

Follow-ups to expect

Common mistakes

Learn it

Build a RAG app

Today's AI turns are used

Lessons, roadmaps, videos, practice cards and the code playground stay free with your account, with no limit.