Update model card with full Plan A details and results
Browse files
README.md
CHANGED
|
@@ -1,202 +1,166 @@
|
|
| 1 |
---
|
| 2 |
base_model: mistralai/Mixtral-8x7B-Instruct-v0.1
|
| 3 |
library_name: peft
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
-
#
|
| 7 |
|
| 8 |
-
|
| 9 |
|
|
|
|
| 10 |
|
|
|
|
| 11 |
|
| 12 |
-
##
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
- **Funded by [optional]:** [More Information Needed]
|
| 22 |
-
- **Shared by [optional]:** [More Information Needed]
|
| 23 |
-
- **Model type:** [More Information Needed]
|
| 24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
| 25 |
-
- **License:** [More Information Needed]
|
| 26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
|
| 31 |
|
| 32 |
-
|
| 33 |
-
- **Paper [optional]:** [More Information Needed]
|
| 34 |
-
- **Demo [optional]:** [More Information Needed]
|
| 35 |
|
| 36 |
-
|
| 37 |
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
-
##
|
| 41 |
|
| 42 |
-
|
| 43 |
|
| 44 |
-
|
| 45 |
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
-
|
| 49 |
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
-
###
|
| 53 |
|
| 54 |
-
|
| 55 |
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
-
|
| 59 |
|
| 60 |
-
|
| 61 |
|
| 62 |
-
|
|
|
|
|
|
|
| 63 |
|
| 64 |
-
##
|
| 65 |
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
-
|
|
|
|
| 69 |
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
-
|
|
|
|
|
|
|
| 73 |
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
-
|
|
|
|
| 77 |
|
| 78 |
-
###
|
|
|
|
| 79 |
|
| 80 |
-
|
|
|
|
| 81 |
|
| 82 |
-
|
|
|
|
| 83 |
|
| 84 |
-
|
|
|
|
|
|
|
| 85 |
|
| 86 |
-
|
|
|
|
| 87 |
|
| 88 |
-
##
|
| 89 |
|
| 90 |
-
|
|
|
|
|
|
|
| 91 |
|
|
|
|
| 92 |
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 96 |
-
|
| 97 |
-
#### Speeds, Sizes, Times [optional]
|
| 98 |
-
|
| 99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 100 |
-
|
| 101 |
-
[More Information Needed]
|
| 102 |
-
|
| 103 |
-
## Evaluation
|
| 104 |
-
|
| 105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 106 |
-
|
| 107 |
-
### Testing Data, Factors & Metrics
|
| 108 |
-
|
| 109 |
-
#### Testing Data
|
| 110 |
-
|
| 111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
| 112 |
-
|
| 113 |
-
[More Information Needed]
|
| 114 |
-
|
| 115 |
-
#### Factors
|
| 116 |
-
|
| 117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 118 |
-
|
| 119 |
-
[More Information Needed]
|
| 120 |
-
|
| 121 |
-
#### Metrics
|
| 122 |
-
|
| 123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 124 |
-
|
| 125 |
-
[More Information Needed]
|
| 126 |
-
|
| 127 |
-
### Results
|
| 128 |
-
|
| 129 |
-
[More Information Needed]
|
| 130 |
-
|
| 131 |
-
#### Summary
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
## Model Examination [optional]
|
| 136 |
-
|
| 137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
| 138 |
-
|
| 139 |
-
[More Information Needed]
|
| 140 |
-
|
| 141 |
-
## Environmental Impact
|
| 142 |
-
|
| 143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 144 |
-
|
| 145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 146 |
-
|
| 147 |
-
- **Hardware Type:** [More Information Needed]
|
| 148 |
-
- **Hours used:** [More Information Needed]
|
| 149 |
-
- **Cloud Provider:** [More Information Needed]
|
| 150 |
-
- **Compute Region:** [More Information Needed]
|
| 151 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
-
|
| 153 |
-
## Technical Specifications [optional]
|
| 154 |
-
|
| 155 |
-
### Model Architecture and Objective
|
| 156 |
-
|
| 157 |
-
[More Information Needed]
|
| 158 |
-
|
| 159 |
-
### Compute Infrastructure
|
| 160 |
-
|
| 161 |
-
[More Information Needed]
|
| 162 |
-
|
| 163 |
-
#### Hardware
|
| 164 |
-
|
| 165 |
-
[More Information Needed]
|
| 166 |
-
|
| 167 |
-
#### Software
|
| 168 |
-
|
| 169 |
-
[More Information Needed]
|
| 170 |
-
|
| 171 |
-
## Citation [optional]
|
| 172 |
-
|
| 173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 174 |
-
|
| 175 |
-
**BibTeX:**
|
| 176 |
-
|
| 177 |
-
[More Information Needed]
|
| 178 |
-
|
| 179 |
-
**APA:**
|
| 180 |
-
|
| 181 |
-
[More Information Needed]
|
| 182 |
-
|
| 183 |
-
## Glossary [optional]
|
| 184 |
-
|
| 185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 186 |
-
|
| 187 |
-
[More Information Needed]
|
| 188 |
-
|
| 189 |
-
## More Information [optional]
|
| 190 |
-
|
| 191 |
-
[More Information Needed]
|
| 192 |
-
|
| 193 |
-
## Model Card Authors [optional]
|
| 194 |
-
|
| 195 |
-
[More Information Needed]
|
| 196 |
-
|
| 197 |
-
## Model Card Contact
|
| 198 |
-
|
| 199 |
-
[More Information Needed]
|
| 200 |
-
### Framework versions
|
| 201 |
-
|
| 202 |
-
- PEFT 0.11.1
|
|
|
|
| 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`).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|