Module deck

Retrieval-augmented generation flashcards

Reviewing needs JavaScript. You can read every card in the list below.

Loading your cards...

Back to the module38 cards in this deck

Read all 38 cards as a list

RAG architecture and chunking

  1. Front
    What is RAG, in one sentence?
    Back
    Retrieving relevant external content and putting it in the prompt so the model's answer is grounded in that content, without changing model weights.
  2. Front
    Why not embed a whole document as one vector?
    Back
    One vector blends every topic in the document, which dilutes relevance and loses the detail a question asks about. Chunking keeps retrieval specific.
  3. Front
    Name the chunk-size trade-off and what overlap adds.
    Back
    Small chunks: precise but may lose surrounding context. Large chunks: more context but blurrier matches and a noisier prompt. Overlap keeps boundary facts in at least one chunk, at the cost of more and near-duplicate chunks.
  4. Front
    What is small-to-big (parent-child) retrieval?
    Back
    Embed small chunks for precise matching, then return their larger parent section so the model gets context. Cost: bigger prompts and de-duplicating shared parents.
  5. Front
    Why must ACL filtering happen inside retrieval?
    Back
    Post-filtering can empty the top-k and can leak through scores, summaries and caches. Enforce permissions in the query (filter or namespace) and scope caches by identity.
  6. Front
    A table is split one row per chunk and retrieval gets worse. Why, and how do you fix it?
    Back
    Rows lose their column headers, so the numbers have no meaning. Keep small tables whole, repeat the caption and header in each chunk, or rewrite each row as a sentence before embedding.
  7. Front
    How do you choose a chunk size without folklore?
    Back
    Index at two or three sizes with other settings fixed, score recall@k on labelled questions, then check prompt cost and a few end-to-end answers.

The core RAG pipeline

  1. Front
    One-line rule for RAG vs fine-tuning?
    Back
    RAG for knowledge (fresh, citable, easy to update); fine-tuning for behaviour (style, format, task skill). They can be combined.
  2. Front
    Name the two lanes of a RAG pipeline and what is in each.
    Back
    Offline: parse, chunk, embed, index. Online (per query): retrieve, rerank, generate.
  3. Front
    Why must you version the index?
    Back
    Queries and chunks must use the same embedding model. Changing the model means re-embedding the whole corpus, so you need to know which model built which index.
  4. Front
    Confident wrong answer, correct passage exists in the corpus. What is the first test?
    Back
    Paste the gold passage into the prompt. Right answer: retrieval or ingestion problem. Still wrong: prompt or generation problem.
  5. Front
    Name four stages where a confident wrong answer can originate.
    Back
    Ingestion (bad parse, stale page), retrieval (filters, embedding, recall), ranking and context assembly (rerank, trimming), generation (model ignores or misreads context).

Better retrieval

  1. Front
    Why hybrid search?
    Back
    BM25 catches exact terms and IDs; vectors catch paraphrase. Fuse the lists (for example with Reciprocal Rank Fusion), then rerank.
  2. Front
    What does Reciprocal Rank Fusion compute, and why use it?
    Back
    score(d) = sum over lists of 1/(k + rank_i(d)), k = 60 by default (Cormack et al., SIGIR 2009). Ranks only, so no calibration of incompatible score scales.
  3. Front
    Bi-encoder vs cross-encoder?
    Back
    Bi-encoder embeds query and document separately (fast, precomputable). Cross-encoder scores the pair jointly (more accurate, one call per pair), so use it to rerank a shortlist.
  4. Front
    Why doesn't reranking fix a recall problem?
    Back
    It only reorders candidates it is given. If the right chunk is not in the shortlist, widen or change the first stage (more candidates, BM25, better query).
  5. Front
    What can go wrong with strict metadata pre-filters in an approximate index?
    Back
    Some ANN indexes lose recall or speed when a filter is very selective. Test your database with realistic filters. The filter value should come from the authenticated identity, not from user input.
  6. Front
    Name two costs of query transformations.
    Back
    Each adds an LLM call (latency, money) and can drift from the user's intent. Gate them to the queries that need them.
  7. Front
    What does MMR do?
    Back
    Maximal marginal relevance picks chunks that are relevant and different from those already chosen, so top-k is not near-duplicates.

