How does Retrieval-Augmented Generation (RAG) work?
mediumAnswer
- Index a knowledge corpus as embeddings in a vector database.
- At query time, embed the user question, retrieve the top-k most similar chunks, and feed them as context to the LLM alongside the question.
- The LLM generates an answer grounded in the retrieved passages, often with citations.
- Key knobs: chunking strategy, embedding model, retriever (dense + BM25 hybrid), reranker, and prompt template.
Check yourself — multiple choice
- RAG replaces the transformer with a retrieval index
- RAG retrieves relevant chunks and injects them into the prompt
- RAG does not use embeddings
- RAG works only on structured databases
Retrieve top-k into answers grounded in them.
#rag#retrieval
Practise LLMs & GenAI
214 interview questions in this topic.