Home · Interview questions · RAG: Retrieval + Generation · Updated
Interview Questions: RAG: Retrieval + Generation
32 questions on “RAG: Retrieval + Generation” — with short answers and a link to an in-depth explanation of each topic.
How to use it: cover the answer, answer out loud within a minute, then compare. All sections are on the interview questions page. Topics marked “in Russian” are not translated yet.
- What RAG Is and Why You Need It · 4
- Vector Search and ANN Indexes · 4
- Vector Databases and Their Types · 4
- Chunking and Data Preparation · 4
- Hybrid Search and Reranking · 4
- MMR and Result Diversity · 4
- Embedding Models: How They Are Trained · 4
- Evaluating RAG Quality · 4
What RAG Is and Why You Need It (in Russian)
- “RAG or fine-tuning?” — knowledge vs skill: fresh/private facts — RAG; style, format, domain behavior — fine-tuning; often a combination.
- “Draw the RAG pipeline” — two phases: indexing (documents → chunks → embeddings → vector DB) and query (question embedding → top-k → prompt → generation).
- “Why RAG with a million-token window?” — corpus scale, query cost and latency, attention degradation; retrieval selects only what's needed.
- “How does RAG affect hallucinations?” — it reduces them and makes them verifiable through citations, but doesn't eliminate them: garbage in — fantasy out.
Vector Search and ANN Indexes (in Russian)
- “Cosine or Euclidean?” — on normalized vectors the ranking is almost the same; what matters more is which metric the embedding model was trained with and the index was built with.
- “Explain HNSW in simple terms” — a multi-layer graph: “highways” at the top for long jumps, “streets” at the bottom for precise refinement; greedy descent through the layers.
- “What do you tune in IVF if recall is low?” — increase nprobe (slower, more complete) or the number/quality of centroids; check the case of queries near cell boundaries.
- “How does ANN coexist with metadata filters?” — post-filtering may leave fewer than k results; you need an engine that filters inside the index traversal.
Vector Databases and Their Types (in Russian)
- “How is a vector DB different from a relational one?” — a relational DB looks for an exact match by value (equals/greater than) and does JOINs with ACID; a vector DB looks for semantic proximity through an ANN index. Different questions — different data structures.
- “Do you need a separate vector DB or is pgvector enough?” — if Postgres is already in the stack and you have up to ~1M vectors, pgvector is simpler to operate: one database, transactions, backups. A dedicated service — when scale and load require it.
- “Pre-filtering or post-filtering?” — a post-filter can knock out almost all results under a strict condition; a pre-filter is more accurate but more expensive. Ideally — filtering inside the index traversal (filter-aware search).
- “When do you not need a vector DB at all?” — with thousands of documents: numpy/FAISS in memory, no separate service.
Chunking and Data Preparation (in Russian)
- “How do you choose the chunk size?” — it's a trade-off: larger means more context but a blurred vector; smaller means a precise vector but lost meaning. It is chosen experimentally by retriever metrics (see RAG evaluation).
- “Why overlap and what's wrong with it?” — it saves thoughts at the boundaries, but breeds duplicates in the index and the results.
- “Users complain that answers are cut off mid-sentence. Where do you look?” — check the chunk boundaries: most likely the answer is split; fixed with overlap or structural chunking.
- “What do you put in the metadata?” — date, source, version and access rights; without ACLs the system is insecure.
Hybrid Search and Reranking (in Russian)
- “How is a bi-encoder different from a cross-encoder?” — separate encoding (vectors precomputed, fast search, lower accuracy) versus reading the pair jointly (higher accuracy, but O(N) inferences — only for reranking the top).
- “Why RRF and not a sum of scores?” — BM25 scores and cosine live on incomparable scales; RRF works with ranks and needs no calibration.
- “When is pure vector search not enough?” — exact terms: SKUs, error codes, names, abbreviations, article numbers.
- “What price do we pay for a reranker?” — latency and inference cost; that's why it is applied to the top-N, not the whole database.
MMR and Result Diversity (in Russian)
- “What does the λ parameter do in MMR?” — it balances relevance (λ→1, risk of duplicates in the results) and novelty/diversity (λ→0, risk of irrelevance); in practice λ ≈ 0.5–0.7.
- “Why diversity in RAG?” — top-k by pure similarity often fills the context with near-duplicates; MMR gives the LLM different facets of the topic instead of copies of one point.
- “When does MMR hurt?” — on narrow factual questions where top-1 accuracy matters; then λ is kept high or MMR is turned off.
- “How is MMR different from a reranker?” — a reranker refines the relevance of each document separately, MMR optimizes the composition of the set given what has already been selected (marginal relevance).
Embedding Models: How They Are Trained (in Russian)
- “How do you fine-tune an embedder for your domain?” — query–document pairs from your own data → mining hard negatives → contrastive fine-tuning with a small LR → reindexing and measuring recall@k on a golden set. And mention the alternative: a reranker is often enough.
- “Why hard negatives?” — random negatives are too easy, the gradient on them is almost zero; hard negatives teach the model to tell the similar from the relevant.
- “What are Matryoshka embeddings?” — training in which the first k coordinates are a standalone embedding: the vector can be truncated to a budget without retraining.
- “Why does E5 have query:/passage: prefixes?” — role asymmetry: the query and the document are encoded differently, and the model must know which one it is looking at.
Evaluating RAG Quality (in Russian)
- “How do you evaluate the quality of a RAG system?” — separately: the retriever (recall@k, precision@k, MRR/nDCG on a golden set) and the generator (faithfulness, answer relevance via LLM-as-judge).
- “The answers are bad — what do you check first?” — retrieval: most often the needed chunk simply isn't in the context.
- “What happens if you greatly increase k?” — recall goes up, but junk goes into the context: faithfulness and answer accuracy may drop, latency and cost go up.
- “What are the problems with LLM-as-judge?” — preference for long answers, position bias, leniency towards texts of a similar style; fixed by calibration against human labels.