用多智能体和思维链技术提升代码缺陷检测能力
FGDM: Reasoning Aware Multi-Agentic Framework for Software Bug Detection using Chain of Thought and Tree of Thought Prompting

- 构建四智能体框架,结合流程图与思维链推理
- 在Python和C代码上分别降低24.33和8.37的编辑距离
- 适合需要高精度缺陷检测的开发者与研究者
深度学习方法在自动化软件缺陷检测中日益重要,但缺乏对代码全局结构的理解,尤其在大型互连代码库或复杂模块化程序中性能下降。最近,大语言模型(LLMs)在捕捉代码库中多模块依赖关系方面表现出色。为此,我们提出流图驱动的多智能体框架(FGDM),由四个按序协作的智能体组成。该框架将输入代码转换为流图,识别错误片段,并生成修复代码。所有智能体均采用思维链(Chain-of-Thought, COT)和树状思维(Tree-of-Thoughts, TOT)提示。此外,集成FAISS向量数据库以检索历史相似缺陷及其修复方案。我们在包括Ansible、Black、FastAPI、Keras、Luigi、Matplotlib、Pandas、Scrapy、SpaCy、Tornado在内的100个程序中验证了该框架的有效性,涵盖C和Python语言。实验表明,相比现有方法,FGDM在Python和C代码上分别实现了24.33和8.37的平均编辑距离降低,以及0.951和0.974的余弦相似度提升。
原文摘要 · Abstract (English)
Deep Learning methods are becoming prominent in automated software bug detection; however, they lack the global understanding of the given code. Consequently, their performance tends to degrade, especially when they are applied to large interconnected code bases or complex modular programs. Recently, Large Language Models (LLMs) have proven to be effective at capturing dependencies among multiple interconnected modules in the codebase. This motivated us to propose the Flow-Graph-Driven Multi-Agent Framework (FGDM), which is composed of four agents that operate in a sequential manner. The framework converts the received code to a flow graph, identifies the erroneous segments, and further generates the repaired code. All the employed agents utilize Chain-of-Thought (COT) and Tree-of-Thoughts (TOT) prompts. Additionally, we also integrated with the FAISS vector database to retrieve similar previous bugs and their repairs. We demonstrated the efficacy of the proposed framework over 100 programs from several projects, including Ansible, Black, FastAPI, Keras, Luigi, Matplotlib, Pandas, Scrapy, SpaCy, and Tornado in both C and Python programs. Our experiments demonstrate that the FGDM outperforms the extant approaches and yielded reductions with a mean of 24.33 and 8.37 in Levenshtein distance and similarities of 0.951 and 0.974 in cosine similarity for Python and C, respectively.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。