Most of the automated program repair (ARP) approaches are learning-based techniques. They treat bug fixes as a neural machine translation task by translating incorrect code into correct code. However, these approaches rely heavily on high-quality bug-fixing pairs and may spend expensive training costs. To alleviate the problems, in this paper, we present TemRepair, a new approach based on mask templates and Large Language Model (LLM), which generate patches through zero-shot learning. First, eight categories of mask templates are summarized by manually analyzing 2,000 bug-fixing pairs, such as modifying method invocation expressions, altering variables, and adjusting operators. Then, mask lines are produced using mask templates, and together with the method context as well as the comments, are input to the Large Language Model (InCoder) to predict the masked sections. Finally, the generated patches are deduplicated and verified. Experimental results on the Defects4J dataset show that, TemRepair can generate 67 correct patches, indicating its superiority over the state-of-the-art approaches.

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

Automated Program Repair Based on Large Language Model and Mask Templates

  • Xiaohan Wu,
  • Lili Bo,
  • Xiaohan Jiang,
  • Yuting He

摘要

Most of the automated program repair (ARP) approaches are learning-based techniques. They treat bug fixes as a neural machine translation task by translating incorrect code into correct code. However, these approaches rely heavily on high-quality bug-fixing pairs and may spend expensive training costs. To alleviate the problems, in this paper, we present TemRepair, a new approach based on mask templates and Large Language Model (LLM), which generate patches through zero-shot learning. First, eight categories of mask templates are summarized by manually analyzing 2,000 bug-fixing pairs, such as modifying method invocation expressions, altering variables, and adjusting operators. Then, mask lines are produced using mask templates, and together with the method context as well as the comments, are input to the Large Language Model (InCoder) to predict the masked sections. Finally, the generated patches are deduplicated and verified. Experimental results on the Defects4J dataset show that, TemRepair can generate 67 correct patches, indicating its superiority over the state-of-the-art approaches.