Retrieval-augmented generation
Section titled “Retrieval-augmented generation”Retrieval-augmented generation, or RAG, supplies external information to a model for the current task instead of relying only on model parameters.
flowchart LR
Query[User or system query] --> Access[Apply access control]
Access --> Retrieve[Retrieve candidate evidence]
Retrieve --> Rank[Filter and rank]
Rank --> Context[Build model context]
Context --> Model[Generate answer]
Model --> Verify[Verify claims against evidence]
Access control belongs before retrieval so unauthorized material does not enter the model context.
Context
Section titled “Context”RAG is useful when answers depend on private data, changing information, large corpora, or evidence that should be traceable to a source.
Failure modes
Section titled “Failure modes”Retrieval can return irrelevant, stale, duplicated, or malicious text. A strong generator cannot recover information that retrieval failed to supply.
A system can also cite retrieved material that does not support the generated claim.
Practical guidance
Section titled “Practical guidance”Evaluate retrieval and generation separately. Preserve source identity and freshness. Apply access control before retrieval, not after generation.
Use reranking, filtering, metadata constraints, or query rewriting when they improve measured retrieval quality.
Require claim-to-source verification for high-impact outputs. RAG reduces some knowledge limitations but does not remove hallucination risk.
Sources
Section titled “Sources”- Patrick Lewis et al. “Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks.” 2020.