Text Generation
Transformers
Safetensors
English
gemma4_unified
image-text-to-text
cybersecurity
cve
cwe
vulnerability
text-classification
gemma4
qlora
conversational
Instructions to use exploitintel/cve-cwe-gemma4-12b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use exploitintel/cve-cwe-gemma4-12b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="exploitintel/cve-cwe-gemma4-12b") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("exploitintel/cve-cwe-gemma4-12b") model = AutoModelForImageTextToText.from_pretrained("exploitintel/cve-cwe-gemma4-12b") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use exploitintel/cve-cwe-gemma4-12b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "exploitintel/cve-cwe-gemma4-12b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "exploitintel/cve-cwe-gemma4-12b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/exploitintel/cve-cwe-gemma4-12b
- SGLang
How to use exploitintel/cve-cwe-gemma4-12b 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 "exploitintel/cve-cwe-gemma4-12b" \ --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": "exploitintel/cve-cwe-gemma4-12b", "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 "exploitintel/cve-cwe-gemma4-12b" \ --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": "exploitintel/cve-cwe-gemma4-12b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use exploitintel/cve-cwe-gemma4-12b with Docker Model Runner:
docker model run hf.co/exploitintel/cve-cwe-gemma4-12b
Upload README.md with huggingface_hub
Browse files
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.
|