Towards Minimal Edits in Automated Program Repair: A Hybrid Framework Integrating Graph Neural Networks and Large Language Models
摘要
Large Language Models trained on Code (LLMCs) have been shown to be effective in Automated Program Repair (APR) tasks, introducing new innovations to the field. Typically, LLMCs do not engage in error localization for APR tasks, instead treating APR more as a code refinement task. This approach often results in larger edit distances, altering the program’s original structure. The principle of making minimal edits is crucial in certain scenarios, such as when correcting student programming assignments or software group development, where it’s better to preserve the original intent of the code with as few changes as possible. To address these challenges, we introduce a hybrid framework for automated program repair that combines graph neural networks and large language models, which we refer to as HFRepair. HFRepair leverages the precise error localization capability of DrRepair for C programs, combining it with LLMCs to perform the line-level APR task based on the code context, aiming for minimal edits. Our experimental results demonstrate that HFRepair significantly outperforms previous state-of-the-art methods in benchmark tests. For instance, on the DeepFix dataset, HFRepair improves the full repair rate from 67.9% and 71.4% (achieved by DrRepair and BIFI, respectively) to 82.2%, while reducing average edit distance from 33.4 and 27.7 to 11.6.