Leveraging Automated Unit Tests for Unsupervised Code Translation
arXiv:2110.06773
Abstract
With little to no parallel data available for programming languages, unsupervised methods are well-suited to source code translation. However, the majority of unsupervised machine translation approaches rely on back-translation, a method developed in the context of natural language translation and one that inherently involves training on noisy inputs. Unfortunately, source code is highly sensitive to small changes; a single token can result in compilation failures or erroneous programs, unlike natural languages where small inaccuracies may not change the meaning of a sentence. To address this issue, we propose to leverage an automated unit-testing system to filter out invalid translations, thereby creating a fully tested parallel corpus. We found that fine-tuning an unsupervised model with this filtered data set significantly reduces the noise in the translations so-generated, comfortably outperforming the state-of-the-art for all language pairs studied. In particular, for Java Python and Python C++ we outperform the best previous methods by more than 16% and 24% respectively, reducing the error rate by more than 35%.
References in corpus (12)
- Evaluating Large Language Models Trained on Code
- CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generation
- CodeBERT: A Pre-Trained Model for Programming and Natural Languages
- Learning and Evaluating Contextual Embedding of Source Code
- Measuring Coding Challenge Competence With APPS
- A parallel corpus of Python functions and documentation strings for automated code documentation and code generation
- Graph-based, Self-Supervised Program Repair from Diagnostic Feedback
- Unified Pre-training for Program Understanding and Generation
- Code Prediction by Feeding Trees to Transformers
- DOBF: A Deobfuscation Pre-Training Objective for Programming Languages
- SPoC: Search-based Pseudocode to Code
- Unit Test Case Generation with Transformers and Focal Context