Fine-tuned from
Salesforce/codet5p-220m (220M parameters) on 7,374 vulnerable→fixed code pairs.
1from transformers import AutoTokenizer, T5ForConditionalGeneration
2
3model_id = "ayshajavd/codet5p-vuln-fixer"
4tokenizer = AutoTokenizer.from_pretrained(model_id)
5model = T5ForConditionalGeneration.from_pretrained(model_id)
6model.eval()
7
8# CWE-aware input format
9code = """
10def get_user(username):
11 query = f"SELECT * FROM users WHERE username = '{username}'"
12 conn = sqlite3.connect('db.sqlite')
13 return conn.execute(query).fetchone()
14"""
15
16input_text = f"fix SQL Injection vulnerability in python: {code}"
17inputs = tokenizer(input_text, return_tensors="pt", max_length=512, truncation=True)
18
19import torch
20with torch.no_grad():
21 outputs = model.generate(
22 **inputs,
23 max_length=512,
24 num_beams=5,
25 early_stopping=True,
26 no_repeat_ngram_size=3,
27 )
28
29fixed_code = tokenizer.decode(outputs[0], skip_special_tokens=True)
30print(fixed_code)
The model was trained on a diverse multi-language dataset. Performance is strongest on C/C++ (largest training subset from BigVul).
Filtered from 175K total samples to only include vulnerable samples with meaningful code fixes (>10 characters).
Try the model in our
Code Security Analyzer Space — paste any code and get vulnerability detection + fix suggestions.
1@misc{codet5p-vuln-fixer,
2 title={CodeT5+ Vulnerability Fixer: CWE-Aware Code Repair with Seq2Seq Generation},
3 author={ayshajavd},
4 year={2025},
5 url={https://huggingface.co/ayshajavd/codet5p-vuln-fixer}
6}