RAG retrieves passages relevant to a query (usually by embedding similarity) and adds them to the context before generation, grounding answers in your data and reducing hallucination. Quality hinges on chunking, embedding, and how the top results are selected and ranked.
Worked flow: embed the question → find the top-k nearest chunks by cosine similarity → paste them into the prompt with a “answer only from these sources” instruction → generate with citations. Gotcha: retrieval quality caps answer quality — if the right passage is not in the top-k, the model answers confidently from the wrong context, and no bigger model fixes it. Most “RAG is bad” problems are retrieval problems (chunking, embedding, ranking), not generation problems.