Abstract
Program translation is a critical task for software modernization and cross-platform development. Traditional approaches rely on pairwise translation models, which suffer from data scarcity, information silos, and linear-to-exponential deployment complexity. This paper introduces VIM-PT (Variational Interaction for Multilingual Program Translation), a unified generative framework that disentangles code into language-shared semantics and language-specific syntax. By optimizing a variational lower bound based on information theory, VIM-PT effectively utilizes semi-parallel datasets and scales linearly with the number of languages. Experimental results on the CoST dataset demonstrate that VIM-PT outperforms state-of-the-art baselines and achieves performance comparable to large language models while maintaining a significantly smaller parameter footprint.
1. Introduction
The task of automatically converting source code from one programming language to another—program translation—is essential for maintaining legacy systems and facilitating cross-platform software engineering. Despite recent advances in neural machine translation, program translation remains challenging due to the structural complexity of code and the lack of high-quality parallel corpora.
Current state-of-the-art methods typically employ pairwise translation, where a dedicated model is trained for each specific language pair (e.g., C++ to Java). This paradigm faces three primary obstacles:
- Data Scarcity: High-quality parallel data is often unavailable for many language pairs.
- Information Silos: Pairwise models fail to leverage commonalities across multiple languages; a model learning C++ to Java does not benefit from Python logic.
- Deployment Bloat: Supporting $N$ languages requires $N(N-1)$ models, or $O(N^2)$ complexity, creating significant overhead in production environments.
2. The VIM-PT Framework
To address these limitations, we propose VIM-PT, a joint learning model designed for multilingual program translation. VIM-PT moves beyond pairwise modeling by training a single, unified model capable of translating across multiple programming languages simultaneously.
2.1 Feature Disentanglement
The core innovation of VIM-PT is the disentanglement of code representations into two distinct components:
- Language-Shared Features: These capture the underlying functional logic and semantics of the program, which remain invariant regardless of the implementation language.
- Language-Specific Features: These capture the syntax, grammar, and idiomatic "flavor" of a specific programming language.
2.2 Variational Interaction
To prevent information leakage between these two components, we derive a new variational lower bound based on information theory. This objective function maximizes the "interaction information" to ensure that the shared feature space truly represents the common logic across all implementations. The model uses a weight-sharing encoder for all input languages to map code into this shared semantic space, while independent decoders handle the generation of target-specific syntax.
2.3 Handling Semi-Parallel Data
Real-world datasets are rarely fully parallel. A specific function might exist in Java and Python but be missing in C++. VIM-PT utilizes a generative framework and an Expectation-Maximization (EM) style algorithm to "fill in the blanks" during training, allowing the model to learn from incomplete data clusters by generating pseudo-instances for missing languages.
3. Experimental Setup
We evaluated VIM-PT using the CoST dataset, a large-scale benchmark for program translation covering seven languages: C, C#, C++, Java, JavaScript, PHP, and Python. The dataset includes both snippet-level and program-level data.
Notably, the dataset is highly imbalanced; languages like C and PHP are "low-resource" compared to Java or Python. Furthermore, only 12.5% of the data is fully parallel across all seven languages, making it a rigorous test for VIM-PT's semi-parallel learning capabilities.
4. Results and Analysis
VIM-PT demonstrates significant improvements over state-of-the-art baselines, including CodeBERT and MuST-PT.
4.1 Performance Gains
The model achieved an average BLEU-4 score improvement ranging from 4.57% to 11.14% across various configurations. The performance boost was particularly pronounced in low-resource languages (C and PHP), suggesting that the multilingual joint learning framework effectively transfers knowledge from data-rich languages to data-poor ones.
4.2 The Auxiliary Benefit
A key finding is the "auxiliary benefit": the inclusion of a third, rich-resource language improves translation between two other languages. For instance, training on Java helps the model better translate between PHP and JavaScript by providing a stable "anchor" for the shared semantic representation. This benefit is most significant when the auxiliary language is syntactically similar to the target language (e.g., using C# to assist in C++ translation).
4.3 Efficiency and Scaling
While pairwise approaches scale exponentially ($O(N^2)$), VIM-PT scales linearly ($O(N)$). For a 7-language setup, VIM-PT requires less than 1/15th the parameters of a full suite of pairwise models while delivering superior performance. Furthermore, VIM-PT proved competitive with much larger models, such as GPT-3.5 and CodeT5, despite having a fraction of the parameters.
5. Conclusion and Future Work
VIM-PT introduces a robust method for multilingual program translation through variational disentanglement. By separating logic from syntax, it achieves state-of-the-art results, especially in low-resource scenarios, and offers a scalable solution for production deployment.
Future research will focus on improving pseudo-instance selection strategies for missing data—perhaps through active learning—and exploring methods to better leverage auxiliary languages with diverse syntactic structures. Additionally, testing the model on more diverse, "in-the-wild" codebases will be essential to validate its generalization beyond curated benchmarks.
Summary updated