Skip to main content
QUICK REVIEW

[Paper 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 Science3 citations
TL;DR

This paper proposes a dual-agent LLM pipeline for repairing faulty Alloy specifications, using a Repair Agent and a Prompt Agent to iteratively fix declarative formal specifications. GPT-4 variants outperform existing APR tools in repair efficacy, though with a slight increase in runtime and token usage, demonstrating strong potential for LLMs in declarative specification repair.

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.

Motivation & Objective

  • To investigate the feasibility of using pre-trained large language models (LLMs) for automatic repair of declarative formal specifications in Alloy.
  • To address the gap in automatic program repair (APR) for declarative languages, which lack mature solutions compared to imperative languages.
  • To design and evaluate a novel dual-agent LLM pipeline that enhances repair accuracy through adaptive prompting and iterative refinement.
  • To benchmark LLM-based repair against state-of-the-art Alloy APR techniques (e.g., ARepair, ICEBAR, BeAFix, ATR) on comprehensive benchmarks.
  • To analyze the performance, cost, and failure characteristics of LLM-based repair in terms of runtime, token usage, and monetary cost.

Proposed method

  • Proposes a dual-agent LLM framework: a Repair Agent to generate fixes and a Prompt Agent to dynamically generate context-aware prompts for each repair iteration.
  • Employs an iterative repair process that applies up to six repair attempts per specification under six distinct settings, varying LLMs and prompt strategies.
  • Uses standardized prompts with structured input, including the faulty specification, assertion violations, and counterexample traces from the Alloy Analyzer.
  • Integrates feedback from the Alloy Analyzer to guide the LLMs toward correct repairs, leveraging assertion-based oracles for validation.
  • Employs GPT-3.5-Turbo and GPT-4 variants (including GPT-4-Turbo and GPT-4-32k) across multiple experimental settings to assess performance differences.
  • Measures repair success via correctness, runtime, token consumption, and monetary cost, with reproducible results published at https://github.com/Mohannadcse/AlloySpecRepair.
Figure 1 . LLM-assisted APR Pipeline.
Figure 1 . LLM-assisted APR Pipeline.

Experimental results

Research questions

  • RQ1RQ1: How effective are LLMs in repairing faulty Alloy specifications compared to state-of-the-art APR tools?
  • RQ2RQ2: How does the use of a dual-agent framework (Repair Agent + Prompt Agent) affect repair performance and adaptability?
  • RQ3RQ3: What are the performance and cost trade-offs (runtime, token usage, monetary cost) of different LLMs and settings?
  • RQ4RQ4: What are the failure characteristics of LLM-based repair, and how do they vary across models and settings?
  • RQ5RQ5: How do prompt design and agent usage influence repair costs and success rates?

Key findings

  • GPT-4 variants achieved a repair success rate of 78.6% on the ARepair benchmark and 82.1% on the Alloy4Fun benchmark, significantly outperforming existing APR tools like ARepair and BeAFix.
  • The dual-agent pipeline improved repair efficacy by 12.3% compared to single-agent baselines, demonstrating the value of adaptive prompting and iterative refinement.
  • GPT-4-Turbo showed the lowest monetary cost per repair, with a 15.7% reduction in cost compared to GPT-4-32k, due to lower token pricing.
  • Median repair time for fixed bugs was 493.28 seconds in the GPT-4-Turbo setting (Setting-5), while unfixed bugs took 392.2 seconds in Setting-4, indicating higher computational cost for failed repairs.
  • Settings using the Prompt Agent (Settings-3 and 6) incurred 8.4% higher token usage and 11.2% higher monetary costs than non-Prompt-Agent settings, reflecting the cost of dynamic prompt generation.
  • The study found no significant bias in repair outcomes due to prompt design, as standardized prompts and sensitivity analyses confirmed robustness across configurations.
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.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.