Skip to main content
QUICK REVIEW

[论文解读] An Empirical Evaluation of Pre-trained Large Language Models for Repairing Declarative Formal Specifications

Mohannad Alhanahnah, Md Rashedul Hasan|arXiv (Cornell University)|Apr 17, 2024
Natural Language Processing TechniquesComputer Science被引用 3
一句话总结

本文提出了一种用于修复有缺陷的 Alloy 规范的双智能体 LLM 流水线,通过修复智能体(Repair Agent)和提示智能体(Prompt Agent)迭代修复声明式形式规范。GPT-4 变体在修复有效性方面优于现有 APR 工具,尽管运行时间和令牌使用量略有增加,显示出 LLM 在声明式规范修复方面具有强大潜力。

ABSTRACT

Automatic Program Repair (APR) has garnered significant attention as a practical research domain focused on automatically fixing bugs in programs. While existing APR techniques primarily target imperative programming languages like C and Java, there is a growing need for effective solutions applicable to declarative software specification languages. This paper systematically investigates the capacity of Large Language Models (LLMs) to repair declarative specifications in Alloy, a declarative formal language used for software specification. We designed 12 different repair settings, encompassing single-agent and dual-agent paradigms, utilizing various LLMs. These configurations also incorporate different levels of feedback, including an auto-prompting mechanism for generating prompts autonomously using LLMs. Our study reveals that dual-agent with auto-prompting setup outperforms the other settings, albeit with a marginal increase in the number of iterations and token usage. This dual-agent setup demonstrated superior effectiveness compared to state-of-the-art Alloy APR techniques when evaluated on a comprehensive set of benchmarks. This work is the first to empirically evaluate LLM capabilities to repair declarative specifications, while taking into account recent trending LLM concepts such as LLM-based agents, feedback, auto-prompting, and tools, thus paving the way for future agent-based techniques in software engineering.

研究动机与目标

  • 探究预训练大规模语言模型(LLMs)在 Alloy 中自动修复声明式形式规范的可行性。
  • 解决声明式语言自动程序修复(APR)中存在的空白,相较于命令式语言,声明式语言缺乏成熟解决方案。
  • 设计并评估一种新颖的双智能体 LLM 流水线,通过自适应提示和迭代优化提升修复准确性。
  • 在综合基准上对 LLM 修复与最先进 Alloy APR 技术(如 ARepair、ICEBAR、BeAFix、ATR)进行基准测试。
  • 从运行时间、令牌使用量和货币成本等方面分析 LLM 修复的性能、成本和失败特征。

提出的方法

  • 提出一种双智能体 LLM 框架:修复智能体负责生成修复方案,提示智能体则为每次修复迭代动态生成上下文感知的提示。
  • 采用迭代修复流程,对每个规范在六种不同设置下最多执行六次修复尝试,设置间变化包括 LLM 模型和提示策略。
  • 使用标准化提示,输入结构化,包括有缺陷的规范、断言违规信息以及 Alloy Analyzer 生成的反例追踪。
  • 整合来自 Alloy Analyzer 的反馈,指导 LLM 向正确修复方向演进,利用基于断言的预言机进行验证。
  • 在多个实验设置中使用 GPT-3.5-Turbo 和 GPT-4 变体(包括 GPT-4-Turbo 和 GPT-4-32k)以评估性能差异。
  • 通过正确性、运行时间、令牌消耗和货币成本来衡量修复成功率,并将可复现结果发布于 https://github.com/Mohannadcse/AlloySpecRepair。
Figure 1 . LLM-assisted APR Pipeline.
Figure 1 . LLM-assisted APR Pipeline.

实验结果

研究问题

  • RQ1RQ1:与最先进 APR 工具相比,LLMs 在修复有缺陷的 Alloy 规范方面的有效性如何?
  • RQ2RQ2:使用双智能体框架(修复智能体 + 提示智能体)如何影响修复性能和适应性?
  • RQ3RQ3:不同 LLM 及其设置在运行时间、令牌使用量和货币成本方面的性能与成本权衡如何?
  • RQ4RQ4:LLM 修复的失败特征是什么?这些特征在不同模型和设置间如何变化?
  • RQ5RQ5:提示设计和智能体使用如何影响修复成本和成功率?

主要发现

  • GPT-4 变体在 ARepair 基准上的修复成功率达到 78.6%,在 Alloy4Fun 基准上达到 82.1%,显著优于现有 APR 工具(如 ARepair 和 BeAFix)。
  • 与单智能体基线相比,双智能体流水线将修复有效性提升了 12.3%,证明了自适应提示和迭代优化的价值。
  • GPT-4-Turbo 在每修复一次的货币成本上最低,相比 GPT-4-32k 降低了 15.7%,主要得益于更低的令牌定价。
  • 在 GPT-4-Turbo 设置(设置-5)中,修复成功错误的中位修复时间为 493.28 秒;而在设置-4 中,未修复错误的中位修复时间为 392.2 秒,表明失败修复的计算成本更高。
  • 使用提示智能体的设置(设置-3 和 6)相比无提示智能体的设置,令牌使用量高出 8.4%,货币成本高出 11.2%,反映出动态提示生成的成本。
  • 研究发现,由于提示设计导致的修复结果偏差不显著,标准化提示和敏感性分析证实了在各种配置下的鲁棒性。
Figure 2 . Venn diagrams illustrating the exclusive and overlapping cases of successful repairs by different repair methods, highlighting the complementary and unique capabilities of the APR pipeline compared to SoTA repair tools.
Figure 2 . Venn diagrams illustrating the exclusive and overlapping cases of successful repairs by different repair methods, highlighting the complementary and unique capabilities of the APR pipeline compared to SoTA repair tools.

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。