Retrieval-Augmented Generation (RAG) is a technique that makes a large language model answer from your own documents instead of only its training data…
Define RAG and the hallucination/knowledge problem it fixes.
A large language model only knows what was in its training data, which is frozen and public. Ask it about your company's policies or last week's news and it will guess — often confidently wrong.
Retrieval-Augmented Generation (RAG) fixes this by fetching the relevant text first and putting it in the prompt, so the model answers from that evidence rather than memory.
Walk the two-step pipeline every RAG system runs.
1) RETRIEVE: embed the user's question, search a vector database of your document chunks, and pull back the few most similar passages. 2) GENERATE: paste those passages into the prompt with an instruction like 'answer using only this context,' and let the LLM write the answer.
The model's language skill stays; the facts come from your documents.
chunks = vector_db.search(embed(question), k=4) context = "\n\n".join(chunks) prompt = f"Answer using only this context:\n{context}\n\nQ: {question}" answer = llm.generate(prompt)
Search returns the top-k relevant chunks; they're joined into context; the LLM is told to answer only from them. Adding 'cite the source' makes answers verifiable.
Explain when RAG beats fine-tuning for knowledge.
Fine-tuning changes how a model behaves (tone, format, skills) by further training it — slow and re-done whenever facts change. RAG adds knowledge at query time with no training, so you can update the answer by just updating a document.
Rule of thumb: use RAG for changing or private FACTS; fine-tune for consistent STYLE or specialized skills. Many production systems use both.
Name the common failure modes and one caution.
RAG is only as good as retrieval. If the right chunk isn't retrieved, the model answers from memory again. Common fixes: better chunking, hybrid keyword+vector search, and reranking the results before generation.
RAG makes an LLM answer from your documents by retrieving the most relevant passages (usually via embedding similarity) and putting them in the prompt before it generates. It grounds answers, cuts hallucination, and adds private or current knowledge without retraining — but it's only as good as its retrieval step.
You want a chatbot that answers from your product docs. Describe the RAG pipeline you'd build and the one thing you'd measure to know retrieval is working.
What is RAG (Retrieval-Augmented Generation)?
RAG augments generation with retrieved context, grounding answers in your documents and cutting hallucination.
Why choose RAG over fine-tuning for company facts that change often?
RAG suits changing/private facts; fine-tuning suits stable style or skills. Facts → RAG.
What is the most common reason a RAG answer is wrong?
RAG quality is retrieval quality. Fix retrieval (chunking, hybrid search, reranking) before blaming the model.