Downloads · 30 days
16
12% of all-time downloads
phamtungthuy/codebert-defect-detection
codebert-defect-detection is a machine learning model from phamtungthuy. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
Fine-tuned from microsoft/codebert-base for vulnerability detection.
Downloads · 30 days
16
12% of all-time downloads
All-time downloads
132
Public
Parameters
125M
997 MB on disk
Likes
0
Public
Click a slice to open those files.
.bin499 MB · 50%
From the Hugging Face model README
Fine-tuned from microsoft/codebert-base for vulnerability detection.
from transformers import RobertaTokenizer, RobertaForSequenceClassification
import torch
tokenizer = RobertaTokenizer.from_pretrained("phamtungthuy/codebert-defect-detection")
model = RobertaForSequenceClassification.from_pretrained("phamtungthuy/codebert-defect-detection")
code = "int main() { char buf[10]; strcpy(buf, argv[1]); }"
inputs = tokenizer(code, return_tensors="pt", truncation=True, max_length=400)
prob = torch.sigmoid(model(**inputs).logits)
print("Vulnerable" if prob > 0.5 else "Secure")