CASE №0005 · Classification: Examined — Thesis Accepted

Confidence-Aware RAG

Retrieval that knows when it doesn't know · MSc research, University of Ghana, 2025

Retrieval for cyber defence that knows when it does not know.

Filing Metadata

Type
Software
Status
Active
Stack
6 components
Filed
MMXXV
The Premise

Filed by the Agent · For Internal Distribution

An LLM answering a security question sounds exactly as authoritative when it is guessing as when it is right. In most domains that is an annoyance. In vulnerability analysis it is a failure mode with consequences: a confidently wrong answer about a CVE sends an analyst down the wrong remediation path, and nothing in the answer's tone warns them.

The fix is not a better model but a calibrated one — a system whose stated confidence actually tracks whether it is correct. This system retrieves along two paths: dense vector search over CVE, CWE, CAPEC, and ATT&CK text, and Cypher queries against a Neo4j graph linking each vulnerability to its root-cause weakness and the techniques that exploit it.

It then scores its own confidence in three stages: sampling multiple answers and measuring their agreement, checking every factual claim against the graph for contradictions, and passing the answer to a separate GPT-4 judge alongside the evidence.

The Bureau approves of any system prepared to state, in writing, that it does not know.

The Method · Retrieval, Fusion, Judgement

Chapter A · Dual-Path Retrieval

When one index isn't enough.

Security knowledge is both prose and structure. The prose lives in CVE, CWE, CAPEC, and ATT&CK descriptions and is best reached by dense vector search. The structure — this vulnerability stems from that weakness, which is exploited by these techniques — is a graph, and asking a vector index to answer a structural question produces plausible nonsense. So the system runs both: FAISS over the text, Cypher over the graph.

Exhibit A · Dual-Path Retrieval · Architecture

Dense vectors · Neo4j graph

  • FAISS dense retrieval over CVE, CWE, CAPEC, ATT&CK
  • Cypher queries against a Neo4j vulnerability graph
  • Root-cause weakness and exploiting techniques linked explicitly
  • Structural questions answered structurally

Chapter B · Three-Stage Confidence

When the system grades itself.

Confidence is computed, not asserted. First the system samples multiple answers and measures how much they agree — wide disagreement is itself a signal. Second, every factual claim is checked against the graph for contradiction. Third, the answer and its evidence go to a separate GPT-4 judge. An ablation confirmed all three stages are load-bearing: removing the fusion step alone collapsed calibration from 0.096 to 0.299.

Exhibit B · Confidence Scoring · Three Stages

Agreement · contradiction · judgement

  • Self-consistency sampling across multiple answers
  • Claim-by-claim contradiction check against the graph
  • Separate GPT-4 judge scoring answer against evidence
  • Ablation: dropping fusion collapses ECE to 0.299

Chapter C · Evaluation

When the numbers are asked to prove it.

Tested on 200 queries spanning definitions, specific CVEs, cross-framework mappings, and deliberately fictitious identifiers. Expected calibration error came out at 0.096 — a 56% improvement over document-only retrieval and 65% over graph-only — with confidence correlating to expert-verified correctness at r = 0.899. On the invented CVEs, mean confidence dropped to 0.08 against roughly 0.22 for both baselines: the system reliably recognised the questions it had no business answering.

Exhibit C · Calibration · ECE Against Baselines

200 queries · four categories

  • ECE 0.096 — 56% better than document-only, 65% than graph-only
  • Confidence ↔ expert-verified correctness at r = 0.899
  • Fictitious CVEs: mean confidence 0.08 vs ~0.22 baselines
  • 200 queries across four question categories
Technical Specification

Parts Inventory · Annotated by the Agent

Model
GPT-4 (Azure OpenAI)
Language
Python
Orchestration
LangChain
Graph
Neo4j / Cypher
Vector Index
FAISS
Interface
Streamlit
Institution
University of Ghana, 2025
Corpora
CVE · CWE · CAPEC · ATT&CK
Field Notes

Asked about vulnerabilities that were never real, it said so. That was the whole experiment.

— Internal memo, undated

Source materials and binaries withheld pending review.