Dataset Viewer

The dataset viewer is not available because its heuristics could not detect any supported data files. You can try uploading some data files, or configuring the data files location manually.

CVE-KGRAG Knowledge Base

A processed, ready-to-ingest knowledge base for retrieval-augmented generation over CVEs, linked to CWE, CAPEC, and MITRE ATT&CK. Drop these files in, run one script per backend, and you have Qdrant (hybrid dense+sparse), BM25, and Neo4j populated.

Built from NVD (with FKIE descriptions where applicable), MITRE CWE, MITRE CAPEC, and MITRE ATT&CK. Snapshot: 2026-04-21.

What's inside

Path Size Used by Description
knowledge_graph/ 1.2 GB Neo4j Graph nodes + relationship JSONs (idempotent MERGE-friendly)
rag_exports/ 565 MB Qdrant, BM25 Pre-chunked text + payloads for vector + sparse indexing
bm25/vocab.json 3.7 MB BM25 sparse encoder Prebuilt vocabulary (IDF + token IDs) for Qdrant sparse vectors
enhanced_documents/ 1.4 GB Re-chunking, custom pipelines One JSON per year (1999–2026), CVE docs with CWE/CAPEC/MITRE mappings already applied
code/ 2.4 MB Reproducing the pipeline Full source tree of the CVE-KGRAG project that produced this data
scripts/ Loading + updating Thin wrappers: load_neo4j.py, load_qdrant.py, load_bm25.py, update_from_fkie.py

Key statistics

  • CVEs: 327,574 (1999–2026)
  • Products: 170,231 | Vendors: 36,305
  • CWEs: 768 | CAPECs: 443
  • MITRE techniques: 174 | tactics: 37
  • CVE↔CAPEC edges: 2,500,380 | CVE↔technique: 693,501 | CVE↔product: 1,423,687
  • CVE chunks (for vector DB): 660,760

File layout

knowledge_graph/
  cves_nodes.json                       # node tables (one per label)
  products_nodes.json
  vendors_nodes.json
  cwes_nodes.json
  capecs_nodes.json
  mitre_techniques_nodes.json
  mitre_tactics_nodes.json
  cve_cwe_relationships.json            # relationship tables
  cve_capec_relationships.json
  cve_mitre_technique_relationships.json
  cve_mitre_tactic_relationships.json
  cve_product_relationships.json
  product_vendor_relationships.json
  product_version_relationships.json
  knowledge_graph_statistics.json       # node + edge counts, severity breakdown

rag_exports/
  cve_chunks.json    # 660,760 chunks — one or two per CVE (description + severity)
  cwe_chunks.json
  capec_chunks.json
  mitre_chunks.json

bm25/
  vocab.json         # {token: {"id": int, "df": int, "idf": float}}

enhanced_documents/
  enhanced_documents_cve_1999.json
  …
  enhanced_documents_cve_2026.json
  enhanced_documents_cve_other.json     # CVEs without a parseable year

