--- license: mit language: - en tags: - smart-contracts - vulnerability-detection - solidity - security base_model: microsoft/codebert-base pipeline_tag: text-classification --- # CodeBERT for Solidity Vulnerability Detection Fine-tuned version of microsoft/codebert-base for binary classification of Solidity smart contracts as vulnerable (1) or safe (0). ## Model Details - Base model: microsoft/codebert-base - Task: Binary classification (vulnerable=1, safe=0) - Dataset: 367 Solidity smart contracts generated by 5 LLMs - Training: 5 epochs, batch size 8, AdamW optimizer - Platform: Google Colaboratory (T4 GPU) ## Results - Accuracy: 95.9% - Precision (vulnerable): 100% - Recall (vulnerable): 93.3% - F1-score (vulnerable): 0.97 - False positives: 0 ## How to Use Install: pip install transformers torch from transformers import AutoTokenizer, AutoModelForSequenceClassification import torch tokenizer = AutoTokenizer.from_pretrained("Sabreen2026/codebert-solidity-vulnerability") model = AutoModelForSequenceClassification.from_pretrained("Sabreen2026/codebert-solidity-vulnerability") model.eval() contract_code = "pragma solidity ^0.8.0; contract Test { }" inputs = tokenizer(contract_code, truncation=True, padding=True, max_length=512, return_tensors='pt') with torch.no_grad(): outputs = model(**inputs) prediction = torch.argmax(outputs.logits, dim=1).item() print('VULNERABLE' if prediction == 1 else 'SAFE') ## Citation Ahmadjee, S. (2026). Vulnerability Detection in LLM-Generated Solidity Smart Contracts Using Fine-Tuned CodeBERT.