Skip to content
Enrique Tomás Martínez Beltrán
HomeResearchPublicationsTopicsTeachingBlog
Contact
EN/ES
HomeResearchPublicationsTopicsTeachingBlogContact
EN/ES

Enrique Tomás Martínez Beltrán

Postdoctoral research in AI, cybersecurity and federated learning, spanning threat analysis, closed-loop cyberdefense and trustworthy decentralized learning.

  • Privacy Policy
  • Terms of Service
  • Accessibility Statement
  • Google Scholaropens in a new tab
  • ORCIDopens in a new tab
  • LinkedInopens in a new tab
  • GitHubopens in a new tab
All profiles
  • ResearchGateopens in a new tab
  • Scopusopens in a new tab
  • DBLPopens in a new tab
  • Web of Scienceopens in a new tab

Enrique Tomás Martínez Beltrán. All rights reserved.

Back to top

This site loads optional analytics from Google and external analytics providers only if you accept. You can decline and continue using the site normally.

  1. Home
  2. Research Notes on Federated Learning, Cybersecurity and Cyberdefense
  3. Retrieval-Augmented Generation for Cybersecurity Workflows
RAGRetrieval-Augmented GenerationLLMsCybersecurityThreat Intelligence

Retrieval-Augmented Generation for Cybersecurity Workflows

What retrieval adds to an LLM and what it still cannot guarantee

Enrique Tomás Martínez Beltrán

Postdoctoral Researcher in Computer Science

August 13, 20269 min read
  • LinkedInopens in a new tab
  • Xopens in a new tab
Retrieval-Augmented Generation for Cybersecurity Workflows

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 qqq and a document collection DDD, a retriever selects a context:

Ck(q)=TopK⁡d∈Ds(q,d).C_k(q) = \operatorname{TopK}_{d\in D} s(q,d).Ck​(q)=TopKd∈D​s(q,d).

The generator then produces an answer conditioned on both the query and the context:

y∼pθ(y∣q,Ck(q)).y \sim p_\theta(y \mid q, C_k(q)).y∼pθ​(y∣q,Ck​(q)).

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 c1,…,cnc_1,\ldots,c_nc1​,…,cn​, a grounding review can estimate:

G=1n∑i=1n1[ci is entailed by the selected context].G = \frac{1}{n}\sum_{i=1}^{n}\mathbf{1}[c_i\text{ is entailed by the selected context}].G=n1​i=1∑n​1[ci​ is entailed by the selected context].

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.

Further reading

  • Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks

Related Research

GraphRAG for Cyber Threat Intelligence

August 13, 2026

GraphRAG for Cyber Threat Intelligence

How graph-based retrieval can connect actors, techniques, assets and incidents while preserving a traceable path to source evidence.

Large Language Models for Cybersecurity: A Careful Starting Point

August 13, 2026

Large Language Models for Cybersecurity: A Careful Starting Point

A practical map of LLM roles in cyberdefense, from threat-intelligence support to alert triage and explanation, with explicit limits and controls.