← All mindmapsMAIN TOPIC · 10 / 14

Retrieval-Augmented Generation

Retrieval, reranking, CRAG and grounded evaluation

Explore full topic ↗
100%
Retrieval-Augmented Generation overview revision sheet; full text available below

Use + to enlarge the vector sheet up to 400%, then pan horizontally or vertically. A readable text version is below.

Readable revision notes (19 concepts)

The same content as the visual sheet, optimized for mobile and assistive technology.

01 · Ingestion & indexing

  • Parse, clean, deduplicate; preserve source metadata
  • Chunk by structure; tune length and overlap
  • Embed chunks; index vectors; update/delete stale records

02 · Retrieval

  • Dense: semantic vector similarity; sparse: BM25
  • Cosine / dot product / L2 must match index assumptions
  • ANN (e.g. HNSW) trades recall for latency

03 · Hybrid & reranking

  • Combine lexical and dense candidates
  • RRF score = Σ 1/(k+rankᵢ)
  • Cross-encoder reranks top candidates with query

04 · Query improvements

  • Rewrite ambiguous queries; multi-query broadens recall
  • HyDE embeds a hypothetical answer for retrieval
  • Metadata and ACL filters restrict relevant authorized docs

05 · Context assembly

  • Deduplicate and rank; reserve output-token budget
  • Attach source IDs and citation evidence
  • Use prompt to separate evidence from instructions

06 · Corrective RAG (CRAG)

  • Evaluate retrieved evidence quality before generation
  • Strong evidence → refine/use; weak → seek alternatives
  • Original CRAG includes web retrieval and knowledge refinement

07 · Advanced patterns

  • Self-RAG uses learned reflection signals
  • Graph retrieval follows entity relationships
  • Adaptive retrieval decides when evidence is needed

08 · Evaluation

  • Recall@k = relevant retrieved / relevant total
  • MRR rewards early first hit; nDCG ranks graded relevance
  • Measure groundedness, answer relevance, citation accuracy

09 · Reliability & production

  • Access-aware retrieval; defend against injected documents
  • Track freshness, cost, p95 latency and failed retrievals
  • Abstain or ask clarification when sources insufficient

10 · Chunking strategies

  • Fixed length simple; recursive/structure-aware preserve headings and boundaries.
  • Overlap helps boundary recall but duplicates context and index size.
  • Parent-child retrieves small chunks then expands to larger context; preserve provenance.

11 · Embeddings & ANN

  • Bi-encoder embeds query/docs separately; same compatible model/dimensions.
  • Cosine similarity, dot product or L2 must match normalization/training.
  • HNSW graph search: tune efSearch/efConstruction and memory-recall tradeoff.

12 · BM25 & hybrid ranking

  • BM25 weights rare terms and saturates TF with length normalization.
  • Hybrid handles lexical exact names plus semantic paraphrases.
  • RRF sum 1/(k+rankᵢ); rerank union using cross-encoder; evaluate candidate recall.

13 · Reranking & context

  • Cross-encoder scores query/chunk jointly; expensive but precise.
  • Deduplicate, diversify evidence, filter ACL and reserve generation token budget.
  • Attach source IDs/page/date; verify citations point to actual support.

14 · Query rewriting, HyDE & multi-query

  • Rewrite resolves context or removes ambiguity; avoid changing intent.
  • HyDE generates hypothetical answer then embeds it for retrieval; not evidence.
  • Multi-query broadens coverage; fuse results and cap cost.

15 · CRAG

  • Retrieval evaluator classifies evidence quality (correct/incorrect/ambiguous).
  • Correct: refine retrieved knowledge; incorrect: seek alternative web evidence in original method.
  • Ambiguous: combine refinement and additional retrieval; evaluate against baseline.

16 · Self-RAG & adaptive retrieval

  • Self-RAG trains reflection tokens to decide retrieval and assess generation.
  • Adaptive approaches use query difficulty/evidence signals to route retrieval.
  • GraphRAG builds graph/entity relationships for multi-hop/global summaries; added indexing cost.

17 · RAG evaluation metrics

  • Recall@k relevant hits / total relevant; precision@k hits/k; MRR=mean 1/first relevant rank.
  • nDCG discounts rank and graded relevance; normalize by ideal DCG.
  • Faithfulness checks claims against evidence; answer correctness checks ground truth.
  • Separate retrieval errors from generation errors; measure citation validity.

18 · RAG security & freshness

  • Enforce permissions before retrieval; cache keys include tenant and access scope.
  • Treat retrieved text as untrusted; prevent prompt injection/tool privilege escalation.
  • Version indexes; propagate updates/deletes; timestamp and monitor stale citations.

19 · RAG architecture tradeoffs

  • Offline ingestion vs online query path; asynchronous incremental indexing.
  • Latency=embedding+search+rerank+prefill+decode; set stage budgets.
  • Abstain with insufficient evidence; fallback retrieval or ask clarification.

References & further study

Original schematics illustrate concepts, not measured data. Review these references for full derivations and implementation details.

Last 30 min revisionHigh-yield interview Q&As