exploitintel commited on
Commit
69385ea
·
verified ·
1 Parent(s): eac6c96

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +87 -0
README.md ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: unsloth/gemma-4-12b-it
4
+ datasets:
5
+ - exploitintel/cve-cwe-consensus
6
+ language:
7
+ - en
8
+ pipeline_tag: text-generation
9
+ library_name: transformers
10
+ tags:
11
+ - cybersecurity
12
+ - cve
13
+ - cwe
14
+ - vulnerability
15
+ - text-classification
16
+ - gemma4
17
+ - qlora
18
+ ---
19
+
20
+ # cve-cwe-gemma4-12b
21
+
22
+ A [Gemma 4 12B](https://huggingface.co/unsloth/gemma-4-12b-it) fine-tune that maps a **CVE description** to its **CWE ID(s)**.
23
+
24
+ - **Input:** a free-text vulnerability description (text only).
25
+ - **Output:** the CWE ID(s) it maps to, comma-separated — e.g. `CWE-79` or `CWE-89, CWE-352`.
26
+ - **Label space:** MITRE [CWE View-1003](https://cwe.mitre.org/data/definitions/1003.html) (~117 weakness classes). Multi-label.
27
+
28
+ This is the merged 16-bit (bf16) model for `transformers` / vLLM / TGI. Quantized GGUFs for Ollama and llama.cpp are at [**exploitintel/cve-cwe-gemma4-12b-GGUF**](https://huggingface.co/exploitintel/cve-cwe-gemma4-12b-GGUF).
29
+
30
+ ## Results
31
+
32
+ Held-out test split (`exploitintel/cve-cwe-consensus`, 10,514 examples), greedy decoding, **description-only** (no CVE-ID or label metadata in the prompt). Rows are split into *easy* (the weakness is named in the text) vs *hard* (it must be inferred).
33
+
34
+ | metric | this model (bf16) | v1 baseline* |
35
+ |---|---|---|
36
+ | exact-match | **0.714** | 0.29 |
37
+ | micro-F1 | **0.756** | 0.32 |
38
+ | macro-F1 | **0.538** | 0.067 |
39
+ | easy exact-match | 0.805 | — |
40
+ | hard exact-match | 0.644 | — |
41
+
42
+ \* v1 baseline = a 1-epoch Gemma-4-E4B fine-tune. The headline gain is **macro-F1** (the rare-CWE long tail), which improves ~8×; *hard* (must-infer) exact-match of 0.644 is close to *easy* (0.805), indicating the model genuinely infers weaknesses rather than only keyword-matching.
43
+
44
+ ## Usage
45
+
46
+ Requires `transformers >= 5.10` (Gemma 4 is the `gemma4_unified` architecture).
47
+
48
+ ```python
49
+ import torch
50
+ from transformers import AutoModelForCausalLM, AutoTokenizer
51
+
52
+ model_id = "exploitintel/cve-cwe-gemma4-12b"
53
+ tok = AutoTokenizer.from_pretrained(model_id)
54
+ model = AutoModelForCausalLM.from_pretrained(model_id, dtype="auto", device_map="auto").eval()
55
+
56
+ cve = ("A vulnerability in the login form allows remote attackers to execute "
57
+ "arbitrary SQL commands via the username parameter.")
58
+ messages = [
59
+ {"role": "system", "content": "You are a vulnerability analyst. Given a CVE "
60
+ "description, reply with only the CWE ID(s) it maps to, comma-separated."},
61
+ {"role": "user", "content": cve},
62
+ ]
63
+ prompt = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
64
+ inputs = tok(prompt, return_tensors="pt").to(model.device)
65
+ out = model.generate(**inputs, max_new_tokens=32, do_sample=False)
66
+ print(tok.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))
67
+ # -> CWE-89
68
+ ```
69
+
70
+ ## Training
71
+
72
+ - **Base:** `unsloth/gemma-4-12b-it` (4-bit QLoRA, bitsandbytes nf4).
73
+ - **Method:** LoRA (r=16), 3 epochs, context length 512, full-sequence SFT.
74
+ - **Data:** `exploitintel/cve-cwe-consensus` (train split, 50,074 examples).
75
+ - **Hardware:** single NVIDIA RTX 5090; ~7.1 h wall, ~17 GB peak VRAM.
76
+ - Trained with [Unsloth](https://github.com/unslothai/unsloth).
77
+
78
+ ## Intended use & limitations
79
+
80
+ - **Intended use:** triage assistance — suggesting candidate CWE mappings for a CVE description.
81
+ - It is **description-only**: quality depends on how well the text describes the weakness. Vague descriptions yield weaker predictions (see the *hard* split).
82
+ - It can predict CWEs outside the true set; treat outputs as suggestions, not authoritative classifications, and keep a human in the loop for security-relevant decisions.
83
+ - Scope is MITRE View-1003; CWEs outside that view are not modeled.
84
+
85
+ ## License
86
+
87
+ Apache-2.0, inherited from the Gemma 4 base model.