Smart-LLaMA-DPO: Reinforced Large Language Model for Explainable Smart Contract Vulnerability Detection
On the map: LLM alignment / RLHF / preference optimisation → Safety alignment and jailbreak attacks
Abstract (arXiv)
Smart contract vulnerability detection remains a major challenge in blockchain security. Existing vulnerability detection methods face two main issues: (1) Existing datasets lack comprehensive coverage and high-quality explanations for preference learning. (2) Large language models (LLMs) often struggle with accurately interpreting specific concepts in smart contract security. Empirical analysis shows that even after continual pre-training (CPT) and supervised fine-tuning (SFT), LLMs may misinterpret the execution order of state changes, resulting in incorrect explanations despite making correct detection decisions. To address these challenges, we propose Smart-LLaMA-DPO based on LLaMA-3.1-8B. We construct a comprehensive dataset covering four major vulnerability types and machine-unauditable vulnerabilities, including precise labels, explanations, and locations for SFT, as well as high-quality and low-quality output pairs for Direct Preference Optimization (DPO). Second, we perform CPT using large-scale smart contract to enhance the LLM's understanding of specific security practices in smart contracts. Futhermore, we conduct SFT with our comprehensive dataset. Finally, we apply DPO, leveraging human feedback and a specially designed loss function that increases the probability of preferred explanations while reducing the likelihood of non-preferred outputs. We evaluate Smart-LLaMA-DPO on four major vulnerability types: reentrancy, timestamp dependence, integer overflow/underflow, and delegatecall, as well as machine-unauditable vulnerabilities. Our method significantly outperforms state-of-the-art baselines, with average improvements of 10.43% in F1 score and 7.87% in accuracy. Moreover, both LLM evaluation and human evaluation confirm that our method generates more correct, thorough, and clear explanations.
Key facts. Cited by 7 papers in the map (data through 14 Oct 2026). Placed in Safety alignment and jailbreak attacks, one of 10 directions in LLM alignment / RLHF / preference optimisation. Builds on 34 of its 78 references that are in the map. First posted on arXiv 23 Jun 2025.
Builds on
34 of 78 references.
References · 34
- 2024The Llama 3 Herd of Modelscited by 14,715
- 2016Semi-Supervised Classification with Graph Convolutional Networkscited by 11,361
- 2023Direct Preference Optimization: Your Language Model is Secretly a Reward Modelcited by 8,065
- 2022Self-Consistency Improves Chain of Thought Reasoning in Language Modelscited by 5,708
- 2024Qwen2 Technical Reportcited by 2,120
- 2024LlamaFactory: Unified Efficient Fine-Tuning of 100+ Language Modelscited by 1,464
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 906
- 2018The Adverse Effects of Code Duplication in Machine Learning Models of Codecited by 126
- 2019Slither: A Static Analysis Framework For Smart Contractscited by 89
- 2023GPTScan: Detecting Logic Vulnerabilities in Smart Contracts by Combining GPT with Program Analysiscited by 65
- 2018Securify: Practical Security Analysis of Smart Contractscited by 61
- 2024LLM4Vuln: A Unified Evaluation Framework for Decoupling and Enhancing LLMs' Vulnerability Reasoningcited by 59
22 more
- 2023When ChatGPT Meets Smart Contract Vulnerability Detection: How Far Are We?cited by 42
- 2024Combining Fine-Tuning and LLM-based Agents for Intuitive Smart Contract Auditing with Justificationscited by 41
- 2023Do you still need a manual smart contract audit?cited by 35
- 2019A Survey on Ethereum Systems Security: Vulnerabilities, Attacks and Defensescited by 25
- 2021Smart Contract Vulnerability Detection: From Pure Neural Network to Interpretable Graph Feature and Expert Pattern Fusioncited by 24
- 2020sFuzz: An Efficient Adaptive Fuzzer for Solidity Smart Contractscited by 19
- 2020SmartBugs: A Framework to Analyze Solidity Smart Contractscited by 18
- 2021Faults in Deep Reinforcement Learning Programs: A Taxonomy and A Detection Approachcited by 18
- 2023Efficient Avoidance of Vulnerabilities in Auto-completed Smart Contract Code Using Vulnerability-constrained Decodingcited by 14
- 2024IRCoCo: Immediate Rewards-Guided Deep Reinforcement Learning for Code Completioncited by 13
- 2021Deep Reinforcement Learning for Black-Box Testing of Android Appscited by 10
- 2021SAILFISH: Vetting Smart Contract State-Inconsistency Bugs in Secondscited by 10
- 2023Rethinking Smart Contract Fuzzing: Fuzzing With Invocation Ordering and Important Branch Revisitingcited by 10
- 2024DeepREST: Automated Test Case Generation for REST APIs Exploiting Deep Reinforcement Learningcited by 8
- 2024Smart-LLaMA: Two-Stage Post-Training of Large Language Models for Smart Contract Vulnerability Detection and Explanationcited by 8
- 2019Security Analysis Methods on Ethereum Smart Contract Vulnerabilities: A Surveycited by 7
- 2023RLocator: Reinforcement Learning for Bug Localizationcited by 7
- 2023Adaptive REST API Testing with Reinforcement Learningcited by 7
- 2017Blockchain-based Smart Contracts: A Systematic Mapping Studycited by 5
- 2019SmartEmbed: A Tool for Clone and Bug Detection in Smart Contracts through Structural Code Embeddingcited by 4
- 2018EASYFLOW: Keep Ethereum Away From Overflowcited by 3
- 2023Language Models are Better Bug Detector Through Code-Pair Classificationcited by 3
Built on by
Citing papers per year: 2025: 1; 2026: 6.
7 papers.
- 2026From SFT to RL: Demystifying the Post-Training Pipeline for LLM-based Vulnerability Detectioncited by 4
- 2025SAEL: Leveraging Large Language Models with Adaptive Mixture-of-Experts for Smart Contract Vulnerability Detectioncited by 2
- 2026TxRay: Agentic Postmortem of Live Blockchain Attackscited by 2
- 2026Who Does What? Archetypes of Roles Assigned to LLMs During Human-AI Decision-Makingcited by 0
- 2026Robust Smart Contract Vulnerability Detection via Contrastive Learning-Enhanced Granular-ball Trainingcited by 0
- 2026SoK: A Systematic Bidirectional Literature Review of AI & DLT Convergencecited by 0
- 2026Frequency-Aware Continual Learning for Smart Contract Vulnerability Detection with Large Language Modelscited by 0
- 2026Frequency-Aware Continual Learning for Smart Contract Vulnerability Detection with Large Language Models20 Aug 2026
- 2026SoK: A Systematic Bidirectional Literature Review of AI & DLT Convergence11 May 2026
- 2026Robust Smart Contract Vulnerability Detection via Contrastive Learning-Enhanced Granular-ball Training29 Mar 2026
- 2026From SFT to RL: Demystifying the Post-Training Pipeline for LLM-based Vulnerability Detection15 Feb 2026
- 2026Who Does What? Archetypes of Roles Assigned to LLMs During Human-AI Decision-Making12 Feb 2026
- 2026TxRay: Agentic Postmortem of Live Blockchain Attacks1 Feb 2026
- 2025SAEL: Leveraging Large Language Models with Adaptive Mixture-of-Experts for Smart Contract Vulnerability Detection30 Jul 2025
Similar, not cited
Close in wording, no citation either way
- 2025ParaVul: A Parallel Large Language Model and Retrieval-Augmented Framework for Smart Contract Vulnerability Detection
- 2025LLM-BSCVM: An LLM-Based Blockchain Smart Contract Vulnerability Management Framework
- 2024LLM-SmartAudit: Advanced Smart Contract Vulnerability Detection
- 2025Large Language Model based Smart Contract Auditing with LLMBugScanner
- 2025ETrace:Event-Driven Vulnerability Detection in Smart Contracts via LLM-Based Trace Analysis
- 2026Benchmarking Zero-Shot Reasoning Approaches for Error Detection in Solidity Smart Contracts
- 2024Detection Made Easy: Potentials of Large Language Models for Solidity Vulnerabilities
- 2024Retrieval Augmented Generation Integrated Large Language Models in Smart Contract Vulnerability Detection