NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Multilingual Code Co-evolution using Large Language Models

Jiyang Zhang, Pengyu Nie, Junyi Jessy Li, Milos Gligoric

TL;DR

Researchers from UT Austin have introduced CODEDITOR, the first Large Language Model (LLM) specifically designed for "multilingual code co-evolution." Instead of translating entire files from scratch, CODEDITOR learns to propagate specific code changes (like bug fixes or new features) from one programming language to another by explicitly modeling edits as unambiguous sequences.

What Problem Does This Paper Address?

Many modern software services (like Google Cloud or MongoDB) provide APIs in multiple languages (Java, C#, Python, etc.) to ensure broad adoption. However, maintaining these "parallel" codebases is a nightmare. When a developer fixes a bug in the Java version, they must manually find the corresponding code in the C# version and apply a similar fix.

Existing "code translation" models usually try to translate a whole snippet from Language A to Language B. This approach often fails in practice because:

  1. Loss of Context: They might ignore project-specific naming conventions or data types already present in the target language.
  2. Irrelevant Changes: They often "hallucinate" changes to parts of the code that were supposed to remain untouched.
  3. Scaling Issues: Generating an entire 500-line method just to change two lines is computationally expensive and prone to error.

Methods

The core innovation of CODEDITOR is that it treats code evolution as an edit-prediction task rather than a text-generation task.

1. The Input "Triple"

To give the model maximum context, the authors provide three pieces of information:

  • The edits made to the source language (e.g., Java).
  • The old version of the code in the target language (e.g., C#).
  • The new version of the code in the source language.

2. Unambiguous Edit Representations

Standard edit tools (like diff) can be ambiguous. If a model says "Replace x with y," but x appears five times in a file, which one changes? CODEDITOR uses a novel Unambiguous Edit Sequence format. It uses "anchor tokens" (unique snippets of surrounding code) to pinpoint exactly where an insertion, deletion, or replacement should occur.

3. Model Architecture

CODEDITOR is built on top of CoditT5, a transformer-based encoder-decoder model. The researchers fine-tuned it using two strategies:

  • EditsTranslation: Directly predicting the edit sequence for the target language.
  • MetaEdits: Predicting a "meta" plan that translates source edits into target edits.

Datasets

The authors curated a new, high-quality dataset by mining GitHub for "twin" projects—open-source software implemented in both Java and C# (e.g., Lucene, Antlr, and iText7).

  • Size: 6,613 aligned code change pairs.
  • Scope: Method-level changes where the logic is identical but the syntax differs.
  • Splits: They used both "time-segmented" splits (training on old commits, testing on new ones) and "cross-project" splits to ensure the model wasn't just memorizing specific project patterns.

Key Insights and Ideas

  • Edits are more stable than code: While a 500-line method in Java and C# might look very different, the logic of a change (e.g., changing an exception type) is often nearly identical. By focusing on the "delta," the model avoids getting bogged down by boilerplate syntax.
  • The "Grounding" Effect: By providing the model with the old version of the target code, the model is "grounded." It knows the existing variable names and class structures in C#, making it much less likely to invent incorrect names.
  • Size Matters: The researchers found that while standard generation models (like CodeT5) are okay at translating very short snippets, their performance falls off a cliff as code length increases. CODEDITOR’s performance remains stable because it only has to generate the small edit sequence, regardless of how long the original method is.

Key Results

CODEDITOR significantly outperformed state-of-the-art models, including fine-tuned CodeT5, Codex (few-shot), and ChatGPT (zero-shot).

  • Exact Match (xMatch): CODEDITOR achieved a 77% improvement over the best existing fine-tuned LLMs for code translation.
  • CodeBLEU: On the J2CS (Java to C#) task, it scored 96.02, compared to 77.15 for standard translation models.
  • Hybrid Power: The authors found that CODEDITOR and traditional generation models are complementary. By using a "Hybrid" approach—using generation for tiny snippets and CODEDITOR for everything else—they boosted exact-match accuracy by another 6%.

Limitations and Future Work

  • Language Support: The current study focused on Java and C# because of the abundance of parallel open-source projects. Future work is needed to see how well this generalizes to less similar pairs, like Python and C++.
  • The Mapping Problem: The model assumes you already know which Java method corresponds to which C# method. In a real-world enterprise setting, you would first need a "code retrieval" tool to find these pairs before CODEDITOR can do its job.
  • Human-in-the-loop: While the automatic metrics are impressive, the authors note that user studies are needed to see how much time this actually saves professional developers in their daily workflows.

Summary updated

BibTeX
@inproceedings{zhang2023multilingual,
  author = {Jiyang Zhang and Pengyu Nie and Junyi Jessy Li and Milos Gligoric},
  title = {{Multilingual Code Co-evolution using Large Language Models}},
  booktitle = {ESEC/SIGSOFT FSE},
  year = {2023},
  url = {https://openreview.net/forum?id=MrzMrdril5},
}

Loading related content...

Figure