Irfan Mohammed

Projects / Threat intelligence RAG

Grounding an LLM in real threat intelligence

A retrieval-augmented generation (RAG) system that answers analyst questions using AlienVault OTX indicators instead of whatever the model remembers. I built it during my research internship at the University of Guelph’s Cyber Science Lab.

Role
Research intern: data pipeline, embeddings, evaluation, docs
Stack
Python, LLaMA 3 8B Instruct, Qdrant, BGE-large, LangChain, OTX API
Outputs
Open-source repo, technical guide, video walkthrough
Code
CyberScienceLab/Threat_Intelligence_Rag

The problem

Ask a general-purpose LLM for “an IP address linked to RDP intrusion attempts” and it will happily give you one. It might be real, outdated, or invented. In threat intelligence a made-up indicator of compromise (IOC) is worse than no answer, because someone might block it, or worse, trust it.

The lab wanted to know whether retrieval could fix this: make the model answer only from indicators we had actually pulled from a threat intelligence platform, and show the analyst exactly which records the answer came from.

Architecture

There are two flows. Ingestion runs ahead of time and turns OTX pulses into vectors in Qdrant. Each query embeds the question, pulls the closest indicators, and gives only those to LLaMA 3 with instructions to say “I don’t know” when the context doesn’t cover the question.

Figure 1. Ingestion runs once per data pull. Queries only ever see what’s in Qdrant, and the retrieved chunks are shown next to the answer.

Why this design

RAG instead of fine-tuning

Threat intelligence goes stale in days. Fine-tuning would bake indicators into the weights, where they can’t be updated, audited or traced back to a source. With retrieval, refreshing the data means re-running ingestion, and every answer can cite the records it used.

Trade-off: answer quality is capped by retrieval quality. If the right chunk isn’t in the top five, the model can’t use it.

A local open model (LLaMA 3 8B) instead of a hosted API

Analysts’ questions and uploaded reports can be sensitive. Running Meta-Llama-3-8B-Instruct on lab hardware kept everything on premises, and at 8B it fit on a single GPU in bfloat16.

Trade-off: weaker reasoning than frontier models. That was acceptable because the job was mostly to read and restate retrieved facts.

Qdrant as the vector store

Qdrant runs as one Docker container, stores a metadata payload with each vector (so I could keep the pulse ID, indicator type and source), and has a UI for checking what got embedded.

Considered: an in-memory index such as FAISS, which is simpler but has no persistence or payloads, and pgvector, which would have meant running and tuning Postgres for a prototype.

BGE-large embeddings, run on CPU

BAAI’s bge-large-en ranked well on retrieval benchmarks at the time and is free to run locally. Embedding on CPU left the GPU for the LLM. Uploads go in batches of 100 with a pause in between so Qdrant isn’t overloaded.

A strict system prompt

The prompt tells the model to answer only from the provided reports and to say it doesn’t know otherwise. That’s the cheapest guard against hallucination, and the “view relevant context” link lets analysts check the answer themselves.

Demo

The lab’s UI let analysts switch between knowledge bases (CVE, threat intelligence, pen-testing and malware) and choose how many chunks to retrieve. I wrote the public guide and recorded a walkthrough.

Video. How to use RAG for threat intelligence, a walkthrough I recorded for the Cyber Science Lab.

Screenshots and video © University of Guelph Cyber Science Lab. Full guide: Developing a RAG to Mitigate LLM Hallucinations in Threat Intelligence (PDF).

Add the evaluation results if you still have them: how many test questions, how often the plain model invented an IOC compared with the RAG version, and any retrieval accuracy numbers. A single before-and-after number would make this page much stronger.

What I learned

  • Most of the work is data, not the model. OTX pulses arrive as nested JSON. Deciding what counts as one “document,” and which metadata to keep, affected answer quality more than any prompt change.
  • Show your sources. Putting the retrieved context next to every answer made the tool checkable. Without it, a confident answer and a hallucinated one look the same.
  • Documentation is part of the deliverable. Writing the public guide made me find every step I’d been doing from memory, like the Qdrant container, the Hugging Face token and the OTX key, and spell it out for people who’d never seen the project.