All RAG types

  1. Front
    When does HyDE help and what is its risk?
    Back
    Helps when query and documents are phrased very differently. Risk: the hypothetical answer can be wrong and bias retrieval toward it.
  2. Front
    Self-RAG vs CRAG vs Adaptive RAG?
    Back
    Self-RAG: a trained model emits reflection signals and critiques itself. CRAG: grade retrieved docs, fall back (rewrite or web) when weak. Adaptive: route each query to no retrieval, single-shot or multi-step.
  3. Front
    What is the decision rule for choosing a RAG variant?
    Back
    Start with the simplest design that meets the quality bar, measure, and add complexity only for a failure you can name. Each extra call adds latency, cost and a failure mode.
  4. Front
    Naive, advanced, modular, agentic: one line each.
    Back
    Naive: retrieve once, generate once. Advanced: adds rewrite, rerank, filters. Modular: swappable stages wired by a router. Agentic: the LLM decides whether, what and how often to retrieve.
  5. Front
    When do you reach for GraphRAG, and what does it cost?
    Back
    For multi-hop or corpus-wide questions that top-k similarity handles poorly. Cost: expensive indexing, a graph that can go stale, and extraction errors that propagate.
  6. Front
    Name two things agentic RAG needs to be safe in production.
    Back
    Step limits to prevent loops, and tracing plus guardrails to evaluate and secure the many tool calls. Latency and cost become unpredictable without them.

RAG evaluation and hallucination

  1. Front
    Does RAG eliminate hallucination?
    Back
    No. It reduces it by grounding answers, but the model can still ignore, misread, or blend retrieved context with unsupported claims.
  2. Front
    Name two hallucination-mitigation techniques for RAG.
    Back
    An explicit "answer only from context" instruction with citations, and a retrieval-quality gate that refuses to answer when the best match score is too low.
  3. Front
    Three ways a model fails even with the right passage in the prompt?
    Back
    It ignores the context, misreads it, or blends it with plausible claims the passage never stated.
  4. Front
    Why is a copied similarity-score threshold risky?
    Back
    Scores are not comparable across embedding models or query types. Calibrate the gate on a labelled set and track both wrong refusals and wrong answers.
  5. Front
    Citations in the answer: what do they not guarantee?
    Back
    Presence of a citation does not mean the cited chunk supports the claim. Check citation accuracy.
  6. Front
    How do you classify a failure from a trace?
    Back
    Gold chunk not retrieved: retrieval. Gold chunk in prompt but answer contradicts it: generation. Answer follows a wrong or stale chunk: source.
  7. Front
    On a 30-question golden set, what is one extra correct answer worth, and what does it mean?
    Back
    About 3.3 percentage points. A one-question change is weak evidence; enlarge the set and inspect what changed.

RAG evaluation in depth

  1. Front
    What's the difference between a retrieval metric and a generation metric in RAG eval?
    Back
    Retrieval metrics (precision@k, recall@k, MRR) measure whether the right chunks were found; generation metrics (faithfulness, relevance) measure whether the answer is grounded in and addresses those chunks.
  2. Front
    Define recall@k, precision@k and MRR, and how they differ.
    Back
    Recall@k: was the relevant item found in the top k. Precision@k: fraction of the top k that is relevant. MRR: mean of 1/rank of the first relevant result, 0 if none; it also rewards ranking it higher.
  3. Front
    Three ranks 3, 1, none: what is MRR?
    Back
    (1/3 + 1 + 0) / 3, about 0.44. A miss counts as 0 and stays in the denominator.
  4. Front
    Retrieved gold = no, faithful = no, correct = yes. What does that mean?
    Back
    A lucky answer from the model's memory, not the corpus. It hides a retrieval gap and cannot be cited.
  5. Front
    Name three LLM-judge pitfalls and mitigations.
    Back
    Position bias, verbosity bias, self-preference. Use a fixed rubric, swap order in pairwise comparisons, calibrate against human labels, and prefer a judge from another model family.
  6. Front
    Why can synthetic evaluation questions mislead?
    Back
    They tend to copy chunk wording and be easier than real queries, inflating scores. Review a sample and add real logged queries and unanswerable questions.