Downloads · 30 days
0
audicarkey/llama2-smart-contract-vulnerability-detector
llama2-smart-contract-vulnerability-detector is a machine learning model from audicarkey. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Fine-tuned Llama-2-7b-chat model for detecting vulnerabilities in Solidity smart contracts.
Downloads · 30 days
0
Access
Public
Updated Aug 16, 2025
Repo size
320 MB
Likes
0
Public
Click a slice to open those files.
.safetensors320 MB · 99%
From the Hugging Face model README
Fine-tuned Llama-2-7b-chat model for detecting vulnerabilities in Solidity smart contracts.
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
import torch
# Load base model
base_model = AutoModelForCausalLM.from_pretrained(
"NousResearch/Llama-2-7b-chat-hf",
torch_dtype=torch.float16,
device_map="auto"
)
# Load LoRA adapter
model = PeftModel.from_pretrained(base_model, "audicarkey/llama2-smart-contract-vulnerability-detector")
tokenizer = AutoTokenizer.from_pretrained("audicarkey/llama2-smart-contract-vulnerability-detector")
# Analyze smart contract
prompt = '''<s>[INST] <<SYS>>
You are a security expert who analyzes smart contracts for vulnerabilities.
<</SYS>>
Analyze this smart contract and identify any vulnerabilities:
[YOUR_SMART_CONTRACT_CODE] [/INST]'''
inputs = tokenizer(prompt, return_tensors="pt")
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=512,
temperature=0.2,
top_p=0.95,
do_sample=True
)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response[len(prompt):].strip())
If you use this model, please cite appropriately and follow ethical AI practices.