umer07 commited on
Commit
98f445d
Β·
verified Β·
1 Parent(s): b240494

Fathom: update model card with full benchmark results

Browse files
Files changed (1) hide show
  1. README.md +126 -111
README.md CHANGED
@@ -1,166 +1,181 @@
1
  ---
 
 
 
2
  base_model: mistralai/Mixtral-8x7B-Instruct-v0.1
3
- library_name: peft
4
  tags:
5
  - cybersecurity
6
  - malware-analysis
7
- - peft
8
  - lora
9
- - qlora
10
  - mixtral
11
- language:
12
- - en
13
  pipeline_tag: text-generation
14
- license: apache-2.0
15
  ---
16
 
17
- # Fathom Plan A LoRA Adapter (Mixtral-8x7B-Instruct)
18
-
19
- This repository contains the **Plan A** LoRA adapter for the Fathom FYP project:
20
-
21
- **"Fathom: An LLM-Powered Automated Malware Analysis Framework"**
22
 
23
- The adapter is trained on a curated cybersecurity instruction-tuning corpus to improve analyst-style security outputs over the base `mistralai/Mixtral-8x7B-Instruct-v0.1` model.
24
 
25
- ## What This Is
26
 
27
- - **Type:** PEFT LoRA adapter (not a full standalone model)
28
- - **Base model required:** `mistralai/Mixtral-8x7B-Instruct-v0.1`
29
- - **Training style:** QLoRA (4-bit NF4 base loading, bf16 compute)
30
- - **Scope:** Plan A MVP uplift for cybersecurity and malware-analysis assistance
31
-
32
- ## Key Training Setup
33
-
34
- - **Sequence length:** 2048
35
- - **Batch:** 2
36
- - **Gradient accumulation:** 8 (effective 16)
37
- - **Learning rate:** 2e-4 (cosine scheduler)
38
- - **Steps:** 3000 (completed run)
39
- - **LoRA rank/alpha:** r=32, alpha=64
40
- - **LoRA targets:** `q_proj`, `k_proj`, `v_proj`, `o_proj` (attention-only)
41
- - **Optimizer:** paged_adamw_8bit
42
- - **Precision:** bf16
43
-
44
- ## Hardware Used
45
-
46
- Training was run on RunPod:
47
-
48
- - **GPU:** NVIDIA A100 PCIe 80GB (1x)
49
- - **vCPU:** 8
50
- - **RAM:** 125 GB
51
- - **Disk:** 200 GB
52
- - **Location:** CA
53
 
54
- ## Data Summary
55
 
56
- Curated cybersecurity instruction corpus with mixed sources (CyberMetric, Trendyol CyberSec, ShareGPT Cybersecurity, NIST downsampled, MITRE ATT&CK, CVE/IR/malware-focused sets).
 
 
 
 
 
 
 
57
 
58
- Final working files used:
59
 
60
- - `train.jsonl`: 120,912 samples
61
- - `eval.jsonl`: 1,915 samples
62
- - `cybermetric_80.jsonl`: 80 held-out MCQs
63
- - `malware_eval_25.jsonl`: 25 expert malware prompts
 
 
 
 
 
 
 
 
 
 
64
 
65
- ## Evaluation Results
66
 
67
- ### Standard post-eval settings
68
 
69
- Generation settings used for fair base-vs-adapter comparison:
70
 
71
- - `do_sample=False`
72
- - `temperature=0.0`
73
- - `max_new_eval=64`
74
- - `max_new_cyber=48`
75
- - `max_new_malware=256`
76
 
77
- #### Baseline (corrected) vs Fine-tuned
 
 
 
 
 
 
 
 
 
 
 
78
 
79
- | Metric | Baseline | Fine-tuned | Delta |
80
- |---|---:|---:|---:|
81
- | Eval mean overlap | 0.3283 | 0.3631 | +0.0349 |
82
- | Eval exact match rate | 0.0000 | 0.2193 | +0.2193 |
83
- | CyberMetric-80 accuracy | 0.825 | 0.900 | +0.075 |
84
- | Malware structure | 0.44 | 0.84 | +0.40 |
85
- | Malware ATT&CK correctness | 0.16 | 0.20 | +0.04 |
86
- | Malware reasoning | 0.24 | 0.20 | -0.04 |
87
- | Malware evidence awareness | 0.48 | 0.52 | +0.04 |
88
- | Malware analyst usefulness | 0.52 | 0.56 | +0.04 |
89
 
