Downloads · 30 days
12
12% of all-time downloads
askalgore/llama-3.2-3b-A1.5
llama-3.2-3b-A1.5 is a text generation model from askalgore. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as mit.
A LoRA fine-tuned Llama 3.2 3B model for decompiling EVM smart contract bytecode into human-readable Solidity source code.
Downloads · 30 days
12
12% of all-time downloads
All-time downloads
100
Public
Repo size
115 MB
Likes
1
Public
Click a slice to open those files.
.safetensors97.3 MB · 85%
From the Hugging Face model README
A LoRA fine-tuned Llama 3.2 3B model for decompiling EVM smart contract bytecode into human-readable Solidity source code.
This model implements the methodology from "Decompiling Smart Contracts with a Large Language Model" (arXiv:2506.19624v1).
Traditional decompilers (Panoramix, Heimdall) produce low-level, hard-to-read output with 0.4–0.5 semantic similarity to original source. This model achieves 0.82 semantic similarity by combining deterministic static analysis with neural code generation in a two-stage pipeline:
| Property | Value |
|---|---|
| Base Model | meta-llama/Llama-3.2-3B |
| Fine-tuning Method | LoRA (Low-Rank Adaptation) via PEFT |
| Task | Causal Language Modeling (CAUSAL_LM) |
| LoRA Rank (r) | 16 |
| LoRA Alpha | 32 |
| LoRA Dropout | 0.1 |
| Target Modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Trainable Parameters | 13,631,488 (0.42% of 3.2B total) |
| Max Sequence Length | 4,096 tokens |
bytecode, tac, and solidity fieldsBytecodeAnalyzer (static analysis with control flow, basic blocks, dominance analysis, loop detection) → paired with the verified Solidity source| Parameter | Value |
|---|---|
| Epochs | 3 |
| Batch Size (per device) | 1 |
| Gradient Accumulation Steps | 8 |
| Effective Batch Size | 8 |
| Optimizer | AdamW (8-bit via bitsandbytes) |
| Learning Rate | 2×10⁻⁴ |
| LR Scheduler | Cosine |
| Warmup Steps | 3 |
| Weight Decay | 0.01 |
| Max Gradient Norm | 1.0 |
| FP16 | Yes |
| Gradient Checkpointing | Yes |
| Metric | Value |
|---|---|
| Final Training Loss | 0.6553 |
| Training Duration | ~31 minutes |
| Total Optimization Steps | 285 |
| Hardware | NVIDIA RTX 4080 (16 GB VRAM) |
| Training Date | July 4, 2025 |
| Metric | Target | Description |
|---|---|---|
| Semantic Similarity | > 0.80 | CodeBERT embedding cosine similarity |
| Edit Distance | < 0.40 | Normalized Levenshtein distance |
| Success Rate | > 78% | Percentage of functions exceeding similarity threshold |
| Feature | This Model | Panoramix | Heimdall |
|---|---|---|---|
| Semantic Similarity | ~0.82 | ~0.45 | ~0.40 |
| Readable Output | ✅ | Partial | Partial |
| Variable Naming | Inferred | Generic | Generic |
| Function Signatures | ✅ | ✅ | ✅ |
| Complex Logic | Good | Limited | Limited |
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
# Load base model
base_model = AutoModelForCausalLM.from_pretrained(
"meta-llama/Llama-3.2-3B",
device_map="auto",
load_in_8bit=True,
)
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.2-3B")
# Load LoRA adapter
model = PeftModel.from_pretrained(base_model, "askalgore/llama-3.2-3b-A1.5")
from src.model_setup import SmartContractLLM
llm = SmartContractLLM()
llm.load_model("models/final_model")
result = llm.generate(tac_input)
### Task: Convert the following Three-Address Code (TAC) representation to Solidity source code.
### TAC:
{tac_representation}
### Solidity:
The model generates Solidity code following the ### Solidity: marker.
TAC is an intermediate representation produced by the static analysis stage. It captures:
Example TAC snippet:
Block_0:
temp_1 = CALLDATALOAD(0)
temp_2 = SHR(224, temp_1)
IF temp_2 == 0x70a08231 GOTO Block_balanceOf
IF temp_2 == 0xa9059cbb GOTO Block_transfer
GOTO Block_fallback
🔗 GitHub — A1.5_Smart_Contract_Bytecode_To_Code_Generator
The repository includes:
If you use this model, please cite the underlying research paper:
@article{david2025decompiling,
title={Decompiling Smart Contracts with a Large Language Model},
author={David, Sifei and Zhou, Zhiyu and Song, Xuan and Gervais, Arthur and Qin, Benjamin},
journal={arXiv preprint arXiv:2506.19624v1},
year={2025}
}
This model adapter is released under the MIT License. The base model (Llama 3.2 3B) is subject to Meta's Llama Community License.