This repo is superseded by anicka/cve-backport-codegen-qwen25-32b which has the latest v3 model. This repo is kept for legacy access to v1/v2 GGUFs and the merged safetensors.
Instead of generating unified diffs directly, 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. This plays to LLM strengths in code completion and avoids format-sensitivity issues.
Quick Start
The easiest way to use this model is with the cve-backport-tool CLI, which handles the full pipeline: parse upstream patch, extract per-hunk regions, call the model, and reconstruct a unified diff.
bash
1# Download and serve the model2./setup.sh
34# Generate a backport patch5python3 cve-backport.py \6 --cve CVE-2024-2398 \7 --package curl-7.66.0 \8 --patch upstream.patch \9 --source-dir /path/to/curl-7.66.0/ \10 --backend openai --port 8403
GGUF Downloads
File
Quant
Size
Notes
cve-backport-codegen-v3-q8_0.gguf
Q8_0
33 GB
Recommended (v3, 35K dataset, 98% precision)
cve-backport-codegen-v2-q8_0.gguf
Q8_0
33 GB
v2 (24K dataset)
cve-backport-codegen-v1-q8_0.gguf
Q8_0
33 GB
v1 (17K dataset)
Evaluation
Per-hunk evaluation on held-out test cases the model never saw during training:
Metric
v1
v2
v3
Average recall
91%
94%
94%
Average precision
—
93%
98%
Exact match
—
15/20
16/20
Perfect hunks (>=95%)
16/18
17/20
17/20
Fail (<10%)
1/18
0/20
0/20
v3 was trained on 35,667 cleaned examples with LR=1e-4 (lowered from 2e-4 for stability with larger dataset). Same recall as v2, but significantly higher precision (98% vs 93%) — the model makes fewer spurious changes.
ChatML format. Each prompt covers one hunk region with 15 lines of context padding:
System:
You are a security patch backporting assistant.
Given vulnerable source code and a description of the upstream fix, output the FIXED version of the code.
Rules:
- Output ONLY the fixed code, nothing else — no explanations, no markdown fences
- Preserve exact formatting, indentation, and style of the original
- Make ONLY the changes described in the fix — do not modify anything else
- Do not add comments about what you changed
User:
## File: lib/ftp.c
## Lines: 2836-2912
```c
{vulnerable code region with 15-line padding}
```
## Fix
CVE-2017-8817: FTP wildcard matching — zero terminate the entry path
```diff
{upstream patch}
```
Assistant: The fixed code (same region with the security fix applied).
Training
Base model
Qwen2.5-Coder-32B-Instruct
Method
QLoRA (4-bit NF4, r=64, alpha=128)
Epochs
2
Learning rate
2e-4
Max sequence length
4,096 tokens
Batch size
1 (gradient accumulation 8)
Training examples
14,458 train + 2,549 eval
Training time
13.2 hours
Hardware
NVIDIA H100 NVL 94GB
Final train loss
0.0137
Final eval loss
0.00699
Files
File
Size
Description
model-*.safetensors
62 GB total
Full merged model (BF16)
cve-backport-codegen-v1-q8_0.gguf
33 GB
Q8_0 quantized GGUF for llama.cpp/ollama
The Q8_0 GGUF fits on a single L40 48GB or A100 80GB GPU with 8k context.
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.
License
Apache-2.0 (inherited from Qwen2.5-Coder-32B-Instruct).