90
- ### Malware-only rerun with longer output budget
 
 
 
 
 
 
91
 
92
- To test truncation effects on malware prompts, both base and fine-tuned were rerun with `max_new_malware=512` (25 prompts only).
93
 
94
- | Rubric axis | Base (512) | Fine-tuned (512) | Delta |
95
- |---|---:|---:|---:|
96
- | Structure | 0.56 | 0.88 | +0.32 |
97
- | ATT&CK correctness | 0.16 | 0.20 | +0.04 |
98
- | Malware reasoning | 0.36 | 0.28 | -0.08 |
99
- | Evidence awareness | 0.56 | 0.64 | +0.08 |
100
- | Analyst usefulness | 0.64 | 0.80 | +0.16 |
101
 
102
- Interpretation: structure/evidence/usefulness improved strongly, but malware reasoning remains the main gap for future iterations.
103
 
104
- ## Limitations
 
 
 
 
105
 
106
- - This is a **Plan A MVP adapter**, not a fully specialized malware reverse-engineering model.
107
- - Malware causal reasoning still needs improvement via targeted data and/or evidence-grounded training (Plan B).
108
- - Outputs should be treated as analyst assistance, not an autonomous verdict.
109
 
110
  ## Usage
111
 
112
  ```python
113
- import torch
114
- from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
115
  from peft import PeftModel
 
116
 
117
- base_model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
118
- adapter_repo = "umer07/fathom-mixtral-lora-plan-a"
119
-
120
- bnb_config = BitsAndBytesConfig(
121
- load_in_4bit=True,
122
- bnb_4bit_quant_type="nf4",
123
- bnb_4bit_use_double_quant=True,
124
- bnb_4bit_compute_dtype=torch.bfloat16,
125
- )
126
-
127
- tokenizer = AutoTokenizer.from_pretrained(base_model_id, use_fast=True)
128
- if tokenizer.pad_token is None:
129
- tokenizer.pad_token = tokenizer.eos_token
130
 
 
131
  model = AutoModelForCausalLM.from_pretrained(
132
- base_model_id,
133
- quantization_config=bnb_config,
134
- device_map={"": 0},
135
  torch_dtype=torch.bfloat16,
136
- low_cpu_mem_usage=True,
137
  )
138
-
139
- model = PeftModel.from_pretrained(model, adapter_repo)
140
  model.eval()
141
 
142
  prompt = """### Instruction:
143
- Analyze the malware behavior and map likely ATT&CK techniques.
 
144
 
145
  ### Input:
146
- Sample creates scheduled task persistence and launches encoded PowerShell.
 
 
 
147
 
148
- ### Response:
149
- """
150
 
151
  inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
152
  with torch.inference_mode():
153
- out = model.generate(**inputs, max_new_tokens=512, do_sample=False, temperature=0.0)
154
-
155
  print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
156
  ```
157
 
158
- ## Project Status
 
 
 
 
159
 
160
- - Core Plan A training/evaluation cycle: **completed**
161
- - GPU instance used for training has been deleted
162
- - No additional training is currently in progress
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
 
164
  ## Citation
165
 
166
- If you use this adapter, please cite your project report/thesis for Fathom Plan A and reference the base model (`mistralai/Mixtral-8x7B-Instruct-v0.1`).
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - en
4
+ license: apache-2.0
5
  base_model: mistralai/Mixtral-8x7B-Instruct-v0.1
 
6
  tags:
7
  - cybersecurity
8
  - malware-analysis
 
9
  - lora
10
+ - peft
11
  - mixtral
12
+ - threat-intelligence
13
+ - security
14
  pipeline_tag: text-generation
 
15
  ---
16
 
17
+ # Fathom β€” Cybersecurity Expert LLM
 
 
 
 
18
 
19
+ **Fathom** is a mixture-of-experts cybersecurity analysis system built on [Mixtral-8x7B-Instruct-v0.1](https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1) with 10 domain-specific LoRA adapters. Each adapter is fine-tuned on a curated cybersecurity dataset for a specific analysis domain, enabling specialized reasoning across the full malware analysis pipeline.
20
 
