Skip to main content
QUICK REVIEW

[Paper Review] CigaR: Cost-efficient Program Repair with LLMs

Dávid Hidvégi, Khashayar Etemadi|arXiv (Cornell University)|Feb 9, 2024
Parallel Computing and Optimization TechniquesComputer Science8 citations
TL;DR

CigaR is an LLM-based program repair tool that minimizes token cost while repairing bugs; it achieves 62% token-cost reduction and fixes 69 of 267 bugs (25.8% correct patches) on Defects4J, outperforming prior GPT-based APR tools.

ABSTRACT

Large language models (LLM) have proven to be effective at automated program repair (APR). However, using LLMs can be costly, with companies invoicing users by the number of tokens. In this paper, we propose CigaR, the first LLM-based APR tool that focuses on minimizing the repair cost. CigaR works in two major steps: generating a first plausible patch and multiplying plausible patches. CigaR optimizes the prompts and the prompt setting to maximize the information given to LLMs using the smallest possible number of tokens. Our experiments on 429 bugs from the widely used Defects4J and HumanEval-Java datasets shows that CigaR reduces the token cost by 73%. On average, CigaR spends 127k tokens per bug while the baseline uses 467k tokens per bug. On the subset of bugs that are fixed by both, CigaR spends 20k per bug while the baseline uses 608k tokens, a cost saving of 96%. Our extensive experiments show that CigaR is a cost-effective LLM-based program repair tool that uses a low number of tokens to automatically generate patches.

Motivation & Objective

  • Motivate reducing the financial and environmental cost of LLM-based automated program repair (APR).
  • Develop an APR system that minimizes token usage while preserving or improving patch quality.
  • Design and orchestrate prompt strategies to maximize information per token and to explore diverse patches efficiently.
  • Evaluate CigaR on a standard benchmark (Defects4J) against state-of-the-art GPT-based APR tools.

Proposed method

  • Three prompts work in concert: an initiation prompt to generate an initial patch, an improvement prompt to refine partial patches, and a multiplication prompt to generate diverse plausible patches.
  • Iterative prompting with summarization of prior responses to build informative context without excessive token use.
  • Patch multiplication to produce diverse plausible patches, reducing redundant exploration.
  • High-temperature, reboot-based exploration to explore different regions of the search space.
  • Caching of prompts, responses, and test results to enable reproducibility and cost tracking.
  • Implementation uses Python with GPT-3.5-turbo-0301, a sampling temperature of 1, and a token-cost aware workflow.
Figure 1 . Overview of CigaR : CigaR combines original prompting techniques, incl. partial patch improvement, search rebooting and patch multiplication to reach high effectiveness at a low token cost.
Figure 1 . Overview of CigaR : CigaR combines original prompting techniques, incl. partial patch improvement, search rebooting and patch multiplication to reach high effectiveness at a low token cost.

Experimental results

Research questions

  • RQ1How effective is CigaR at generating plausible and correct patches compared with state-of-the-art GPT-based APR tools?
  • RQ2How token-cost efficient is CigaR relative to the baseline in solving Defects4J bugs?
  • RQ3How do rebooting and patch-multiplication contribute to exploring the patch search space and increasing diversity of patches?

Key findings

  • CigaR fixes 69 of 267 bugs (25.8% with exact AST match) and yields 185/267 plausible patches (69.2%) after multiple rounds.
  • CigaR reduces token cost by 62% on average (171K vs. 451K tokens per bug), compared to ChatRepair.
  • On bugs fixed by both tools, CigaR saves 97% of token cost (average 20K vs. 695K tokens).
  • CigaR achieves higher plausibility and patch diversity, with 24 bugs fixed uniquely by CigaR and 45 bugs fixed by either tool in the studied set.
  • Patch exploration strategies (reboots and multiplication) yield increasing numbers of distinct patches, demonstrating effective search space exploration.
Figure 2 . P1: initiation prompt structure used for plausible patch search initiation.
Figure 2 . P1: initiation prompt structure used for plausible patch search initiation.

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.