arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2601.00254cs.SEcs.AI
收藏

基于大型语言模型的代码漏洞检测方法实证评估:RAG、SFT和双智能体系统

An Empirical Evaluation of LLM-Based Approaches for Code Vulnerability Detection: RAG, SFT, and Dual-Agent Systems

Department of Electrical, Computer, and Software Engineering(电气、计算机与软件工程系);Ontario Tech University(安大略技术大学)

Md Hasan Saju, Maher Muhtadi, Akramul Azim

AI总结:

本文通过实证评估,比较了RAG、SFT和双智能体系统在代码漏洞检测中的有效性,发现RAG在准确率和F1分数上表现最佳,SFT和双智能体系统也展示了良好的性能,证明了领域专业知识对LLM在实际漏洞检测中的重要性。

摘要:

大型语言模型(LLMs)的快速发展为自动化软件漏洞检测提供了新的机会,这是保障现代代码库安全的关键任务。本文对基于LLM的技术检测软件漏洞的有效性进行了比较研究。研究评估了三种方法:检索增强生成(RAG)、监督微调(SFT)以及双智能体LLM框架,与基线LLM模型进行对比。数据集从Big-Vul和GitHub上的真实代码仓库中精心编纂,聚焦于五个关键的常见弱点枚举(CWE)类别:CWE-119、CWE-399、CWE-264、CWE-20和CWE-200。我们的RAG方法整合了来自互联网和MITRE CWE数据库的外部领域知识,实现了最高的总体准确率(0.86)和F1分数(0.85),突显了上下文增强的价值。我们的SFT方法使用参数高效的QLoRA适配器实现,也表现出强劲的性能。我们的双智能体系统,一种二次智能体审核和改进主智能体输出的架构,展示了在提高推理透明度和错误缓解方面的潜力,且资源消耗较低。这些结果强调了在实际漏洞检测任务中整合领域专业知识机制显著增强了LLM的实用性。

英文摘要:

The rapid advancement of Large Language Models (LLMs) presents new opportunities for automated software vulnerability detection, a crucial task in securing modern codebases. This paper presents a comparative study on the effectiveness of LLM-based techniques for detecting software vulnerabilities. The study evaluates three approaches, Retrieval-Augmented Generation (RAG), Supervised Fine-Tuning (SFT), and a Dual-Agent LLM framework, against a baseline LLM model. A curated dataset was compiled from Big-Vul and real-world code repositories from GitHub, focusing on five critical Common Weakness Enumeration (CWE) categories: CWE-119, CWE-399, CWE-264, CWE-20, and CWE-200. Our RAG approach, which integrated external domain knowledge from the internet and the MITRE CWE database, achieved the highest overall accuracy (0.86) and F1 score (0.85), highlighting the value of contextual augmentation. Our SFT approach, implemented using parameter-efficient QLoRA adapters, also demonstrated strong performance. Our Dual-Agent system, an architecture in which a secondary agent audits and refines the output of the first, showed promise in improving reasoning transparency and error mitigation, with reduced resource overhead. These results emphasize that incorporating a domain expertise mechanism significantly strengthens the practical applicability of LLMs in real-world vulnerability detection tasks.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