[Paper Review] Exploring and Unleashing the Power of Large Language Models in Automated Code Translation
This paper proposes UniTrans, a unified framework that enhances large language models (LLMs) for automated code translation by leveraging test case generation, execution-based augmentation, and iterative repair. Evaluated across Python, Java, and C++ translations, UniTrans significantly improves computational and exact match accuracy across diverse LLMs, including GPT-3.5 and LLaMA variants, without requiring fine-tuning.
Code translation tools (transpilers) are developed for automatic source-to-source translation. Although learning-based transpilers have shown impressive enhancement against rule-based counterparts, owing to their task-specific pre-training on extensive monolingual corpora. Their current performance still remains unsatisfactory for practical deployment, and the associated training resources are also prohibitively expensive. LLMs pre-trained on huge amounts of human-written code/text have shown remarkable performance in many code intelligence tasks due to their powerful generality, even without task-specific training. Thus, LLMs can potentially circumvent the above limitations, but they have not been exhaustively explored yet. This paper investigates diverse LLMs and learning-based transpilers for automated code translation tasks, finding that: although certain LLMs have outperformed current transpilers, they still have some accuracy issues, where most of the failures are induced by a lack of comprehension of source programs, missing clear instructions on I/O types in translation, and ignoring discrepancies between source and target programs. Enlightened by the above findings, we further propose UniTrans, a Unified code Translation framework, applicable to various LLMs, for unleashing their power in this field. Specifically, UniTrans first crafts a series of test cases for target programs with the assistance of source programs. Next, it harnesses the above auto-generated test cases to augment the code translation and then evaluate their correctness via execution. Afterward, UniTrans further (iteratively) repairs incorrectly translated programs prompted by test case execution results. Extensive experiments are conducted on six settings of translation datasets between Python, Java, and C++. Three recent LLMs of diverse sizes are tested with UniTrans, and all achieve substantial improvements.
Motivation & Objective
- To investigate the feasibility of using large language models (LLMs) as alternatives to learning-based transpilers for automated code translation.
- To identify and analyze the root causes of failure in LLM-based code translation, particularly in comprehension, I/O specification, and structural discrepancy handling.
- To design a unified, prompt-based framework—UniTrans—that enhances LLM performance in code translation without fine-tuning.
- To evaluate the framework across multiple LLMs and translation settings, demonstrating its generalizability and practical utility.
Proposed method
- UniTrans generates test cases for target programs using source code to encode input-output requirements and program behavior.
- It augments code translation by injecting test case information into prompts, improving LLMs' understanding of required I/O types and program semantics.
- It evaluates translated code via automatic execution of generated test cases to validate correctness.
- It repairs incorrect translations by analyzing test case execution failures, with an optional iterative repair loop for refinement.
- The framework is designed to be model-agnostic, supporting various LLMs including GPT-3.5, LLaMA-7B/13B/33B, and CodeGen-6B.
- It uses a three-phase pipeline: Test Case Generation, Translation Augmentation, and Translation Repair, all driven by prompt engineering and execution feedback.

Experimental results
Research questions
- RQ1What are the primary failure modes of state-of-the-art LLMs in automated code translation tasks?
- RQ2Can LLMs outperform existing learning-based transpilers in code translation without task-specific fine-tuning?
- RQ3How can test cases and execution feedback be effectively leveraged to improve LLM-based code translation?
- RQ4To what extent can a unified, prompt-based framework enhance diverse LLMs across multiple programming language pairs?
- RQ5What are the key design principles for building a general-purpose, fine-tuning-free code translation system using LLMs?
Key findings
- LLMs such as GPT-3.5 outperform current learning-based transpilers in code translation accuracy, but still suffer from significant failure rates.
- The primary failure causes in LLMs are: lack of source program comprehension (38.51%), missing I/O type instructions (14.94%), and ignoring structural discrepancies (41.38%).
- UniTrans improves computational accuracy and exact match accuracy across all tested LLMs and translation settings, with substantial gains observed on GPT-3.5 and LLaMA models.
- The framework achieves consistent performance improvements without requiring model fine-tuning, demonstrating its practicality and scalability.
- The iterative repair mechanism in UniTrans further enhances translation correctness, especially in complex translation scenarios.
- The framework is effective across diverse LLM families and sizes, including open-source (LLaMA) and closed-source (GPT-3.5) models, proving its universality.

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.