Text Generation
Transformers
Safetensors
PEFT
English
qwen3
cybersecurity
cti
cwe-classification
vulnerability-analysis
security
lora
amd
rocm
mi300x
flash-attention-2
conversational
Eval Results (legacy)
text-generation-inference
Instructions to use lablab-ai-amd-developer-hackathon/CyberSecQwen-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lablab-ai-amd-developer-hackathon/CyberSecQwen-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="lablab-ai-amd-developer-hackathon/CyberSecQwen-4B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("lablab-ai-amd-developer-hackathon/CyberSecQwen-4B") model = AutoModelForCausalLM.from_pretrained("lablab-ai-amd-developer-hackathon/CyberSecQwen-4B") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - PEFT
How to use lablab-ai-amd-developer-hackathon/CyberSecQwen-4B with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use lablab-ai-amd-developer-hackathon/CyberSecQwen-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "lablab-ai-amd-developer-hackathon/CyberSecQwen-4B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lablab-ai-amd-developer-hackathon/CyberSecQwen-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/lablab-ai-amd-developer-hackathon/CyberSecQwen-4B
- SGLang
How to use lablab-ai-amd-developer-hackathon/CyberSecQwen-4B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "lablab-ai-amd-developer-hackathon/CyberSecQwen-4B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lablab-ai-amd-developer-hackathon/CyberSecQwen-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "lablab-ai-amd-developer-hackathon/CyberSecQwen-4B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lablab-ai-amd-developer-hackathon/CyberSecQwen-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use lablab-ai-amd-developer-hackathon/CyberSecQwen-4B with Docker Model Runner:
docker model run hf.co/lablab-ai-amd-developer-hackathon/CyberSecQwen-4B
Commit ·
c755f5d
0
Parent(s):
Duplicate from athena129/CyberSecQwen-4B
Browse files- .gitattributes +36 -0
- README.md +323 -0
- chat_template.jinja +7 -0
- config.json +71 -0
- generation_config.json +13 -0
- model.safetensors +3 -0
- tokenizer.json +3 -0
- tokenizer_config.json +30 -0
.gitattributes
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
library_name: transformers
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
base_model: Qwen/Qwen3-4B-Instruct-2507
|
| 6 |
+
tags:
|
| 7 |
+
- cybersecurity
|
| 8 |
+
- cti
|
| 9 |
+
- cwe-classification
|
| 10 |
+
- vulnerability-analysis
|
| 11 |
+
- security
|
| 12 |
+
- lora
|
| 13 |
+
- peft
|
| 14 |
+
- amd
|
| 15 |
+
- rocm
|
| 16 |
+
- mi300x
|
| 17 |
+
- flash-attention-2
|
| 18 |
+
language:
|
| 19 |
+
- en
|
| 20 |
+
metrics:
|
| 21 |
+
- accuracy
|
| 22 |
+
model-index:
|
| 23 |
+
- name: CyberSecQwen-4B
|
| 24 |
+
results:
|
| 25 |
+
- task:
|
| 26 |
+
type: text-classification
|
| 27 |
+
name: CWE Classification (CTI-RCM)
|
| 28 |
+
dataset:
|
| 29 |
+
name: CTI-Bench
|
| 30 |
+
type: cti-bench
|
| 31 |
+
split: cti-rcm
|
| 32 |
+
metrics:
|
| 33 |
+
- type: accuracy
|
| 34 |
+
value: 0.6664
|
| 35 |
+
name: strict_acc (5-trial mean)
|
| 36 |
+
verified: false
|
| 37 |
+
- task:
|
| 38 |
+
type: multiple-choice
|
| 39 |
+
name: Cyber Threat Intel Multiple Choice (CTI-MCQ)
|
| 40 |
+
dataset:
|
| 41 |
+
name: CTI-Bench
|
| 42 |
+
type: cti-bench
|
| 43 |
+
split: cti-mcq
|
| 44 |
+
metrics:
|
| 45 |
+
- type: accuracy
|
| 46 |
+
value: 0.5868
|
| 47 |
+
name: strict_acc (5-trial mean)
|
| 48 |
+
verified: false
|
| 49 |
+
---
|
| 50 |
+
|
| 51 |
+
# CyberSecQwen-4B — Model Card
|
| 52 |
+
|
| 53 |
+
## Model Information
|
| 54 |
+
|
| 55 |
+
CyberSecQwen-4B is a 4B-parameter language model specialized for defensive cybersecurity tasks, fine-tuned from [Qwen3-4B-Instruct-2507](https://huggingface.co/Qwen/Qwen3-4B-Instruct-2507). It is purpose-built for two evaluation skills measured by [CTI-Bench](https://github.com/xashru/cti-bench): mapping CVE descriptions to their CWE category (CTI-RCM) and answering cyber threat intelligence multiple-choice questions (CTI-MCQ).
|
| 56 |
+
|
| 57 |
+
Under the evaluation protocol of [Foundation-Sec-8B (arXiv:2504.21039)](https://arxiv.org/abs/2504.21039), CyberSecQwen-4B retains **97.3% of Foundation-Sec-Instruct-8B's CTI-RCM accuracy** while exceeding its CTI-MCQ by **+8.7 points**, at half the parameter count.
|
| 58 |
+
|
| 59 |
+
The full training, merge, and evaluation pipeline runs end-to-end on a single AMD Instinct MI300X 192GB instance using ROCm + vLLM + FlashAttention-2. A companion model trained with the same recipe on Gemma-4-E2B-it — [Gemma4Defense-2B](https://huggingface.co/athena129/Gemma4Defense-2B) — converges to the same CTI-RCM accuracy within 0.9 points (0.6754 vs 0.6664), demonstrating that the result is recipe-driven rather than substrate-specific.
|
| 60 |
+
|
| 61 |
+
| | |
|
| 62 |
+
|---|---|
|
| 63 |
+
| Base model | Qwen/Qwen3-4B-Instruct-2507 |
|
| 64 |
+
| Parameters | 4.0B total (3.6B non-embedding) |
|
| 65 |
+
| Architecture | Qwen3 (RoPE, GQA 32:8, head_dim=128, 36 layers) |
|
| 66 |
+
| Context length | 32,768 native |
|
| 67 |
+
| Adapter | LoRA r=64, alpha=64, dropout=0.05 |
|
| 68 |
+
| Precision | bfloat16 |
|
| 69 |
+
| Languages | English |
|
| 70 |
+
| License | Apache 2.0 |
|
| 71 |
+
|
| 72 |
+
## Intended Use
|
| 73 |
+
|
| 74 |
+
### Intended Use Cases
|
| 75 |
+
|
| 76 |
+
CyberSecQwen-4B is intended for security practitioners, researchers, and engineers working on:
|
| 77 |
+
|
| 78 |
+
- **CWE classification** — mapping vulnerability descriptions (CVEs, advisories) to MITRE CWE categories
|
| 79 |
+
- **Cyber threat intelligence Q&A** — answering structured questions about cybersecurity concepts, attacks, controls
|
| 80 |
+
- **Defensive analysis assistants** — supporting human analysts who triage CVEs, prioritize patches, or document threat-actor behavior
|
| 81 |
+
- **Cybersecurity benchmarking on AMD hardware** — as a reference fine-tune for the AMD MI300X stack and a comparator for compact-model performance on CTI-Bench
|
| 82 |
+
|
| 83 |
+
### Downstream Use
|
| 84 |
+
|
| 85 |
+
The model can be used as a building block in:
|
| 86 |
+
|
| 87 |
+
- Security operations center (SOC) ticket triage tools that suggest a likely CWE for an incoming CVE
|
| 88 |
+
- Vulnerability management dashboards that pre-classify CVE feeds before human review
|
| 89 |
+
- Internal cyber knowledge bases / chat assistants for security teams
|
| 90 |
+
- Reference deployments demonstrating CTI workloads on AMD MI300X via vLLM ROCm
|
| 91 |
+
|
| 92 |
+
### Out-of-Scope Use
|
| 93 |
+
|
| 94 |
+
The following uses are out-of-scope and are neither recommended nor intended use cases:
|
| 95 |
+
|
| 96 |
+
1. **Generating harmful content** — the model must not be used to produce exploit code, weaponized proof-of-concept payloads, attacker tradecraft, or instructions that materially aid offensive operations.
|
| 97 |
+
2. **Critical security decisions without human oversight** — the model should not auto-execute remediation, blocklist updates, account lockouts, or any action whose reversal carries cost; outputs are advisory and require qualified human review.
|
| 98 |
+
3. **Legal or medical advice** — the model is trained on cybersecurity domain content and is not appropriate for legal, medical, or other regulated-advice contexts.
|
| 99 |
+
4. **Non-security use cases** — general chat, code generation, summarization, translation, or other domains outside its specialization will produce lower-quality output than purpose-built models.
|
| 100 |
+
5. **Violation of laws or regulations** — including but not limited to unauthorized vulnerability scanning, illegal data access, or misuse contrary to applicable cybersecurity statutes (CFAA, GDPR, etc.).
|
| 101 |
+
|
| 102 |
+
## Hardware Requirements
|
| 103 |
+
|
| 104 |
+
The numbers below are first-principles estimates from the bf16 weight footprint plus typical KV-cache overhead at the trained 4096-token context. They are not measured throughput numbers; for production deployment, profile against your specific traffic pattern.
|
| 105 |
+
|
| 106 |
+
| Specification | CyberSecQwen-4B | Foundation-Sec-Instruct-8B (reference) |
|
| 107 |
+
|---|---|---|
|
| 108 |
+
| Parameters (total / non-embedding) | 4.0 B / 3.6 B | 8 B |
|
| 109 |
+
| bf16 weight file on disk | ~8.0 GB | ~16 GB |
|
| 110 |
+
| Inference VRAM, weights only (bf16) | ~8 GB | ~16 GB |
|
| 111 |
+
| Inference VRAM, weights + 4 K KV cache (bf16) | ~9–10 GB | ~17–18 GB |
|
| 112 |
+
| Single-GPU class (bf16, headroom for batch ≥ 1) | Fits on 12 GB+ consumer GPU (e.g., RTX 3060 12 GB, RTX 4070 12 GB, T4 16 GB) | Typically requires 24 GB+ (e.g., RTX 4090, A10, A100 40 GB) |
|
| 113 |
+
| AMD Instinct MI300X 192 GB (validated) | Fits trivially with very large batch / long context | Fits trivially |
|
| 114 |
+
|
| 115 |
+
Notes:
|
| 116 |
+
- Compute (FLOPs / token) is approximately proportional to the parameter count at fixed context length, so per-token inference cost is roughly **0.50×** that of an 8 B model.
|
| 117 |
+
- Quantized variants (int8, int4) further reduce VRAM by ~½ and ~¼ respectively. The released checkpoint is bf16 only; community quantization is not validated by the authors of this release.
|
| 118 |
+
- This model has been validated end-to-end on AMD Instinct MI300X via vLLM ROCm + FlashAttention-2; consult the "How to Get Started" section below for the exact serving command on AMD hardware.
|
| 119 |
+
|
| 120 |
+
## How to Get Started with the Model
|
| 121 |
+
|
| 122 |
+
```python
|
| 123 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 124 |
+
import torch
|
| 125 |
+
|
| 126 |
+
model_id = "athena129/CyberSecQwen-4B"
|
| 127 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 128 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 129 |
+
model_id,
|
| 130 |
+
torch_dtype=torch.bfloat16,
|
| 131 |
+
device_map="auto",
|
| 132 |
+
)
|
| 133 |
+
|
| 134 |
+
cve = ("A deserialization vulnerability in the destruct() function of Laravel "
|
| 135 |
+
"v8.5.9 allows attackers to execute arbitrary commands.")
|
| 136 |
+
|
| 137 |
+
messages = [{
|
| 138 |
+
"role": "user",
|
| 139 |
+
"content": (
|
| 140 |
+
"Analyze the following CVE description and map it to the appropriate CWE. "
|
| 141 |
+
"Provide a brief justification for your choice. "
|
| 142 |
+
"Ensure the last line of your response contains only the CWE ID.\n\n"
|
| 143 |
+
f"CVE Description: {cve}"
|
| 144 |
+
),
|
| 145 |
+
}]
|
| 146 |
+
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 147 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 148 |
+
output = model.generate(**inputs, max_new_tokens=256, temperature=0.3, do_sample=True)
|
| 149 |
+
print(tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
|
| 150 |
+
```
|
| 151 |
+
|
| 152 |
+
### Serving via vLLM on AMD MI300X
|
| 153 |
+
|
| 154 |
+
```bash
|
| 155 |
+
docker run --rm --network=host --device=/dev/kfd --device=/dev/dri \
|
| 156 |
+
-e VLLM_ROCM_USE_AITER=1 -e TORCH_BLAS_PREFER_HIPBLASLT=1 \
|
| 157 |
+
vllm/vllm-openai-rocm:latest \
|
| 158 |
+
--model athena129/CyberSecQwen-4B \
|
| 159 |
+
--served-model-name cybersecqwen-4b \
|
| 160 |
+
--attention-backend TRITON_ATTN \
|
| 161 |
+
--dtype bfloat16 \
|
| 162 |
+
--max-model-len 4096 \
|
| 163 |
+
--gpu-memory-utilization 0.9
|
| 164 |
+
```
|
| 165 |
+
|
| 166 |
+
## Training and Evaluation
|
| 167 |
+
|
| 168 |
+
### Training Data
|
| 169 |
+
|
| 170 |
+
The model was trained on a combined cybersecurity corpus of approximately **14,776 supervised records**:
|
| 171 |
+
|
| 172 |
+
- **CTI-RCM 2021 (decontaminated)** — CVE → CWE classification examples drawn from MITRE/NVD public records dated 2021. Items appearing in the CTI-Bench evaluation splits were explicitly removed prior to training. (~6,776 records)
|
| 173 |
+
- **CVE / CTI synthetic Q&A** — defensive-analyst-style cyber question–answer pairs grounded in CVE descriptions. (~8,000 records)
|
| 174 |
+
|
| 175 |
+
Decontamination matters here: an earlier internal version of this work showed roughly 72% test-set overlap when trained on undeduplicated CTI corpora, producing inflated CTI-RCM scores that did not generalize. The released model trains exclusively on the 2021 cohort with overlap items removed.
|
| 176 |
+
|
| 177 |
+
### Methodology
|
| 178 |
+
|
| 179 |
+
This model uses **direct supervised fine-tuning (SFT)** of an instruction-tuned base via LoRA. The training recipe was selected through a controlled-experiment series across multiple trained variants spanning two model families and several corpus compositions, with multi-trial benchmark validation locking the released hyperparameters.
|
| 180 |
+
|
| 181 |
+
Key methodological choices that informed the released recipe:
|
| 182 |
+
|
| 183 |
+
- **Direct SFT, not knowledge distillation.** Knowledge-distillation variants from a larger 20B teacher model (CyberPal-2.0-20B) were evaluated during recipe development. At the corpus sizes tested (≤ 15K supervised records), direct SFT on the curated corpus outperformed distillation on the headline benchmarks. The released model is direct SFT only.
|
| 184 |
+
- **Decontaminated training data.** An earlier internal iteration showed ~72% test-set overlap when trained on undeduplicated CTI corpora, producing inflated CTI-RCM scores that did not generalize. The released model trains exclusively on the 2021 cohort with CTI-Bench overlap items removed.
|
| 185 |
+
- **Instruction-tuned base, not pre-trained base.** Direct SFT on the IT checkpoint preserves the existing format priors (terse-answer multiple-choice convention) better than SFT on the pre-trained base; comparable runs on base checkpoints (Qwen3-4B-Base + identical recipe) showed substantial CTI-MCQ format-binding decay at the same corpus scale.
|
| 186 |
+
- **Recipe portability across substrates was an explicit design goal.** The same corpus + hyperparameters were applied independently to Gemma-4-E2B-it ([Gemma4Defense-2B](https://huggingface.co/athena129/Gemma4Defense-2B)). Both models converge to within 0.9 points on CTI-RCM, providing a built-in robustness check that the result is recipe-driven rather than substrate-specific.
|
| 187 |
+
- **Multi-trial benchmarking.** All headline numbers are means of 5 independent trials with random sampling seeds at temperature 0.3; standard deviations are reported alongside.
|
| 188 |
+
- **AMD MI300X end-to-end pipeline.** Training, adapter merging, and evaluation all run on a single AMD Instinct MI300X 192 GB instance via PyTorch + ROCm + Hugging Face transformers + PEFT + TRL inside the official vLLM ROCm Docker image. FlashAttention-2 is enabled in training for forward-and-backward passes; vLLM serves with TRITON_ATTN backend for inference.
|
| 189 |
+
|
| 190 |
+
### Training Setup
|
| 191 |
+
|
| 192 |
+
| Hyperparameter | Value |
|
| 193 |
+
|---|---|
|
| 194 |
+
| Adapter | LoRA, r=64, alpha=64, dropout=0.05 |
|
| 195 |
+
| Target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
|
| 196 |
+
| Learning rate | 5e-5 |
|
| 197 |
+
| Schedule | cosine, warmup_ratio=0.05 |
|
| 198 |
+
| Weight decay | 0.01 |
|
| 199 |
+
| Per-device batch size | 2 |
|
| 200 |
+
| Gradient accumulation | 8 (effective batch = 16) |
|
| 201 |
+
| Epochs | 10 |
|
| 202 |
+
| Max sequence length | 4096 |
|
| 203 |
+
| Precision | bfloat16 |
|
| 204 |
+
| Attention implementation | flash_attention_2 |
|
| 205 |
+
| Random seed | 42 |
|
| 206 |
+
|
| 207 |
+
The base model was Qwen3-4B-Instruct-2507, an instruction-tuned variant with Apache 2.0 licensing. Training was performed end-to-end on a single AMD Instinct MI300X 192GB instance via the AMD Developer Cloud, using PyTorch + ROCm 7 + Hugging Face transformers, peft, and trl 0.29.1 inside the official `vllm/vllm-openai-rocm` Docker image.
|
| 208 |
+
|
| 209 |
+
FlashAttention-2 is enabled because Qwen3-4B's attention head dimension (128) fits within the gfx942 shared-memory budget on AMD MI300X — the same FA2 approach is not viable on Gemma-4 due to its 512 head_dim on global-attention layers, which is why the companion Gemma4Defense-2B trains with sdpa instead.
|
| 210 |
+
|
| 211 |
+
### Evaluation
|
| 212 |
+
|
| 213 |
+
Evaluated under the [Foundation-Sec-8B protocol (arXiv:2504.21039 §B.3-B.4)](https://arxiv.org/abs/2504.21039): zero-shot for instruction-tuned models, 5-shot for pretrained base models, dataset's own `Prompt` column as the user message, no system prompt, temperature 0.3, max-tokens 512, concurrency 32. Reported numbers are the mean of **5 independent trials** with random sampling seeds; standard deviations are reported alongside.
|
| 214 |
+
|
| 215 |
+
#### Headline result
|
| 216 |
+
|
| 217 |
+
| Benchmark | Metric | CyberSecQwen-4B | Foundation-Sec-Instruct-8B | Δ |
|
| 218 |
+
|---|---|---:|---:|---:|
|
| 219 |
+
| **CTI-MCQ** (2,500 items) | strict_acc, 5-trial mean ± std | **0.5868 ± 0.0029** | 0.4996 | **+8.7 pp** |
|
| 220 |
+
| **CTI-RCM** (1,000 items) | strict_acc, 5-trial mean ± std | **0.6664 ± 0.0023** | 0.6850 | -1.9 pp |
|
| 221 |
+
|
| 222 |
+
Parseable rates were 100% on CTI-RCM and 98.1% on CTI-MCQ — the model produces well-formed outputs in the expected response convention.
|
| 223 |
+
|
| 224 |
+
#### Pre / post fine-tune comparison
|
| 225 |
+
|
| 226 |
+
The improvement attributable to this fine-tune over its starting checkpoint:
|
| 227 |
+
|
| 228 |
+
| Stage | CTI-RCM | CTI-MCQ |
|
| 229 |
+
|---|---:|---:|
|
| 230 |
+
| Qwen3-4B-Instruct-2507 (raw, instruction-tuned base) | 0.519 | 0.473 |
|
| 231 |
+
| **CyberSecQwen-4B (this fine-tune)** | **0.6664** | **0.5868** |
|
| 232 |
+
| **Lift** | **+15.1 pp** | **+12.0 pp** |
|
| 233 |
+
|
| 234 |
+
Qwen3-4B-Instruct-2507's raw CTI-MCQ score (0.473) is substantially lower than its corresponding base model's score (0.667) under the chat-template evaluation — the same instruction-tuning-collapses-MCQ effect we observe for Foundation-Sec-Instruct (-15.6 pp vs Foundation-Sec base). This fine-tune recovers and exceeds the IT starting point on both subsets, restoring most of the MCQ format binding the instruction tuning eroded while delivering a substantial CTI-RCM lift.
|
| 235 |
+
|
| 236 |
+
#### Comparison to other cybersecurity-relevant models we evaluated
|
| 237 |
+
|
| 238 |
+
All numbers below were measured by us under the protocol above (with the noted shot count), not quoted from third-party papers. CyberPal-2.0-20B numbers reflect a single-trial run at our protocol — its own paper reports 0.874 / 0.757 using a different prompt template (Figure 11 of arXiv:2510.14113); the +2pp MCQ match validated our harness, while the RCM gap likely reflects the template difference.
|
| 239 |
+
|
| 240 |
+
| Model | Size | CTI-RCM | CTI-MCQ | Notes |
|
| 241 |
+
|---|---:|---:|---:|---|
|
| 242 |
+
| Foundation-Sec-8B (base) | 8B | 0.745 | 0.655 | 5-shot pretrained reference |
|
| 243 |
+
| Foundation-Sec-Instruct-8B | 8B | **0.685** | **0.500** | 0-shot, our TARGET |
|
| 244 |
+
| CyberPal-2.0-20B (cyber-pal-security/CyberOss-2.0-20B) | 20B | 0.728* | 0.738* | independently verified at our protocol |
|
| 245 |
+
| **CyberSecQwen-4B** (this model) | 4B | **0.6664 ± 0.0023** | **0.5868 ± 0.0029** | 5-trial mean ± std |
|
| 246 |
+
| [Gemma4Defense-2B](https://huggingface.co/athena129/Gemma4Defense-2B) (companion) | 2.3B | 0.6754 ± 0.0035 | 0.6042 ± 0.0090 | same recipe, different substrate |
|
| 247 |
+
| Qwen3-4B-Instruct-2507 (raw) | 4B | 0.519 | 0.473 | 0-shot, our base |
|
| 248 |
+
| Qwen3-4B-Base (raw) | 4B | 0.517 | 0.667 | 5-shot |
|
| 249 |
+
| Gemma-4-E4B-it (raw) | 5.1B effective | 0.618 | 0.666 | 0-shot |
|
| 250 |
+
| Gemma-4-E4B-base (raw) | 5.1B effective | 0.588 | 0.666 | 5-shot |
|
| 251 |
+
|
| 252 |
+
\* Single-trial values from our independent reproduction.
|
| 253 |
+
|
| 254 |
+
#### Key highlights
|
| 255 |
+
|
| 256 |
+
- Beats Foundation-Sec-Instruct-8B on CTI-MCQ by +8.7 points at half the parameter count.
|
| 257 |
+
- Stays within ~2 points of Foundation-Sec-Instruct-8B on CTI-RCM under the same evaluation protocol.
|
| 258 |
+
- Cross-substrate companion ([Gemma4Defense-2B](https://huggingface.co/athena129/Gemma4Defense-2B)) reproduces the CTI-RCM result within 0.9 points using the same recipe on a different model family.
|
| 259 |
+
- Independent reproduction of CyberPal-2.0-20B at the Foundation-Sec protocol confirms its CTI-MCQ accuracy within 2 points of its paper claim.
|
| 260 |
+
- Trained, merged, and evaluated end-to-end on a single AMD MI300X 192GB instance with FlashAttention-2 enabled.
|
| 261 |
+
|
| 262 |
+
## Limitations
|
| 263 |
+
|
| 264 |
+
1. **Domain-specific knowledge limitations.** The model is trained on cybersecurity domain text and is not a general assistant. Tasks outside this domain will produce lower-quality output than purpose-built general models.
|
| 265 |
+
|
| 266 |
+
2. **Time-anchored training data.** The CTI-RCM training cohort is drawn from 2021 records. Vulnerability classes that emerged or rose in prevalence after 2021 (e.g., AI/ML-specific weaknesses, recent supply-chain CWEs) are under-represented in training and will be classified less accurately.
|
| 267 |
+
|
| 268 |
+
3. **English-only.** All training and evaluation data are in English; multilingual cyber tasks will degrade.
|
| 269 |
+
|
| 270 |
+
4. **CTI-RCM gap.** Foundation-Sec-Instruct-8B remains stronger on CTI-RCM under this protocol (-1.9 point gap). Production deployments where CWE classification is the primary metric should benchmark both models on their specific input distribution.
|
| 271 |
+
|
| 272 |
+
5. **No safety RLHF.** The model is supervised-fine-tuned only; the training data emphasizes defensive-analyst framing but no formal reinforcement-learning safety alignment was applied.
|
| 273 |
+
|
| 274 |
+
6. **Chat template note.** The repository ships with a minimal training-aligned `chat_template.jinja` matching the format used during SFT (Qwen `<|im_start|>` / `<|im_end|>` user-and-assistant turns, no thinking-mode block). Inference via `tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)` produces correctly-formatted prompts; downstream tooling that injects system prompts or thinking-mode toggles outside this template may degrade output quality.
|
| 275 |
+
|
| 276 |
+
### Recommendations
|
| 277 |
+
|
| 278 |
+
1. **Always have qualified security professionals review model outputs before implementation** for any operational use case (patch prioritization, ticket routing, blocklisting).
|
| 279 |
+
2. **Use this model as an assistive tool rather than a replacement for expert human judgment**, especially for novel vulnerability classes outside the 2021 training cohort.
|
| 280 |
+
3. **Validate on your own input distribution** before deployment. Public CTI-Bench performance does not perfectly transfer to internal advisory feeds, vendor-proprietary CWE taxonomies, or non-English content.
|
| 281 |
+
4. **Monitor for drift.** As new CVE / CWE patterns emerge, periodically re-evaluate; consider supplementing with retrieval over a current vulnerability knowledge base for time-sensitive queries.
|
| 282 |
+
5. **Apply standard prompt-injection mitigations** when wrapping the model in agentic workflows that accept external content (advisory feeds, scraped pages); domain-SFT does not confer prompt-injection resistance.
|
| 283 |
+
|
| 284 |
+
## Companion Model
|
| 285 |
+
|
| 286 |
+
[Gemma4Defense-2B](https://huggingface.co/athena129/Gemma4Defense-2B) is a sister release fine-tuned with the same training corpus and hyperparameters, on the Gemma-4-E2B-it base. The two models converge to within 0.9 points on CTI-RCM (0.6664 Qwen vs 0.6754 Gemma, 5-trial mean) — the same recipe produces equivalent task performance across two distinct model families. The Gemma variant is licensed under the Gemma Terms of Use; CyberSecQwen-4B (Apache 2.0) is appropriate for use cases where Gemma terms are not a fit.
|
| 287 |
+
|
| 288 |
+
## Citation
|
| 289 |
+
|
| 290 |
+
If you use this model, please cite:
|
| 291 |
+
|
| 292 |
+
```bibtex
|
| 293 |
+
@misc{cybersecqwen2026,
|
| 294 |
+
title = {CyberSecQwen-4B: A Compact CTI Specialist Fine-Tuned from Qwen3-4B-Instruct-2507 on AMD MI300X},
|
| 295 |
+
author = {Mulia, Samuel},
|
| 296 |
+
year = {2026},
|
| 297 |
+
publisher = {Hugging Face},
|
| 298 |
+
url = {https://huggingface.co/athena129/CyberSecQwen-4B}
|
| 299 |
+
}
|
| 300 |
+
```
|
| 301 |
+
|
| 302 |
+
The evaluation protocol is from:
|
| 303 |
+
|
| 304 |
+
```bibtex
|
| 305 |
+
@article{foundation-sec-8b,
|
| 306 |
+
title = {Foundation-Sec-8B: A Cybersecurity-Specialized Language Model},
|
| 307 |
+
author = {Cisco Foundation AI},
|
| 308 |
+
journal = {arXiv preprint arXiv:2504.21039},
|
| 309 |
+
year = {2025},
|
| 310 |
+
url = {https://arxiv.org/abs/2504.21039}
|
| 311 |
+
}
|
| 312 |
+
```
|
| 313 |
+
|
| 314 |
+
The benchmark is from:
|
| 315 |
+
|
| 316 |
+
```bibtex
|
| 317 |
+
@misc{cti-bench,
|
| 318 |
+
title = {CTI-Bench: A Benchmark Suite for Cybersecurity LLMs},
|
| 319 |
+
author = {Alam, Md Tanvirul and Bhusal, Dipkamal and Park, Youngja and Rastogi, Nidhi},
|
| 320 |
+
year = {2024},
|
| 321 |
+
url = {https://github.com/xashru/cti-bench}
|
| 322 |
+
}
|
| 323 |
+
```
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- for message in messages -%}
|
| 2 |
+
<|im_start|>{{ message['role'] if message['role'] != 'system' else 'user' }}
|
| 3 |
+
{{ message['content'] }}<|im_end|>
|
| 4 |
+
{% endfor -%}
|
| 5 |
+
{%- if add_generation_prompt -%}
|
| 6 |
+
<|im_start|>assistant
|
| 7 |
+
{% endif -%}
|
config.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"Qwen3ForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_bias": false,
|
| 6 |
+
"attention_dropout": 0.0,
|
| 7 |
+
"bos_token_id": 151643,
|
| 8 |
+
"dtype": "bfloat16",
|
| 9 |
+
"eos_token_id": 151645,
|
| 10 |
+
"head_dim": 128,
|
| 11 |
+
"hidden_act": "silu",
|
| 12 |
+
"hidden_size": 2560,
|
| 13 |
+
"initializer_range": 0.02,
|
| 14 |
+
"intermediate_size": 9728,
|
| 15 |
+
"layer_types": [
|
| 16 |
+
"full_attention",
|
| 17 |
+
"full_attention",
|
| 18 |
+
"full_attention",
|
| 19 |
+
"full_attention",
|
| 20 |
+
"full_attention",
|
| 21 |
+
"full_attention",
|
| 22 |
+
"full_attention",
|
| 23 |
+
"full_attention",
|
| 24 |
+
"full_attention",
|
| 25 |
+
"full_attention",
|
| 26 |
+
"full_attention",
|
| 27 |
+
"full_attention",
|
| 28 |
+
"full_attention",
|
| 29 |
+
"full_attention",
|
| 30 |
+
"full_attention",
|
| 31 |
+
"full_attention",
|
| 32 |
+
"full_attention",
|
| 33 |
+
"full_attention",
|
| 34 |
+
"full_attention",
|
| 35 |
+
"full_attention",
|
| 36 |
+
"full_attention",
|
| 37 |
+
"full_attention",
|
| 38 |
+
"full_attention",
|
| 39 |
+
"full_attention",
|
| 40 |
+
"full_attention",
|
| 41 |
+
"full_attention",
|
| 42 |
+
"full_attention",
|
| 43 |
+
"full_attention",
|
| 44 |
+
"full_attention",
|
| 45 |
+
"full_attention",
|
| 46 |
+
"full_attention",
|
| 47 |
+
"full_attention",
|
| 48 |
+
"full_attention",
|
| 49 |
+
"full_attention",
|
| 50 |
+
"full_attention",
|
| 51 |
+
"full_attention"
|
| 52 |
+
],
|
| 53 |
+
"max_position_embeddings": 262144,
|
| 54 |
+
"max_window_layers": 36,
|
| 55 |
+
"model_type": "qwen3",
|
| 56 |
+
"num_attention_heads": 32,
|
| 57 |
+
"num_hidden_layers": 36,
|
| 58 |
+
"num_key_value_heads": 8,
|
| 59 |
+
"pad_token_id": null,
|
| 60 |
+
"rms_norm_eps": 1e-06,
|
| 61 |
+
"rope_parameters": {
|
| 62 |
+
"rope_theta": 5000000,
|
| 63 |
+
"rope_type": "default"
|
| 64 |
+
},
|
| 65 |
+
"sliding_window": null,
|
| 66 |
+
"tie_word_embeddings": true,
|
| 67 |
+
"transformers_version": "5.7.0",
|
| 68 |
+
"use_cache": true,
|
| 69 |
+
"use_sliding_window": false,
|
| 70 |
+
"vocab_size": 151936
|
| 71 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token_id": 151643,
|
| 3 |
+
"do_sample": true,
|
| 4 |
+
"eos_token_id": [
|
| 5 |
+
151645,
|
| 6 |
+
151643
|
| 7 |
+
],
|
| 8 |
+
"pad_token_id": 151643,
|
| 9 |
+
"temperature": 0.7,
|
| 10 |
+
"top_k": 20,
|
| 11 |
+
"top_p": 0.8,
|
| 12 |
+
"transformers_version": "5.7.0"
|
| 13 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:63881a91d6e951a9ee2fef41c14c9049a8e5d8500dd10b5f07de741feaaa0b92
|
| 3 |
+
size 8044982080
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:be75606093db2094d7cd20f3c2f385c212750648bd6ea4fb2bf507a6a4c55506
|
| 3 |
+
size 11422650
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"backend": "tokenizers",
|
| 4 |
+
"bos_token": null,
|
| 5 |
+
"clean_up_tokenization_spaces": false,
|
| 6 |
+
"eos_token": "<|im_end|>",
|
| 7 |
+
"errors": "replace",
|
| 8 |
+
"extra_special_tokens": [
|
| 9 |
+
"<|im_start|>",
|
| 10 |
+
"<|im_end|>",
|
| 11 |
+
"<|object_ref_start|>",
|
| 12 |
+
"<|object_ref_end|>",
|
| 13 |
+
"<|box_start|>",
|
| 14 |
+
"<|box_end|>",
|
| 15 |
+
"<|quad_start|>",
|
| 16 |
+
"<|quad_end|>",
|
| 17 |
+
"<|vision_start|>",
|
| 18 |
+
"<|vision_end|>",
|
| 19 |
+
"<|vision_pad|>",
|
| 20 |
+
"<|image_pad|>",
|
| 21 |
+
"<|video_pad|>"
|
| 22 |
+
],
|
| 23 |
+
"is_local": false,
|
| 24 |
+
"local_files_only": false,
|
| 25 |
+
"model_max_length": 1010000,
|
| 26 |
+
"pad_token": "<|endoftext|>",
|
| 27 |
+
"split_special_tokens": false,
|
| 28 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
| 29 |
+
"unk_token": null
|
| 30 |
+
}
|