Explain how RAG works end to end.
Answer
- Indexing (offline): split the documents into chunks, turn each chunk into an embedding, and store them with their text and metadata in a vector index.
- Query: embed the user's question with the same model and fetch the nearest chunks (often mixed with keyword search).
- Optional steps: filter by permissions, rerank the candidates, trim to the few best.
- Generation: put the chunks and the question in the prompt, tell the model to answer only from them and to cite them, and to say when the answer is not there.
- Updating knowledge means re-indexing the changed documents, not retraining the model.
- Evaluate retrieval (is the right chunk found?) and generation (does the answer follow the chunks?) separately.
Practice this question in Repaso