Text Classification
PEFT
Safetensors
lora
sequence-classification
solidity
smart-contract
vulnerability-detection
access-control
Instructions to use jhsu12/solidity-vuln-cls-access-control-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use jhsu12/solidity-vuln-cls-access-control-v1 with PEFT:
from peft import PeftModel from transformers import AutoModelForSequenceClassification base_model = AutoModelForSequenceClassification.from_pretrained("Qwen/Qwen2.5-Coder-3B-Instruct") model = PeftModel.from_pretrained(base_model, "jhsu12/solidity-vuln-cls-access-control-v1") - Notebooks
- Google Colab
- Kaggle
| library_name: peft | |
| base_model: Qwen/Qwen2.5-Coder-3B-Instruct | |
| tags: | |
| - peft | |
| - lora | |
| - sequence-classification | |
| - solidity | |
| - smart-contract | |
| - vulnerability-detection | |
| - access-control | |
| pipeline_tag: text-classification | |
| license: apache-2.0 | |
| # Solidity Vulnerability Classifier — Access Control | |
| Binary classifier that detects **Access Control** vulnerabilities in Solidity smart contracts. | |
| ## Model Details | |
| - **Base model**: [Qwen/Qwen2.5-Coder-3B-Instruct](https://huggingface.co/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=`: | |
| ```python | |
| model = PeftModel.from_pretrained(base, "jhsu12/solidity-vuln-cls-access-control-v1", revision="checkpoint-200") | |
| ``` | |
| | Tag | Step | | |
| |-----|------| | |
| | `checkpoint-28` | 28 | | |
| | `checkpoint-56` | 56 | | |
| | `checkpoint-84` | 84 | | |
| | `checkpoint-112` | 112 | | |
| | `checkpoint-140` | 140 ← `main` | | |
| ## Usage | |
| ```python | |
| 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-access-control-v1") | |
| model.eval() | |
| tokenizer = AutoTokenizer.from_pretrained("jhsu12/solidity-vuln-cls-access-control-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: | |
| ```bash | |
| python inference_classifier.py --checkpoint jhsu12/solidity-vuln-cls-access-control-v1 --file contract.sol | |
| ``` | |
| ## Part of | |
| This is one of 5 expert classifiers in the | |
| [Solidity Vulnerability Detector](https://huggingface.co/jhsu12/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` | | |