Solidity Vulnerability Classifier โ€” Unchecked Low-Level Calls

Binary classifier that detects Unchecked Low-Level Calls 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 q_proj, k_proj, v_proj, o_proj
  • Classification head: modules_to_save=["score"]

Available Checkpoints

Load a specific checkpoint with revision=:

model = PeftModel.from_pretrained(base, "jhsu12/solidity-vuln-cls-unchecked-low-level-calls-v1", revision="checkpoint-200")
Tag Step
checkpoint-27 27
checkpoint-54 54
checkpoint-81 81
checkpoint-108 108
checkpoint-135 135 โ† main

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-unchecked-low-level-calls-v1")
model.eval()

tokenizer = AutoTokenizer.from_pretrained("jhsu12/solidity-vuln-cls-unchecked-low-level-calls-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-unchecked-low-level-calls-v1 --file contract.sol

Part of

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
Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for jhsu12/solidity-vuln-cls-unchecked-low-level-calls-v1

Base model

Qwen/Qwen2.5-3B
Adapter
(45)
this model