Open-source contrastive embedding stack for mapping technical CVE disclosures to cybersecurity compliance controls (NIST SP 800-53 / CMMC)
Python
0
2 commits
updated Sep 24, 2026
An open-source machine learning framework for mapping technical software vulnerabilities (CVE descriptions) to formal cybersecurity compliance controls (NIST SP 800-53 Rev 5 and CMMC).
Developed by James Pusateri (Middle Coast Software Inc.) and published under the Applied Inference Lab initiative.
Download Technical White Paper (PDF)
Correlating technical vulnerability scans with regulatory compliance frameworks is a persistent operational bottleneck in cybersecurity compliance programs. Technical vulnerability descriptions (such as memory corruption, buffer overflows, or authentication bypasses) inhabit a different vocabulary space than administrative compliance controls (such as flaw remediation, boundary protection, or audit logging).
This repository provides the complete model generation, contrastive fine-tuning, evaluation, and GGUF quantization pipeline developed for AutoRMF. Middle Coast Software Inc. has elected to open source this architecture as a contribution to the cybersecurity and machine learning communities.
Evaluating standard approaches against an isolated 2,000-sample golden validation dataset revealed critical insights that contradict common enterprise search assumptions:
All evaluations were conducted against the full NIST SP 800-53 Rev 5 catalog (1,196 controls) using an isolated 2,000-sample validation dataset.
| Model / Architecture | Strict HR@1 | Strict HR@3 | Strict MRR | Parent HR@1 | Parent HR@3 | Parent MRR |
|---|---|---|---|---|---|---|
| gte-Qwen2-7B-instruct (Zero-Shot) | 0.10% | 0.40% | 0.0030 | 0.40% | 1.10% | 0.0070 |
| bge-large-en-v1.5 (Zero-Shot) | 0.30% | 0.90% | 0.0050 | 8.40% | 18.60% | 0.1270 |
| bge-base-en-v1.5 (Fine-Tuned) | 77.45% | 82.15% | 0.7947 | 81.95% | 87.15% | 0.8422 |
| BGE-Base + Qwen2.5 Reranker | 72.00% | 80.00% | 0.7600 | 82.00% | 86.00% | 0.8400 |
| BGE-Base + BM25 Hybrid (RRF) | 13.65% | 58.10% | 0.3305 | 21.95% | 66.25% | 0.4155 |
├── data/
│ ├── autormf.db # Standalone SQLite database containing control catalogs and mappings
│ ├── golden_validation_set.json # Isolated 2,000-item evaluation benchmark
│ ├── nist_seed.json # NIST SP 800-53 Rev 5 control catalog
│ ├── cwe_seed.json # Common Weakness Enumeration to NIST mappings
│ └── sp800-53r5-control-catalog.csv # Reference control catalog export
├── docs/
│ ├── 10_static_mapping_and_ml_pipeline_design.md
│ ├── 12_model_conversion_guide.md
│ ├── 13_model_retraining_and_overfitting_safeguards.md
│ └── 18_model_training_eval_and_cve_api_summary.md
├── models/
│ └── nist_control_embeddings_cache.json
├── scripts/
│ ├── init_db.py # SQLite database generator from catalog seeds
│ ├── train_embeddings.py # BGE-Base contrastive fine-tuning with MNRL
│ ├── train_qwen_embeddings.py # High-capacity GTE-Qwen2-7B LoRA adapter fine-tuning
│ ├── evaluate_local_model.py # Local evaluation suite for SentenceTransformers
│ ├── evaluate_mappings.py # Comparative evaluation harness for HTTP endpoints
│ ├── test_reranker.py # Local Cross-Encoder and remote LLM reranking testbed
│ ├── test_hybrid_search.py # Dense + BM25 Reciprocal Rank Fusion testbed
│ ├── offline_rag_mapper.py # Batch FAISS vector retrieval script
│ ├── generate_cve_mappings.py # Delta-aware mapping generation pipeline
│ ├── merge_lora.py # LoRA adapter weight merger for GGUF export
│ └── run_eval.ps1 # Automated evaluation runner
├── requirements.txt
├── LICENSE
└── README.md
All scripts require Python 3.10 or later and should be executed within a virtual environment.
On Windows (PowerShell):
python -m venv .venv
.\.venv\Scripts\Activate.ps1
On Linux or macOS:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
If data/autormf.db is present, it is ready for immediate use. To initialize or verify the schema from catalog seed files:
python scripts/init_db.py
To evaluate the fine-tuned model against the 2,000-sample golden validation dataset:
python scripts/evaluate_local_model.py --model-path models/bge-base-en-v1.5-fine-tuned
To run the automated PowerShell evaluation runner:
.\scripts\run_eval.ps1
To reproduce the reranking experiment using a local Cross-Encoder:
python scripts/test_reranker.py local
To test with a remote OpenAI-compatible server hosting an instruction model (such as Qwen2.5-7B-Instruct):
python scripts/test_reranker.py remote --lm-studio-url http://localhost:1234/v1/chat/completions --llm-model-name qwen2.5-7b-instruct
To reproduce the hybrid search experiment demonstrating lexical rank dilution:
python scripts/test_hybrid_search.py --rrf-k 60
python scripts/train_embeddings.py --output-dir models/bge-base-en-v1.5-fine-tuned --epochs 3 --batch-size 8
The script automatically isolates all queries present in data/golden_validation_set.json to prevent evaluation data leakage.
For high-capacity environments (such as machines with unified memory or high-memory GPUs):
python scripts/train_qwen_embeddings.py --output-dir models/gte-qwen2-7b-adjudicated-lora --epochs 3 --batch-size 32
To merge LoRA weights back into the base architecture for export:
python scripts/merge_lora.py --adapter-path models/gte-qwen2-7b-adjudicated-lora --output-path models/gte-qwen2-7b-merged
To convert fine-tuned Hugging Face weights to GGUF format for low-memory, in-process inference via llama.cpp or LLamaSharp:
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
pip install -r requirements-convert-hf-to-gguf.txt
python convert_hf_to_gguf.py ../models/bge-base-en-v1.5-fine-tuned/ --outfile ../models/bge-base-en-v1.5-fine-tuned.gguf
./llama-quantize ../models/bge-base-en-v1.5-fine-tuned.gguf ../models/bge-base-en-v1.5-fine-tuned-q8_0.gguf Q8_0
For comprehensive conversion details, consult docs/12_model_conversion_guide.md.
This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.
Copyright 2026 Middle Coast Software Inc.
2 commits
Python
98.0%
PowerShell
2.0%
Open-source contrastive embedding stack for mapping technical CVE disclosures to cybersecurity compliance controls (NIST SP 800-53 / CMMC)
Python
0
2 commits
updated Sep 24, 2026
An open-source machine learning framework for mapping technical software vulnerabilities (CVE descriptions) to formal cybersecurity compliance controls (NIST SP 800-53 Rev 5 and CMMC).
Developed by James Pusateri (Middle Coast Software Inc.) and published under the Applied Inference Lab initiative.
Download Technical White Paper (PDF)
Correlating technical vulnerability scans with regulatory compliance frameworks is a persistent operational bottleneck in cybersecurity compliance programs. Technical vulnerability descriptions (such as memory corruption, buffer overflows, or authentication bypasses) inhabit a different vocabulary space than administrative compliance controls (such as flaw remediation, boundary protection, or audit logging).
This repository provides the complete model generation, contrastive fine-tuning, evaluation, and GGUF quantization pipeline developed for AutoRMF. Middle Coast Software Inc. has elected to open source this architecture as a contribution to the cybersecurity and machine learning communities.
Evaluating standard approaches against an isolated 2,000-sample golden validation dataset revealed critical insights that contradict common enterprise search assumptions:
All evaluations were conducted against the full NIST SP 800-53 Rev 5 catalog (1,196 controls) using an isolated 2,000-sample validation dataset.
| Model / Architecture | Strict HR@1 | Strict HR@3 | Strict MRR | Parent HR@1 | Parent HR@3 | Parent MRR |
|---|---|---|---|---|---|---|
| gte-Qwen2-7B-instruct (Zero-Shot) | 0.10% | 0.40% | 0.0030 | 0.40% | 1.10% | 0.0070 |
| bge-large-en-v1.5 (Zero-Shot) | 0.30% | 0.90% | 0.0050 | 8.40% | 18.60% | 0.1270 |
| bge-base-en-v1.5 (Fine-Tuned) | 77.45% | 82.15% | 0.7947 | 81.95% | 87.15% | 0.8422 |
| BGE-Base + Qwen2.5 Reranker | 72.00% | 80.00% | 0.7600 | 82.00% | 86.00% | 0.8400 |
| BGE-Base + BM25 Hybrid (RRF) | 13.65% | 58.10% | 0.3305 | 21.95% | 66.25% | 0.4155 |
├── data/
│ ├── autormf.db # Standalone SQLite database containing control catalogs and mappings
│ ├── golden_validation_set.json # Isolated 2,000-item evaluation benchmark
│ ├── nist_seed.json # NIST SP 800-53 Rev 5 control catalog
│ ├── cwe_seed.json # Common Weakness Enumeration to NIST mappings
│ └── sp800-53r5-control-catalog.csv # Reference control catalog export
├── docs/
│ ├── 10_static_mapping_and_ml_pipeline_design.md
│ ├── 12_model_conversion_guide.md
│ ├── 13_model_retraining_and_overfitting_safeguards.md
│ └── 18_model_training_eval_and_cve_api_summary.md
├── models/
│ └── nist_control_embeddings_cache.json
├── scripts/
│ ├── init_db.py # SQLite database generator from catalog seeds
│ ├── train_embeddings.py # BGE-Base contrastive fine-tuning with MNRL
│ ├── train_qwen_embeddings.py # High-capacity GTE-Qwen2-7B LoRA adapter fine-tuning
│ ├── evaluate_local_model.py # Local evaluation suite for SentenceTransformers
│ ├── evaluate_mappings.py # Comparative evaluation harness for HTTP endpoints
│ ├── test_reranker.py # Local Cross-Encoder and remote LLM reranking testbed
│ ├── test_hybrid_search.py # Dense + BM25 Reciprocal Rank Fusion testbed
│ ├── offline_rag_mapper.py # Batch FAISS vector retrieval script
│ ├── generate_cve_mappings.py # Delta-aware mapping generation pipeline
│ ├── merge_lora.py # LoRA adapter weight merger for GGUF export
│ └── run_eval.ps1 # Automated evaluation runner
├── requirements.txt
├── LICENSE
└── README.md
All scripts require Python 3.10 or later and should be executed within a virtual environment.
On Windows (PowerShell):
python -m venv .venv
.\.venv\Scripts\Activate.ps1
On Linux or macOS:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
If data/autormf.db is present, it is ready for immediate use. To initialize or verify the schema from catalog seed files:
python scripts/init_db.py
To evaluate the fine-tuned model against the 2,000-sample golden validation dataset:
python scripts/evaluate_local_model.py --model-path models/bge-base-en-v1.5-fine-tuned
To run the automated PowerShell evaluation runner:
.\scripts\run_eval.ps1
To reproduce the reranking experiment using a local Cross-Encoder:
python scripts/test_reranker.py local
To test with a remote OpenAI-compatible server hosting an instruction model (such as Qwen2.5-7B-Instruct):
python scripts/test_reranker.py remote --lm-studio-url http://localhost:1234/v1/chat/completions --llm-model-name qwen2.5-7b-instruct
To reproduce the hybrid search experiment demonstrating lexical rank dilution:
python scripts/test_hybrid_search.py --rrf-k 60
python scripts/train_embeddings.py --output-dir models/bge-base-en-v1.5-fine-tuned --epochs 3 --batch-size 8
The script automatically isolates all queries present in data/golden_validation_set.json to prevent evaluation data leakage.
For high-capacity environments (such as machines with unified memory or high-memory GPUs):
python scripts/train_qwen_embeddings.py --output-dir models/gte-qwen2-7b-adjudicated-lora --epochs 3 --batch-size 32
To merge LoRA weights back into the base architecture for export:
python scripts/merge_lora.py --adapter-path models/gte-qwen2-7b-adjudicated-lora --output-path models/gte-qwen2-7b-merged
To convert fine-tuned Hugging Face weights to GGUF format for low-memory, in-process inference via llama.cpp or LLamaSharp:
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
pip install -r requirements-convert-hf-to-gguf.txt
python convert_hf_to_gguf.py ../models/bge-base-en-v1.5-fine-tuned/ --outfile ../models/bge-base-en-v1.5-fine-tuned.gguf
./llama-quantize ../models/bge-base-en-v1.5-fine-tuned.gguf ../models/bge-base-en-v1.5-fine-tuned-q8_0.gguf Q8_0
For comprehensive conversion details, consult docs/12_model_conversion_guide.md.
This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.
Copyright 2026 Middle Coast Software Inc.
2 commits
Python
98.0%
PowerShell
2.0%