Introduction
What is InterTrans?
InterTrans is a methodology to convert source code across programming languages (i.e. code translation) that utilizes planning and off-the-shelf Large Language Models (LLMs) to enhance the correctness of the produced translation (i.e. the program output by the LLM). Previous approaches instruct LLMs to perform a direct translation, that is, translate from a source programming language (A) to a target programming language (B). InterTrans instead attemps to exploit the multi-lingual capacity of LLMs and, whenever a direct translation is unsuccessful, it continues to explore translation through other programming languages different than the target language (B). This process forms and is guided by a Tree of Code Translation (ToCT). Tree of Code Translations (ToCT) allows InterTrans to leverage intermediate generations in other PLs as a bridge towards the wanted translation in the target language B. Our research demonstrates that this methodology achieves an absolute improvement of 18.3% to 43.3% in Computation Accuracy (CA) for InterTrans compared to Direct Translation (CA@10).

The image above shows an example of a Tree of Code Translation. The source program to be translated is in Python, and the target language is Java. The tree shows the intermediate translations in other languages that are used to bridge the gap between the source and target languages. The translation order is shown through the numbers on the edges of the tree. The initial translation from Python to Java (direct translation) is unsuccessful (red nodes), so the tree explores other languages to find a successful translation. It finally finds the correct translation in Java through intermediate translations in C++ (green node).
CodeTransEngine Architecture
The CodeTransEngine is a server that provides an API for translating code across programming languages. It was originally designed to run the Tree of Code Translation (ToCT) algorithm, but now supports a variety of different techniques. This API is exposed through gRPC and can be accessed by clients written in any language that supports gRPC. We provide a Python client that can be used to interact with the CodeTransEngine.
+-----------------------------------------+ | External Consumer | | (e.g., Python Client) | +-----------------------------------------+ | gRPC ↓ +-----------------------------------------+ | CodeTransEngine | +-----------------------------------------+ ↓ ↓ OpenAI API Spec Code Execution (Singularity Container) ↓ vLLM Compatible Server