Chunk schema (rag_exports/*.json)

Each entry is:

{
  "id": "CVE-2021-44228::desc",
  "kind": "cve_description",
  "text": "Apache Log4j2 2.0-beta9 through 2.15.0 …",
  "payload": {
    "cve_id": "CVE-2021-44228",
    "severity": "CRITICAL",
    "cvss_score": 10.0,
    "cwe_ids": ["CWE-502"],
    "capec_ids": ["CAPEC-242"],
    "mitre_tactics": ["TA0001"],
    "mitre_techniques": ["T1190"],
    "vendors": ["apache"],
    "products": ["log4j"],
    "year": 2021,
    "in_kev": true
  }
}

The payload is intended to be stored directly as the Qdrant point payload (filterable). Lists are kept as native arrays; the ingestion script flattens any that Qdrant cannot index natively.

Installation

1. Pull the data

pip install -U huggingface_hub
huggingface-cli download <HF_USER>/cve-kgrag-db \
  --repo-type dataset \
  --local-dir ./data/knowledge_base

This drops everything under data/knowledge_base/ so paths line up with the CVE-KGRAG codebase defaults.

2. Spin up the backends

Versions below match the stack that produced this dataset; the schema is stable across nearby versions but pin if you want bit-for-bit reproducibility.

# Qdrant 1.17 — what the dataset's sparse-vector / payload schema was tested on
docker run -d -p 6333:6333 -p 6334:6334 \
  -v qdrant_storage:/qdrant/storage \
  qdrant/qdrant:v1.17.0

# Neo4j 5.15 with APOC + GDS (graph-data-science used for optional PageRank)
docker run -d -p 7474:7474 -p 7687:7687 \
  -e NEO4J_AUTH=neo4j/password \
  -e NEO4J_PLUGINS='["apoc","graph-data-science"]' \
  neo4j:5.15

Or docker compose up -d if you grabbed the docker-compose.yml from the upstream codebase.

Python environment

pip install -r scripts/requirements.txt

scripts/requirements.txt pins the versions used to build this dataset:

Package Version
neo4j 6.1.0
qdrant-client 1.17.1
sentence-transformers 5.4.1
transformers 5.5.4
torch 2.5.1 (CUDA 12.1 wheel used in dev)
huggingface_hub 1.11.0
numpy 1.26.4
tqdm 4.67.3

Python 3.11 was used in development. 3.10+ should work.

3. Load each backend

Three options, depending on what you need.

A. Use the provided one-shot scripts (recommended)

The scripts/ folder in this repo contains thin wrappers that download from HF and invoke the loaders:

# Neo4j — bulk MERGE of all nodes + relationships (~10–20 min on SSD)
python scripts/load_neo4j.py \
  --kg-dir ./data/knowledge_base/knowledge_graph \
  --uri bolt://localhost:7687 --user neo4j --password password

# Qdrant — dense (harrier-oss-v1-270m) + sparse (BM25 from vocab.json), with checkpointing
python scripts/load_qdrant.py \
  --kb-dir ./data/knowledge_base \
  --qdrant-url http://localhost:6333

# BM25 only (in-process, no Qdrant) — for plain keyword search
python scripts/load_bm25.py \
  --vocab ./data/knowledge_base/bm25/vocab.json \
  --chunks ./data/knowledge_base/rag_exports/cve_chunks.json \
  --out ./data/knowledge_base/bm25/index.pkl

B. Use the upstream CVE-KGRAG pipeline directly

If you've cloned the CVE-KGRAG repo, just place this dataset at data/knowledge_base/ and run:

python -m src.constructors.neo4j_graph_service --bulk-load
python -m src.generators.rag_system --build   # builds Qdrant collections

C. Bring your own loader

The files are plain JSON. Schemas are documented above. Read them with any client.

4. Verify

# Neo4j
cypher-shell -u neo4j -p password "MATCH (n:CVE) RETURN count(n);"
# expect ~327,574

# Qdrant
curl http://localhost:6333/collections | jq
# expect: cve_chunks, mitre_techniques, capec_patterns, cwe_entries

Reproducing from scratch

If NVD updates and you want a fresh build:

  1. Re-download NVD JSON feeds: scripts/download_all_cves.py
  2. Re-run CWE/CAPEC/MITRE mapping: python -m src.mapper.run_cve_ttp_mapping
  3. Re-export enhanced docs → KG → chunks → vocab via the upstream codebase's src/generators/export_kg_for_rag.py and src/constructors/kg_builder.py.

The slowest step is the LLM-assisted TTP mapping (hours on a single GPU). If you only need re-chunking or re-embedding, start from enhanced_documents/ — they already have the mappings applied, so you skip step 2.

Keeping the dataset fresh — incremental updates

NVD changes daily. The fkie-cad/nvd-json-data-feeds project rebuilds JSON feeds every 2 hours and ships CVE-Recent.json.xz (last 8 days) and CVE-Modified.json.xz (~30 days) as release assets. Rather than re-running the full pipeline, use the included incremental updater:

# Default — pull last 8 days from FKIE, patch enhanced_docs + KG + chunks in place
python scripts/update_from_fkie.py

# Longer catch-up window
python scripts/update_from_fkie.py --feed modified

# Backfill specific years (full per-year file)
python scripts/update_from_fkie.py --feed year --years 2025 2026

# See what would change without writing anything
python scripts/update_from_fkie.py --dry-run

# Cron-friendly: stores FKIE .meta hash in data/knowledge_base/.last_sync.json
# and exits 0 with "nothing to do" if upstream hasn't changed
0 */6 * * * cd /path/to/CVE-KGRAG && python scripts/update_from_fkie.py >> /var/log/cve-kgrag-update.log 2>&1

What it does:

  1. Fetches the FKIE feed and decompresses it (no need to clone their repo).
  2. Converts each CVE record into our enhanced_documents schema using src/mapper/cve_cwe_mapper.py for CWE→CAPEC→TTP (deterministic, no LLM, ~milliseconds per CVE).
  3. Upserts into enhanced_documents_cve_<YEAR>.json only when the CVE's lastModified is newer than ours.
  4. Regenerates cves_nodes.json rows, all relationship JSONs, and cve_chunks.json entries — but only for the touched CVE IDs. Untouched data is preserved byte-for-byte.
  5. Writes state to .last_sync.json so re-runs are no-ops when upstream is unchanged.

What it does not do automatically:

  • Re-encode/re-upsert into Qdrant or Neo4j. After updating, re-run python scripts/load_qdrant.py --kb-dir ./data/knowledge_base (it's checkpointed; it will only encode new chunks) and python scripts/load_neo4j.py --kg-dir ./data/knowledge_base/knowledge_graph (idempotent MERGE).
  • Rebuild BM25 vocab.json. IDFs drift slowly; rebuild on a weekly cadence if you want fresh statistics.
  • Push back to this HF dataset. If you're maintaining your own fork, huggingface-cli upload <your-repo> data/knowledge_base/ will sync it.

This requires the upstream CVE-KGRAG codebase (the script imports src.generators.chunkers and src.mapper.cve_cwe_mapper). A copy of that codebase is bundled in code/ for convenience — see code/README.md for the full project README.

Codebase

The code/ folder contains the full CVE-KGRAG project tree that produced this dataset (119 files, 2.4 MB). It includes:

  • code/src/ — pipeline modules (collectors, processors, mapper, constructors, generators, agents, api, ui, training)
  • code/scripts/ — operational scripts (downloaders, index builders, environment setup)
  • code/llms/ — pluggable LLM backends (OpenAI-compatible, Ollama, vLLM)
  • code/tests/, code/doc/ — tests and reference documentation
  • code/config.py, code/docker-compose.yml, code/requirements.txt, code/.env.example

To run the full project, clone the dataset code folder into a working directory:

huggingface-cli download DuyTa/cve-kgrag-db --repo-type dataset \
  --include "code/*" --local-dir /tmp/cve-kgrag-snapshot
cp -r /tmp/cve-kgrag-snapshot/code/. ./CVE-KGRAG/
cd CVE-KGRAG
cp .env.example .env  # fill in NEO4J_AUTH, LLM_API_KEY, etc.
pip install -r requirements.txt
docker compose up -d

The dataset files (knowledge_graph/, rag_exports/, etc.) belong under CVE-KGRAG/data/knowledge_base/scripts/load_*.py and scripts/update_from_fkie.py expect that layout.

Note: code/ is a snapshot, not the canonical source. For ongoing development, issue tracking, and PRs, refer to the upstream Git repository.

License & attribution

This dataset is a derivative work combining:

The processing pipeline, schemas, and aggregations are released under CC-BY-4.0. Attribute the upstream sources (MITRE in particular) per their terms when republishing.

CVE® is a registered trademark of The MITRE Corporation.

Citation

@misc{cve-kgrag-db-2026,
  title  = {CVE-KGRAG Knowledge Base},
  year   = {2026},
  url    = {https://huggingface.co/datasets/<HF_USER>/cve-kgrag-db}
}
Downloads last month
201