RAG Interview Questions
Retrieval-Augmented Generation — chunking, embeddings, vector search and grounded answers.
What is RAG and when would you use it instead of fine-tuning?
RAG retrieves relevant documents at query time and gives them to the model as context. Use it when knowledge changes often or must be cited; fine-tune to change style or behaviour.
Key Points:
- RAG is cheaper to update than retraining.
How do you choose chunk size?
Balance context and precision: small chunks retrieve precisely but lose context; large chunks keep context but dilute relevance. Start around a few hundred tokens with some overlap and test retrieval quality.
Key Points:
- Chunk on document structure (headings) when you can.
What is re-ranking?
A second pass that scores the top retrieved chunks with a more accurate (slower) model so the best context goes into the prompt.
Key Points:
- Retrieve wide, re-rank narrow.
How does vector search work?
Documents are split into chunks and converted into embeddings, which are stored in an index. At query time the question is embedded with the same model and the index returns the chunks whose vectors are closest, usually by cosine similarity.
Key Points:
- Approximate nearest-neighbour (ANN) indexes like HNSW keep search fast at scale.
- Query and documents must use the same embedding model.
What is hybrid search?
Hybrid search combines keyword search (such as BM25) with vector search and merges the results. Keywords catch exact terms — product codes, names, acronyms — that embeddings can miss, while vectors catch meaning and paraphrases.
Key Points:
- Results are often merged with reciprocal rank fusion.
- Usually more robust than either method alone, especially for enterprise data.
Do you always need a vector database for RAG?
No. For small collections an in-memory index or a vector extension on an existing database (like pgvector for PostgreSQL) is often enough. Dedicated vector databases help when you have millions of vectors, heavy filtering or high query volume.
Key Points:
- Start simple and scale when you have evidence you need to.
- Keyword search alone can be a solid baseline.
How do you evaluate a RAG system?
Evaluate retrieval and generation separately. For retrieval, measure whether the right chunks appear in the top results (recall@k, MRR). For generation, measure faithfulness to the retrieved context, answer relevance and correctness against a labelled question set.
Key Points:
- Build a test set of real questions with known source documents.
- LLM-as-judge tools like RAGAS can score faithfulness at scale, but spot-check them.
- Most bad answers trace back to bad retrieval.
What are common RAG failure modes?
The right content isn't in the index, chunking splits the answer apart, retrieval returns similar-but-wrong chunks, too much irrelevant context dilutes the prompt, or the model ignores the context and answers from memory.
Key Points:
- Diagnose by checking retrieved chunks before blaming the model.
- Fixes include better chunking, hybrid search, re-ranking and stricter grounding prompts.
What is chunk overlap and why use it?
Chunk overlap repeats a small amount of text at the boundary between consecutive chunks, for example 10–20% of the chunk size. It prevents a sentence or idea from being cut in half and lost to retrieval.
Key Points:
- Too much overlap wastes storage and returns near-duplicate chunks.
- Structure-aware chunking reduces the need for large overlaps.
What is query rewriting?
Query rewriting uses an LLM to turn the user's question into a better search query before retrieval — expanding acronyms, adding context from the conversation, or splitting a complex question into several sub-queries.
Key Points:
- Essential for follow-up questions like 'what about last year?'.
- HyDE is a variant that embeds a hypothetical answer instead of the question.
How does metadata filtering help retrieval?
Storing metadata such as source, date, department or access level with each chunk lets you filter results before or during vector search. This narrows the search to relevant documents and enforces permissions.
Key Points:
- Use it to apply document-level access control in RAG.
- Filters like 'most recent version only' prevent outdated answers.
How do you make RAG answers cite their sources?
Give each retrieved chunk an ID and source label in the prompt, instruct the model to cite the IDs it used for each claim, then map IDs back to links in the UI. Validate that cited IDs actually exist in the retrieved set.
Key Points:
- Citations build user trust and make errors easy to check.
- Ask the model to say when the context doesn't contain the answer.
What is agentic RAG?
In agentic RAG the model decides how to retrieve: whether to search at all, which source or tool to use, how to reformulate queries, and whether to search again after reviewing results. It replaces a fixed retrieve-then-generate pipeline with a reasoning loop.
Key Points:
- Handles multi-step and multi-source questions better.
- Costs more and is slower and harder to evaluate than a simple pipeline.