21
+ > **FYP (Final Year Project)** β€” Muhammad Haseeb, i221698
22
 
23
+ ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
+ ## Model Architecture
26
 
27
+ | Component | Details |
28
+ |---|---|
29
+ | Base Model | Mixtral-8x7B-Instruct-v0.1 (MoE, 47B params, 8Γ—7B experts) |
30
+ | Fine-tuning | LoRA (rank=32, alpha=64, dropout=0.05) |
31
+ | Precision | BFloat16 full precision (no quantization) |
32
+ | Training Hardware | AMD MI300X VF (205.8 GB VRAM), ROCm 7.0 |
33
+ | Framework | PEFT + TRL (SFTTrainer), Alpaca instruction format |
34
+ | Adapter Count | 10 (1 unified + 9 domain experts) |
35
 
36
+ ---
37
 
38
+ ## Adapters
39
+
40
+ | Adapter | Domain | Training Examples | Description |
41
+ |---|---|---|---|
42
+ | `unified-v2` *(root)* | General Cybersecurity | 9,000+ | Unified adapter across all domains β€” use as default |
43
+ | `adapters/expert-e1-static` | Static Analysis | 2,500+ | PE analysis, YARA rules, entropy, imports |
44
+ | `adapters/expert-e2-dynamic` | Dynamic / Behavioral | 2,500+ | API call sequences, sandbox reports, process injection |
45
+ | `adapters/expert-e3-network` | Network Analysis | 2,000+ | C2 detection, DNS/HTTP IOC analysis, traffic patterns |
46
+ | `adapters/expert-e4-forensics` | Digital Forensics | 2,000+ | Memory forensics, artifact analysis, timeline reconstruction |
47
+ | `adapters/expert-e5-threatintel` | Threat Intelligence | 9,532 | APT attribution, MITRE ATT&CK mapping, IOC enrichment |
48
+ | `adapters/expert-e6-detection` | Detection Engineering | 2,000+ | YARA, Sigma, Snort rule generation |
49
+ | `adapters/expert-e7-reports` | Report Generation | 2,000+ | Structured incident reports, executive summaries |
50
+ | `adapters/expert-e8-analyst` | Analyst Assistance | 2,000+ | Triage, prioritization, analyst Q&A |
51
+ | `adapters/expert-e9-cot` | Chain-of-Thought | 2,000+ | Step-by-step reasoning for complex analysis tasks |
52
 
53
+ ---
54
 
55
+ ## Benchmark Results
56
 
57
+ All evaluations run on AMD MI300X (ROCm 7.0), bf16 full precision, greedy decode (temperature=0).
58
 
59
+ ### CyberMetric-80 (Multiple Choice β€” Cybersecurity Knowledge)
 
 
 
 
60
 
61
+ | Adapter | Accuracy |
62
+ |---|---|
63
+ | **unified-v2** | **91.25%** |
64
+ | expert-e8-analyst | 91.25% |
65
+ | expert-e3-network | 90.00% |
66
+ | expert-e4-forensics | 90.00% |
67
+ | expert-e2-dynamic | 85.00% |
68
+ | expert-e9-cot | 87.50% |
69
+ | expert-e7-reports | 88.75% |
70
+ | expert-e6-detection | 88.75% |
71
+ | expert-e1-static | 83.75% |
72
+ | expert-e5-threatintel | 81.25% |
73
 
74
+ ### Malware Analysis Rubric (25 open-ended samples, scored 0–1)
 
 
 
 
 
 
 
 
 
75
 
76
+ | Metric | unified-v2 | Best Expert |
77
+ |---|---|---|
78
+ | Structure | 0.96 | 0.96 (e5, e7) |
79
+ | MITRE ATT&CK Correctness | 0.20 | 0.20 (e3, e4, e6) |
80
+ | Malware Reasoning | 0.24 | 0.32 (e9-cot) |
81
+ | Evidence Awareness | 0.68 | 1.00 (e2-dynamic) |
82
+ | Analyst Usefulness | 0.84 | 0.88 (e1, e3, e7) |
83
 
84
+ ### MMLU Cybersecurity (unified-v2)
85
 
