用并行大模型与检索增强提升智能合约漏洞检测准确率
ParaVul: A Parallel Large Language Model and Retrieval-Augmented Framework for Smart Contract Vulnerability Detection
- 采用稀疏低秩适配微调模型,降低计算开销
- 融合密集检索与BM25,F1最高达0.9398
- 适合区块链安全研究者与开发人员使用
智能合约在自动化区块链服务中至关重要,但其漏洞严重威胁系统安全。传统静态分析和形式化验证存在误报率高、可扩展性差的问题。近期大语言模型(LLM)在漏洞检测方面取得进展,但仍面临推理成本高、计算开销大的挑战。本文提出ParaVul,一种并行大语言模型与检索增强框架,以提升检测可靠性与准确性。首先,设计稀疏低秩适配(SLoRA)用于微调LLM,通过引入稀疏矩阵优化量化后的LoRA模型,在降低计算资源需求的同时增强对漏洞语义的理解能力。其次,构建漏洞合约数据集,并开发混合检索增强生成(RAG)系统,结合密集检索与最佳匹配25(BM25)以辅助验证LLM输出。此外,提出元学习模型融合RAG与LLM结果,生成最终检测结论。完成检测后,使用思维链提示引导LLM生成完整漏洞报告。仿真结果表明,ParaVul在单标签检测中F1得分为0.9398,多标签检测为0.9330,显著优于现有方法。
原文摘要 · Abstract (English)
Smart contracts play a significant role in automating blockchain services. Nevertheless, vulnerabilities in smart contracts pose serious threats to blockchain security. Currently, traditional detection methods primarily rely on static analysis and formal verification, which can result in high false-positive rates and poor scalability. Large Language Models (LLMs) have recently made significant progress in smart contract vulnerability detection. However, they still face challenges such as high inference costs and substantial computational overhead. In this paper, we propose ParaVul, a parallel LLM and retrieval-augmented framework to improve the reliability and accuracy of smart contract vulnerability detection. Specifically, we first develop Sparse Low-Rank Adaptation (SLoRA) for LLM fine-tuning. SLoRA introduces sparsification by incorporating a sparse matrix into quantized LoRA-based LLMs, thereby reducing computational overhead and resource requirements while enhancing their ability to understand vulnerability-related issues. We then construct a vulnerability contract dataset and develop a hybrid Retrieval-Augmented Generation (RAG) system that integrates dense retrieval with Best Matching 25 (BM25), assisting in verifying the results generated by the LLM. Furthermore, we propose a meta-learning model to fuse the outputs of the RAG system and the LLM, thereby generating the final detection results. After completing vulnerability detection, we design chain-of-thought prompts to guide LLMs to generate comprehensive vulnerability detection reports. Simulation results demonstrate the superiority of ParaVul, especially in terms of F1 scores, achieving 0.9398 for single-label detection and 0.9330 for multi-label detection.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。