[Paper Review] AVATAR: A Parallel Corpus for Java-Python Program Translation
This paper introduces Avatar, a parallel corpus of 9,515 programming problems with corresponding Java and Python solutions, collected from competitive programming sites and open-source repositories. The dataset includes 250 examples with unit tests for functional correctness evaluation and enables fine-tuning of pre-trained code language models, though experiments show existing models still struggle with functional accuracy despite strong lexical performance.
Program translation refers to migrating source code from one programming language to another. It has tremendous practical value in software development, as porting software across languages is time-consuming and costly. Automating program translation is of paramount importance in software migration, and recently researchers explored unsupervised approaches due to the unavailability of parallel corpora. However, the availability of pre-trained language models for programming languages enables supervised fine-tuning with a small number of labeled examples. Therefore, we present AVATAR, a collection of 9,515 programming problems and their solutions written in two popular languages, Java and Python. AVATAR is collected from competitive programming sites, online platforms, and open-source repositories. Furthermore, AVATAR includes unit tests for 250 examples to facilitate functional correctness evaluation. We benchmark several pre-trained language models fine-tuned on AVATAR. Experiment results show that the models lack in generating functionally accurate code.
Motivation & Objective
- To address the lack of large-scale, high-quality parallel corpora for Java-Python program translation.
- To enable supervised fine-tuning of pre-trained code language models (PLMs) for improved translation performance.
- To provide a benchmark with unit tests to evaluate functional correctness of translated code.
- To investigate the limitations of current neural models in generating functionally correct code.
- To support future research in automated program translation by releasing a diverse, publicly available dataset.
Proposed method
- Collected solutions from competitive programming platforms (AtCoder, Codeforces, AIZU, Code Jam, LeetCode, Project Euler) and online repositories (GeeksforGeeks, GitHub).
- Tokenized and filtered code by removing comments and docstrings, and applied length thresholds (≤464 tokens) to ensure consistency.
- Retained up to five distinct solutions per problem to ensure diversity and avoid redundancy.
- Split the dataset into 75% training, 5% validation, and 20% test, with multiple ground-truth solutions for validation and test sets.
- Provided 250 examples with unit tests to enable functional correctness evaluation beyond syntactic and lexical matching.
- Fine-tuned multiple pre-trained code language models (e.g., CodeBERT, GraphCodeBERT, TransCoder-ST, PLBART) on the Avatar dataset for translation tasks.
Experimental results
Research questions
- RQ1How effective are pre-trained code language models when fine-tuned on a new, large-scale parallel corpus for Java-Python translation?
- RQ2To what extent do current models generate functionally correct code, as verified by unit tests?
- RQ3What factors contribute to the gap between lexical accuracy and functional correctness in program translation?
- RQ4How does the diversity and quality of training data affect model generalization and functional correctness?
- RQ5Can a curated parallel corpus improve zero-shot or few-shot translation performance on unseen problems?
Key findings
- The Avatar dataset contains 9,515 programming problems with 250 examples annotated with unit tests, enabling functional correctness evaluation.
- Fine-tuned models achieved strong performance on lexical and syntactic metrics, but significantly lower accuracy on functional correctness as measured by unit test execution.
- Among the evaluated models, fine-tuned TransCoder-ST achieved the highest performance on both lexical and functional metrics, followed closely by PLBART.
- Despite strong lexical match, models frequently failed to generate functionally correct code, indicating a critical gap in semantic understanding.
- The dataset reveals that models often produce syntactically valid but logically incorrect code, especially in handling data structures and control flow.
- The carbon footprint of training was low (7.5kg CO2 equivalent), due to limited model fine-tuning on a moderate-sized dataset.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.