Retrieval-Augmented Generation, or RAG, combines a language model with an external collection of documents. The collection can contain playbooks, vulnerability records, incident reports or local policies. The model receives a selected context at inference time instead of relying only on what was learned during pre-training.
The idea is simple. The engineering is not.
1. The basic pipeline
Given a query and a document collection , a retriever selects a context:
The generator then produces an answer conditioned on both the query and the context:
The equation does not guarantee that the answer is supported. It only describes where the model received its context.
2. What matters in security settings
Security RAG needs more than semantic similarity. Retrieval should consider:
- document authority and version,
- time validity,
- asset or environment scope,
- access control,
- indicator normalization,
- whether the evidence is an observation, a rule or a hypothesis.
A stale playbook can be more dangerous than no playbook because it may look authoritative.
3. Separate retrieval quality from generation quality
If the answer is wrong, ask whether the retriever missed the relevant evidence, selected conflicting evidence or returned a good context that the generator misused. Store the retrieved identifiers and scores so the failure can be localized.
For a response with claims , a grounding review can estimate:
This is a useful diagnostic, not a substitute for expert review.
4. RAG is not a security boundary by itself
Retrieved documents can contain malicious instructions, sensitive data or contradictory policy. The application must keep instructions separate from evidence, filter access before retrieval and prevent the model from treating document text as a new system command.
The output should include citations, uncertainty and a refusal when the context is insufficient. A confident answer without provenance is a failed security response.
5. A disciplined rollout
Build a small, versioned corpus first. Use a golden set of realistic queries, include stale and conflicting documents, and evaluate retrieval and generation separately. Add human corrections to the evaluation set only after adjudication.
RAG improves access to current knowledge. It does not remove the need for source governance, access control or careful measurement.
This note is an original synthesis of RAG design for cybersecurity.


