jhsu12/solidity-vuln-cls-integer-overflow-underflow-v1
04
Solidity Vulnerability Classifier — Integer Overflow/Underflow
Binary classifier that detects Integer Overflow/Underflow vulnerabilities in Solidity smart contracts.
Model Details
- Base model: Qwen/Qwen2.5-Coder-3B-Instruct
- Method: QLoRA (4-bit NF4) + classification head
- Task: Sequence Classification (2 labels: safe / vulnerable)
- LoRA rank: 16, targeting qproj, kproj, vproj, oproj
- Classification head:
modules_to_save=["score"]
Available Checkpoints
Load a specific checkpoint with revision=:
model = PeftModel.from_pretrained(base, "jhsu12/solidity-vuln-cls-integer-overflow-underflow-v1", revision="checkpoint-200")Usage
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.solPart of
This is one of 5 expert classifiers in the Solidity Vulnerability Detector system.
