Sabreen2026 commited on
Commit
e25c676
·
verified ·
1 Parent(s): 216787d

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +42 -0
README.md ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CodeBERT for Solidity Vulnerability Detection
2
+
3
+ Fine-tuned version of microsoft/codebert-base for binary classification of Solidity smart contracts as vulnerable (1) or safe (0).
4
+
5
+ ## Model Details
6
+ - Base model: microsoft/codebert-base
7
+ - Task: Binary classification (vulnerable=1, safe=0)
8
+ - Dataset: 367 Solidity smart contracts generated by 5 LLMs
9
+ - Training: 5 epochs, batch size 8, AdamW optimizer
10
+ - Platform: Google Colaboratory (T4 GPU)
11
+
12
+ ## Results
13
+ - Accuracy: 95.9%
14
+ - Precision (vulnerable): 100%
15
+ - Recall (vulnerable): 93.3%
16
+ - F1-score (vulnerable): 0.97
17
+ - False positives: 0
18
+
19
+ ## How to Use
20
+
21
+ Install: pip install transformers torch
22
+
23
+ Then run:
24
+
25
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
26
+ import torch
27
+
28
+ tokenizer = AutoTokenizer.from_pretrained("Sabreen2026/codebert-solidity-vulnerability")
29
+ model = AutoModelForSequenceClassification.from_pretrained("Sabreen2026/codebert-solidity-vulnerability")
30
+ model.eval()
31
+
32
+ contract_code = "pragma solidity ^0.8.0; contract Test { }"
33
+
34
+ inputs = tokenizer(contract_code, truncation=True, padding=True, max_length=512, return_tensors='pt')
35
+ with torch.no_grad():
36
+ outputs = model(**inputs)
37
+ prediction = torch.argmax(outputs.logits, dim=1).item()
38
+
39
+ print('VULNERABLE' if prediction == 1 else 'SAFE')
40
+
41
+ ## Citation
42
+ Ahmadjee, S. (2026). Vulnerability Detection in LLM-Generated Solidity Smart Contracts Using Fine-Tuned CodeBERT.