AggressiveBag/VKR_Dataset
Viewer • Updated • 81k • 19
Binary classifier for detecting whether Python code is human-written or AI-generated.
The model was fine-tuned from microsoft/codebert-base on the AggressiveBag/VKR_Dataset dataset.
0: human-written Python code1: AI-generated Python codemicrosoft/codebert-base2e-50.010.06| Metric | Value |
|---|---|
| Loss | 0.4192 |
| Accuracy | 0.7836 |
| Precision, AI class | 0.7142 |
| Recall, AI class | 0.9456 |
| F1, AI class | 0.8138 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_id = "AggressiveBag/VKR_Model"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(model_id)
code = "print('hello world')"
inputs = tokenizer(code, return_tensors="pt", truncation=True, max_length=512)
with torch.no_grad():
logits = model(**inputs).logits
probs = torch.softmax(logits, dim=-1)[0]
print({"human": float(probs[0]), "ai": float(probs[1])})
This model is intended for research and educational experiments related to AI-generated Python code detection. It should not be used as the sole evidence for high-stakes decisions, because AI-code detection can produce false positives and false negatives.
The training data is based on human solutions from APPS and locally generated AI solutions. See AggressiveBag/VKR_Dataset for dataset details.
Base model
microsoft/codebert-base