Text Generation
GGUF
English
qwen2
security
patch-backporting
code-generation
test-generation
qlora
opensuse
conversational
Instructions to use anicka/cve-backport-codegen-qwen25-32b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use anicka/cve-backport-codegen-qwen25-32b with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf anicka/cve-backport-codegen-qwen25-32b:Q8_0 # Run inference directly in the terminal: llama cli -hf anicka/cve-backport-codegen-qwen25-32b:Q8_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf anicka/cve-backport-codegen-qwen25-32b:Q8_0 # Run inference directly in the terminal: llama cli -hf anicka/cve-backport-codegen-qwen25-32b:Q8_0
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf anicka/cve-backport-codegen-qwen25-32b:Q8_0 # Run inference directly in the terminal: ./llama-cli -hf anicka/cve-backport-codegen-qwen25-32b:Q8_0
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf anicka/cve-backport-codegen-qwen25-32b:Q8_0 # Run inference directly in the terminal: ./build/bin/llama-cli -hf anicka/cve-backport-codegen-qwen25-32b:Q8_0
Use Docker
docker model run hf.co/anicka/cve-backport-codegen-qwen25-32b:Q8_0
- LM Studio
- Jan
- vLLM
How to use anicka/cve-backport-codegen-qwen25-32b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "anicka/cve-backport-codegen-qwen25-32b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "anicka/cve-backport-codegen-qwen25-32b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/anicka/cve-backport-codegen-qwen25-32b:Q8_0
- Ollama
How to use anicka/cve-backport-codegen-qwen25-32b with Ollama:
ollama run hf.co/anicka/cve-backport-codegen-qwen25-32b:Q8_0
- Unsloth Studio
How to use anicka/cve-backport-codegen-qwen25-32b with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for anicka/cve-backport-codegen-qwen25-32b to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for anicka/cve-backport-codegen-qwen25-32b to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for anicka/cve-backport-codegen-qwen25-32b to start chatting
- Pi
How to use anicka/cve-backport-codegen-qwen25-32b with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf anicka/cve-backport-codegen-qwen25-32b:Q8_0
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "anicka/cve-backport-codegen-qwen25-32b:Q8_0" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use anicka/cve-backport-codegen-qwen25-32b with Docker Model Runner:
docker model run hf.co/anicka/cve-backport-codegen-qwen25-32b:Q8_0
- Lemonade
How to use anicka/cve-backport-codegen-qwen25-32b with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull anicka/cve-backport-codegen-qwen25-32b:Q8_0
Run and chat with the model
lemonade run user.cve-backport-codegen-qwen25-32b-Q8_0
List all available models
lemonade list
- Hermes Agent
How to use anicka/cve-backport-codegen-qwen25-32b with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf anicka/cve-backport-codegen-qwen25-32b:Q8_0
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default anicka/cve-backport-codegen-qwen25-32b:Q8_0
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use anicka/cve-backport-codegen-qwen25-32b with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf anicka/cve-backport-codegen-qwen25-32b:Q8_0
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "anicka/cve-backport-codegen-qwen25-32b:Q8_0" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
v4 model card: 93% recall, test generation, Gemini comparison
Browse files
README.md
CHANGED
|
@@ -5,6 +5,7 @@ tags:
|
|
| 5 |
- security
|
| 6 |
- patch-backporting
|
| 7 |
- code-generation
|
|
|
|
| 8 |
- qwen2
|
| 9 |
- qlora
|
| 10 |
- opensuse
|
|
@@ -15,70 +16,73 @@ language:
|
|
| 15 |
pipeline_tag: text-generation
|
| 16 |
---
|
| 17 |
|
| 18 |
-
# CVE Backport Code Generation — Qwen2.5-Coder-32B
|
| 19 |
|
| 20 |
-
Fine-tuned [Qwen2.5-Coder-32B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-32B-Instruct) for security patch backporting via per-hunk code generation.
|
| 21 |
|
| 22 |
-
Instead of generating unified diffs
|
| 23 |
|
| 24 |
## Quick Start
|
| 25 |
|
| 26 |
-
The easiest way to use this model is with the **[cve-backport-tool](https://github.com/openSUSE/cve-backport-tool)** CLI, which handles the full pipeline: parse upstream patch, extract per-hunk regions, call the model, and reconstruct a unified diff.
|
| 27 |
-
|
| 28 |
```bash
|
| 29 |
-
|
| 30 |
-
|
|
|
|
| 31 |
|
| 32 |
-
# Generate a backport patch
|
| 33 |
python3 cve-backport.py \
|
| 34 |
-
--cve CVE-
|
| 35 |
-
--package
|
| 36 |
-
--patch upstream.patch \
|
| 37 |
-
--obs-fetch --
|
|
|
|
| 38 |
```
|
| 39 |
|
| 40 |
## GGUF Downloads
|
| 41 |
|
| 42 |
-
| File | Quant | Size |
|
| 43 |
-
|------|-------|------|-------
|
| 44 |
-
| `cve-backport-codegen-
|
| 45 |
-
| `cve-backport-codegen-
|
| 46 |
-
| `cve-backport-codegen-v1-q8_0.gguf` | Q8_0 | 33 GB | 17,007 examples | First release |
|
| 47 |
-
|
| 48 |
-
Older GGUFs (v1, v2) are available in the [legacy repo](https://huggingface.co/anicka/cve-backport-codegen-qwen25-32b-v1).
|
| 49 |
|
| 50 |
-
## Evaluation
|
| 51 |
|
| 52 |
-
Per-hunk evaluation on held-out
|
| 53 |
|
| 54 |
-
| Metric |
|
| 55 |
-
|--------|----
|
| 56 |
-
| Average recall |
|
| 57 |
-
| Average precision |
|
| 58 |
-
| Exact match |
|
| 59 |
-
|
|
| 60 |
-
| Fail (<10%) | 1/18 | 0/20 | **0/20** |
|
| 61 |
|
| 62 |
By tier:
|
| 63 |
-
- **Identical** (upstream patch applies directly):
|
| 64 |
-
- **Adapted** (line numbers/context differ):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
-
##
|
| 67 |
|
| 68 |
-
|
| 69 |
-
|-|----|----|-----|
|
| 70 |
-
| Dataset | 17,007 | 24,452 | **35,667** |
|
| 71 |
-
| Learning rate | 2e-4 | 2e-4 | **1e-4** |
|
| 72 |
-
| Epochs | 2 | 2 | 2 |
|
| 73 |
-
| Training time | 13h | 27h | 41h |
|
| 74 |
-
| Hardware | H100 NVL | H100 NVL | H100 NVL |
|
| 75 |
-
| Method | QLoRA r=64 α=128 | QLoRA r=64 α=128 | QLoRA r=64 α=128 |
|
| 76 |
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
## Prompt Format
|
| 80 |
|
| 81 |
-
ChatML format. Each prompt covers one hunk region with 15 lines of context padding
|
|
|
|
|
|
|
| 82 |
|
| 83 |
**System:**
|
| 84 |
```
|
|
@@ -94,37 +98,77 @@ Rules:
|
|
| 94 |
```
|
| 95 |
|
| 96 |
**User:**
|
| 97 |
-
```
|
| 98 |
-
## File: lib/
|
| 99 |
-
## Lines:
|
| 100 |
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
|
| 105 |
## Fix
|
| 106 |
-
CVE-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
```
|
| 112 |
|
| 113 |
-
**Assistant:**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
|
| 115 |
## Training Data
|
| 116 |
|
| 117 |
-
**[anicka/cve-backport-codegen-dataset](https://huggingface.co/datasets/anicka/cve-backport-codegen-dataset)** —
|
| 118 |
|
| 119 |
-
##
|
| 120 |
|
| 121 |
-
|
| 122 |
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
|
| 125 |
-
|
| 126 |
-
- **Dataset**: [anicka/cve-backport-codegen-dataset](https://huggingface.co/datasets/anicka/cve-backport-codegen-dataset)
|
| 127 |
-
- **Legacy repo** (v1/v2 GGUFs + safetensors): [anicka/cve-backport-codegen-qwen25-32b-v1](https://huggingface.co/anicka/cve-backport-codegen-qwen25-32b-v1)
|
| 128 |
|
| 129 |
## License
|
| 130 |
|
|
|
|
| 5 |
- security
|
| 6 |
- patch-backporting
|
| 7 |
- code-generation
|
| 8 |
+
- test-generation
|
| 9 |
- qwen2
|
| 10 |
- qlora
|
| 11 |
- opensuse
|
|
|
|
| 16 |
pipeline_tag: text-generation
|
| 17 |
---
|
| 18 |
|
| 19 |
+
# CVE Backport Code Generation — Qwen2.5-Coder-32B (v4)
|
| 20 |
|
| 21 |
+
Fine-tuned [Qwen2.5-Coder-32B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-32B-Instruct) for security patch backporting via per-hunk code generation, with CVE test case generation.
|
| 22 |
|
| 23 |
+
Instead of generating unified diffs, this model takes a vulnerable code region and a fix description, and outputs the **fixed version of the code**. A programmatic diff then produces the final patch. Optionally, the model can also generate a **test case** that verifies the fix.
|
| 24 |
|
| 25 |
## Quick Start
|
| 26 |
|
|
|
|
|
|
|
| 27 |
```bash
|
| 28 |
+
git clone https://github.com/openSUSE/cve-backport-tool
|
| 29 |
+
cd cve-backport-tool
|
| 30 |
+
./setup.sh # downloads GGUF, registers with ollama
|
| 31 |
|
|
|
|
| 32 |
python3 cve-backport.py \
|
| 33 |
+
--cve CVE-2024-1234 \
|
| 34 |
+
--package curl \
|
| 35 |
+
--patch upstream-fix.patch \
|
| 36 |
+
--obs-fetch --obs-project openSUSE:Leap:15.6:Update \
|
| 37 |
+
--retry 3
|
| 38 |
```
|
| 39 |
|
| 40 |
## GGUF Downloads
|
| 41 |
|
| 42 |
+
| File | Quant | Size | Notes |
|
| 43 |
+
|------|-------|------|-------|
|
| 44 |
+
| `cve-backport-codegen-v4-q8_0.gguf` | Q8_0 | 33 GB | **Recommended** (v4, 36K dataset + test generation) |
|
| 45 |
+
| `cve-backport-codegen-v3-q8_0.gguf` | Q8_0 | 33 GB | v3 (35K dataset, 98% precision) |
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
+
## Evaluation (v4)
|
| 48 |
|
| 49 |
+
Per-hunk evaluation on 100 held-out examples the model never saw during training:
|
| 50 |
|
| 51 |
+
| Metric | v3 (n=20) | v4 (n=100) |
|
| 52 |
+
|--------|-----------|------------|
|
| 53 |
+
| Average recall | 94% | **93%** |
|
| 54 |
+
| Average precision | 98% | **95%** |
|
| 55 |
+
| Exact match | 16/20 | **87/100** |
|
| 56 |
+
| Failures (<10%) | 0/20 | **4/100** |
|
|
|
|
| 57 |
|
| 58 |
By tier:
|
| 59 |
+
- **Identical** (upstream patch applies directly): 94% recall
|
| 60 |
+
- **Adapted** (line numbers/context differ): 86% recall
|
| 61 |
+
|
| 62 |
+
### Test Generation (new in v4)
|
| 63 |
+
|
| 64 |
+
50 held-out CVEs with known reference tests:
|
| 65 |
+
- Average quality score: **0.67**
|
| 66 |
+
- All 50 produced structurally valid tests
|
| 67 |
+
- 17/50 matched reference test exactly
|
| 68 |
|
| 69 |
+
### Comparison with Frontier Models
|
| 70 |
|
| 71 |
+
Same eval, same 100 examples, optimized prompts with markdown stripping:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
+
| Model | Recall | Precision | Exact | Failures |
|
| 74 |
+
|-------|--------|-----------|-------|----------|
|
| 75 |
+
| **CVE Backport v4** (32B fine-tuned) | **93%** | **95%** | **87/100** | **4** |
|
| 76 |
+
| Gemini 3.1 Pro (frontier, zero-shot) | 27% | 24% | 10/100 | 50 |
|
| 77 |
+
| Gemini 2.0 Flash (frontier, zero-shot) | 13% | 17% | 4/100 | 81 |
|
| 78 |
+
|
| 79 |
+
Fine-tuning on 36K domain-specific examples outperforms frontier models by 3-7x on this task.
|
| 80 |
|
| 81 |
## Prompt Format
|
| 82 |
|
| 83 |
+
ChatML format. Each prompt covers one hunk region with 15 lines of context padding.
|
| 84 |
+
|
| 85 |
+
### Code Generation (3-turn)
|
| 86 |
|
| 87 |
**System:**
|
| 88 |
```
|
|
|
|
| 98 |
```
|
| 99 |
|
| 100 |
**User:**
|
| 101 |
+
````
|
| 102 |
+
## File: lib/ftp.c
|
| 103 |
+
## Lines: 2836-2912
|
| 104 |
|
| 105 |
+
```c
|
| 106 |
+
{vulnerable code region with 15-line padding}
|
| 107 |
+
```
|
| 108 |
|
| 109 |
## Fix
|
| 110 |
+
CVE-2017-8817: FTP wildcard matching — zero terminate the entry path
|
| 111 |
+
|
| 112 |
+
```diff
|
| 113 |
+
{upstream patch}
|
| 114 |
+
```
|
| 115 |
+
````
|
| 116 |
+
|
| 117 |
+
**Assistant:** The fixed code (same region with the security fix applied).
|
| 118 |
+
|
| 119 |
+
### Test Generation (5-turn, new in v4)
|
| 120 |
+
|
| 121 |
+
After the code generation turn, an optional second turn:
|
| 122 |
|
| 123 |
+
**User:**
|
| 124 |
+
```
|
| 125 |
+
Write a test case that:
|
| 126 |
+
1. Triggers the vulnerability in the original code above
|
| 127 |
+
2. Passes after applying your fix
|
| 128 |
+
|
| 129 |
+
Output ONLY the test code, nothing else.
|
| 130 |
```
|
| 131 |
|
| 132 |
+
**Assistant:** Test code targeting the specific CVE.
|
| 133 |
+
|
| 134 |
+
## Training
|
| 135 |
+
|
| 136 |
+
| | |
|
| 137 |
+
|-|-|
|
| 138 |
+
| Base model | Qwen2.5-Coder-32B-Instruct |
|
| 139 |
+
| Method | QLoRA (4-bit NF4, r=64, alpha=128) |
|
| 140 |
+
| Epochs | 2 |
|
| 141 |
+
| Learning rate | 1e-4 |
|
| 142 |
+
| Max sequence length | 4,096 tokens |
|
| 143 |
+
| Batch size | 1 (gradient accumulation 8) |
|
| 144 |
+
| Training examples | 36,166 (35,396 codegen + 770 codegen+test) |
|
| 145 |
+
| Training time | 41.2 hours |
|
| 146 |
+
| Hardware | 2x NVIDIA H100 NVL 94GB |
|
| 147 |
+
| Label masking | Multi-turn aware (both assistant segments trained) |
|
| 148 |
|
| 149 |
## Training Data
|
| 150 |
|
| 151 |
+
**[anicka/cve-backport-codegen-dataset](https://huggingface.co/datasets/anicka/cve-backport-codegen-dataset)** — 36,166 per-hunk examples from openSUSE maintenance patches, covering 145+ packages and 2,300+ CVEs, with per-example SPDX license metadata.
|
| 152 |
|
| 153 |
+
## Reproducibility
|
| 154 |
|
| 155 |
+
Trained using the [Teapot](https://github.com/anicka-net/teapot) composable training pipeline:
|
| 156 |
|
| 157 |
+
```bash
|
| 158 |
+
teapot compose configs/cve-backport.config
|
| 159 |
+
teapot train configs/cve-backport.config --backend qlora-hf
|
| 160 |
+
teapot eval configs/cve-backport.config
|
| 161 |
+
```
|
| 162 |
+
|
| 163 |
+
All versioned datasets available at the dataset repo (`train-v1.jsonl` through `train-v4.jsonl`).
|
| 164 |
+
|
| 165 |
+
## How It Was Built
|
| 166 |
+
|
| 167 |
+
This model, tool, dataset pipeline, and training infrastructure were developed by Claude (Anthropic) with code review by Codex (OpenAI), under the direction of Anna Maresova (SUSE Engineering).
|
| 168 |
+
|
| 169 |
+
## Intended Use
|
| 170 |
|
| 171 |
+
This model assists with security patch backporting in Linux distribution maintenance. It is a research tool — all generated patches must be reviewed by a maintainer before application.
|
|
|
|
|
|
|
| 172 |
|
| 173 |
## License
|
| 174 |
|