Better Patching Using LLM Prompting, via Self-Consistency
Authors:
- 11 September 2023
- conference paper
- Published by Institute of Electrical and Electronics Engineers (IEEE)
- p. 1742-1746
Abstract
Large Language models (LLMs) can be induced to solve non-trivial problems with “few-shot” prompts including illustrative problem-solution examples. Now if the few-shots also include “chain of thought” ( $\mathcal{C}oT$ ) explanations, which are of the form problem-explanation-solution, LLMs will generate a “explained” solution, and perform even better. Recently an exciting, substantially better technique, self-consistency [1] ( $\mathcal{S}-C$ ) has emerged, based on the intuition that there are many plausible explanations for the right solution; when the LLM is sampled repeatedly to generate a pool of explanation-solution pairs, for a given problem, the most frequently occurring solutions in the pool (ignoring the explanations) tend to be even more likely to be correct! Unfortunately, the use of this highly-performant $\mathcal{S}-C$ (or even $\mathcal{C}oT$ ) approach in software engineering settings is hampered by the lack of explanations; most software datasets lack explanations. In this paper, we describe an application of the $\mathcal{S}-C$ approach to program repair, using the commit log on the fix as the explanation, only in the illustrative few-shots. We achieve state-of-the art results, beating previous approaches to prompting-based program repair, on the MODIT dataset; we also find evidence suggesting that the correct commit messages are helping the LLM learn to produce better patches.
Keywords
All Related Versions
Funding Information
- National Science Foundation (2107592)
This publication has 16 references indexed in Scilit:
- A systematic evaluation of large language models of code2022
- On Multi-Modal Learning of Editing Source Code2021
- CURE: Code-Aware Neural Machine Translation for Automatic Program Repair2021
- CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation2021
- CoCoNuT: combining context-aware neural translation models using ensemble for program repair2020
- An Empirical Study on Learning Bug-Fixing Patches in the Wild via Neural Machine TranslationACM Transactions on Software Engineering and Methodology, 2019
- QuixBugs: a multi-lingual program repair benchmark set based on the quixey challenge2017
- Defects4J: a database of existing faults to enable controlled testing studies for Java programs2014
- The Probabilistic Relevance Framework: BM25 and BeyondFoundations and Trends® in Information Retrieval, 2009
- Note on the Sampling Error of the Difference Between Correlated Proportions or PercentagesPsychometrika, 1947