Instructions to use jhsu12/solidity-vulnerability-detector with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use jhsu12/solidity-vulnerability-detector with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-Coder-7B-Instruct") model = PeftModel.from_pretrained(base_model, "jhsu12/solidity-vulnerability-detector") - Transformers
How to use jhsu12/solidity-vulnerability-detector with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="jhsu12/solidity-vulnerability-detector") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("jhsu12/solidity-vulnerability-detector", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use jhsu12/solidity-vulnerability-detector with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "jhsu12/solidity-vulnerability-detector" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jhsu12/solidity-vulnerability-detector", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/jhsu12/solidity-vulnerability-detector
- SGLang
How to use jhsu12/solidity-vulnerability-detector with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "jhsu12/solidity-vulnerability-detector" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jhsu12/solidity-vulnerability-detector", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "jhsu12/solidity-vulnerability-detector" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jhsu12/solidity-vulnerability-detector", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use jhsu12/solidity-vulnerability-detector with Docker Model Runner:
docker model run hf.co/jhsu12/solidity-vulnerability-detector
See design_document.md for architecture details.
Multi-Expert Smart Contract Vulnerability Detector
This project uses a Router + Type-Specific Expert Adapters architecture to improve smart contract vulnerability detection.
Problem Diagnosis
Current single-model approach achieves only:
- Binary F1: 0.7673 (with 25% parse failures)
- Access Control F1: 0.0235 (essentially undetected)
- Reentrancy precision: 0.0663 (massive hallucinations)
Root Causes
- Severe class imbalance: Integer Overflow 3412 vs tx.origin 11
- Single model trying to learn 6 distinct vulnerability patterns
- No reasoning chains — model memorizes shortcuts
- Rigid output format causes 25% parse failures
Solution: 5 Expert Adapters
Each expert is a LoRA adapter trained to answer: "Is this contract vulnerable with MY specific vulnerability type?"
| Expert | Dataset | Train Pos/Neg |
|---|---|---|
| Reentrancy | jhsu12/solidity-vuln-expert-reentrancy | 767 / 2301 |
| Access Control | jhsu12/solidity-vuln-expert-access-control | 219 / 657 |
| Integer Overflow | jhsu12/solidity-vuln-expert-integer-overflow-underflow | 3412 / 6670 |
| Timestamp Dependence | jhsu12/solidity-vuln-expert-timestamp-dependence | 858 / 2574 |
| Unchecked Low-Level Calls | jhsu12/solidity-vuln-expert-unchecked-low-level-calls | 215 / 645 |
Training
# Train each expert (can run in parallel)
python train_expert.py --expert "Reentrancy"
python train_expert.py --expert "Access Control"
python train_expert.py --expert "Integer Overflow/Underflow"
python train_expert.py --expert "Timestamp Dependence"
python train_expert.py --expert "Unchecked Low-Level Calls"
Evaluation
python evaluate_experts.py --max_samples 200
Research References
- VulnLLM-R (arXiv:2512.07533): Reasoning models with distillation
- Smart-LLaMA-DPO (arXiv:2506.18245): Balanced detection+explanation loss
- SmartLLM (arXiv:2502.13167): Multi-role pipeline (Detector→Reasoner→Verificator)
- SmartVD (arXiv:2409.10574): Composite function F(C)=(binary, type, severity)