86
+ | Benchmark | Questions | Accuracy |
87
+ |---|---|---|
88
+ | MMLU Computer Security | 100 | **79.0%** |
89
+ | MMLU Security Studies | 100 | **64.0%** |
90
+ | TruthfulQA MC1 | 100 | **65.0%** |
 
 
91
 
92
+ ### Q&A Eval β€” Fathom Cybersecurity Dataset (200 samples, unified-v2)
93
 
94
+ | Metric | Score |
95
+ |---|---|
96
+ | Token Overlap (ROUGE-like) | 0.467 |
97
+ | Exact Match Rate | 1.5% |
98
+ | Mean Throughput | 15.5 tok/s |
99
 
100
+ ---
 
 
101
 
102
  ## Usage
103
 
104
  ```python
105
+ from transformers import AutoModelForCausalLM, AutoTokenizer
 
106
  from peft import PeftModel
107
+ import torch
108
 
109
+ BASE_MODEL = "mistralai/Mixtral-8x7B-Instruct-v0.1"
110
+ ADAPTER = "umer07/fathom-mixtral" # unified-v2 (default)
111
+ # For expert: "umer07/fathom-mixtral/adapters/expert-e2-dynamic"
 
 
 
 
 
 
 
 
 
 
112
 
113
+ tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL, use_fast=True)
114
  model = AutoModelForCausalLM.from_pretrained(
115
+ BASE_MODEL,
116
+ device_map="auto",
 
117
  torch_dtype=torch.bfloat16,
 
118
  )
119
+ model = PeftModel.from_pretrained(model, ADAPTER)
 
120
  model.eval()
121
 
122
  prompt = """### Instruction:
123
+ Analyze this CAPEv2 sandbox report excerpt and identify the malware family,
124
+ behavioral patterns, and MITRE ATT&CK techniques.
125
 
126
  ### Input:
127
+ File: suspicious.exe | CAPE Malscore: 9.5/10
128
+ API Calls: CreateFileW, WriteProcessMemory, CreateRemoteThread, RegSetValueExW
129
+ DNS: update.microsoft-cdn.net, api.telemetry-svc.com
130
+ Registry: HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\SvcHost32
131
 
132
+ ### Response:"""
 
133
 
134
  inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
135
  with torch.inference_mode():
136
+ out = model.generate(**inputs, max_new_tokens=512, do_sample=False)
 
137
  print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
138
  ```
139
 
140
+ ---
141
+
142
+ ## Fathom Pipeline
143
+
144
+ The full Fathom system includes:
145
 
146
+ 1. **CAPEv2 Extraction Layer** β€” parses sandbox JSON reports into structured evidence
147
+ 2. **Domain Classifier** β€” sentence-transformer embeddings β†’ cosine similarity β†’ adapter selection
148
+ 3. **RAG Retriever** β€” FAISS index of domain knowledge (on `umer07/fathom-expert-data`)
149
+ 4. **Expert Adapter Registry** β€” loads the appropriate LoRA adapter per query
150
+ 5. **Prompt Templates** β€” domain-specific instruction prompts per expert
151
+ 6. **Guardrails** β€” output filtering for hallucination / harmful content
152
+ 7. **Inference Engine** β€” unified generation with adapter hot-swap
153
+ 8. **FastAPI Backend** β€” REST API for integration
154
+
155
+ ---
156
+
157
+ ## Training Data
158
+
159
+ Training datasets are published at [umer07/fathom-expert-data](https://huggingface.co/datasets/umer07/fathom-expert-data).
160
+
161
+ Sources include:
162
+ - CAPE sandbox reports (real malware execution data)
163
+ - URLhaus threat feed (malicious URL classification)
164
+ - Atomic Red Team ATT&CK simulations
165
+ - GTFOBins living-off-the-land binaries
166
+ - MITRE ATT&CK STIX bundles
167
+ - CyberMetric, SecQA, and curated cybersecurity QA pairs
168
+ - LOLBAS project
169
+
170
+ ---
171
 
172
  ## Citation
173
 
174
+ ```
175
+ @misc{fathom2026,
176
+ title = {Fathom: A Mixture-of-Expert LLM Framework for Cybersecurity Analysis},
177
+ author = {Muhammad Haseeb},
178
+ year = {2026},
179
+ note = {Final Year Project, FAST-NUCES}
180
+ }
181
+ ```