Downloads · 30 days
6
12% of all-time downloads
jhsu12/solidity-vuln-cls-integer-overflow-underflow-v1
solidity-vuln-cls-integer-overflow-underflow-v1 is a text classification model from jhsu12. Use it when you need a label for a piece of text. It is set up for peft. The card lists the license as apache-2.0.
Binary classifier that detects Integer Overflow/Underflow vulnerabilities in Solidity smart contracts.
Downloads · 30 days
6
12% of all-time downloads
All-time downloads
52
Public
Repo size
159 MB
Likes
0
Public
Click a slice to open those files.
.safetensors29.5 MB · 72%
From the Hugging Face model README
Binary classifier that detects Integer Overflow/Underflow vulnerabilities in Solidity smart contracts.
modules_to_save=["score"]Load a specific checkpoint with revision=:
model = PeftModel.from_pretrained(base, "jhsu12/solidity-vuln-cls-integer-overflow-underflow-v1", revision="checkpoint-200")
| Tag | Step |
|---|---|
checkpoint-316 | 316 |
checkpoint-632 | 632 |
checkpoint-948 | 948 |
checkpoint-1264 | 1264 |
checkpoint-1580 | 1580 ← main |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, BitsAndBytesConfig
from peft import PeftModel
import torch
base_model = "Qwen/Qwen2.5-Coder-3B-Instruct"
bnb_config = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16, bnb_4bit_use_double_quant=True)
model = AutoModelForSequenceClassification.from_pretrained(
base_model, num_labels=2, quantization_config=bnb_config,
device_map="auto", trust_remote_code=True, ignore_mismatched_sizes=True)
model = PeftModel.from_pretrained(model, "jhsu12/solidity-vuln-cls-integer-overflow-underflow-v1")
model.eval()
tokenizer = AutoTokenizer.from_pretrained("jhsu12/solidity-vuln-cls-integer-overflow-underflow-v1", trust_remote_code=True)
code = "pragma solidity ^0.8.0; contract Example { ... }"
inputs = tokenizer(code, return_tensors="pt", truncation=True, max_length=1536).to(model.device)
with torch.no_grad():
logits = model(**inputs).logits
probs = torch.softmax(logits, dim=-1)
print(f"Safe: {probs[0][0]:.2%}, Vulnerable: {probs[0][1]:.2%}")
Or use the inference script:
python inference_classifier.py --checkpoint jhsu12/solidity-vuln-cls-integer-overflow-underflow-v1 --file contract.sol
This is one of 5 expert classifiers in the Solidity Vulnerability Detector system.
| Expert | Hub Repo |
|---|---|
| Reentrancy | jhsu12/solidity-vuln-cls-reentrancy-v1 |
| Access Control | jhsu12/solidity-vuln-cls-access-control-v1 |
| Integer Overflow/Underflow | jhsu12/solidity-vuln-cls-integer-overflow-underflow-v1 |
| Timestamp Dependence | jhsu12/solidity-vuln-cls-timestamp-dependence-v1 |
| Unchecked Low-Level Calls | jhsu12/solidity-vuln-cls-unchecked-low-level-calls-v1 |