arrow
Return

BatFix: Repairing Language Model-based Transpilation

delete2024-06-27
delete0
delete
OA
AI
D
Daniel Ramos *
I
Inês Lynce
V
Vasco Manquinho
R
Ruben Martins
C
Claire Le Goues
DOI:10.1145/3658668delete
deleteOriginal
deleteOriginal request for help
deleteShare
deleteSave
Abstract

Abstract

En 中文
To keep up with changes in requirements, frameworks, and coding practices, software organizations might need to migrate code from one language to another. Source-to-source migration, or transpilation, is often a complex, manual process. Transpilation requires expertise both in the source and target language, making it highly laborious and costly. Languages models for code generation and transpilation are becoming increasingly popular. However, despite capturing code-structure well, code generated by language models is often spurious and contains subtle problems. We propose BatFix, a novel approach that augments language models for transpilation by leveraging program repair and synthesis to fix the code generated by these models. BatFix takes as input both the original program, the target program generated by the machine translation model, and a set of test cases and outputs a repaired program that passes all test cases. Experimental results show that our approach is agnostic to language models and programming languages. BatFix can locate bugs spawning multiple lines and synthesize patches for syntax and semantic bugs for programs migrated from Java to C++ and Python to C++ from multiple language models, including, OpenAI's Codex.
Keywords:
Program analysis
automated refactoring
machine learning
transpilation

Journal

A
ACM Transactions on Software Engineering and Methodology
IF:
6.2
Papers:
1.2K
Citations:
3.4K

Organization

U
universidade de lisboa
Scholars:
3.4W
Papers: 3.1W
Citations: 29
C
Carnegie Mellon University
Scholars:
1.4W
Papers: 1.4W
Citations: 2.7W