Repository Level Neural Code Translation

This direction is no longer present in the current build. Its last version stays readable and citable here.

Version 1 of 129 papers32 conceptsfrozen 2026-10-04

Most Large Language Models (LLMs) excel at "snippet-level" tasks—translating a single function or a short competitive programming solution. However, as Wasi Uddin Ahmad and colleagues observe in their work on AVATAR, functional correctness plummets when these models face full-program translation. The reason is a "contextual myopia": models often treat functions as isolated islands, failing to see the complex web of dependencies, global variables, and cross-module calls that define real-world software.

The emerging research direction in neural code translation focuses on bridging this gap, moving from local logic conversion to holistic, repository-level migration.

The Challenge of Cascading Dependencies

In a large codebase, a single change in one file can have "cascading effects" across the entire project. For example, when translating legacy C code to Rust, a pointer's behavior in a low-level utility function dictates how every calling function must handle memory safety.

To address this, researchers like Wenjun Mao and Xin Peng 0001 developed PTRMAPPER. Instead of asking an LLM to guess pointer types, they use a Knowledge Graph (KG) to track pointer behaviors across the entire project. By explicitly modeling these inter-dependencies, the system ensures that the "ownership" and "lifetime" semantics required by Rust are consistent across every file in the repository.

Mapping the Global Context

Standard LLMs are limited by their context window; they cannot "see" the definitions of external libraries or custom modules located in different directories. This leads to "dependency misuse," where the model generates code that looks correct but fails to compile because it references non-existent or incorrectly typed variables.

Guangsheng Ou and Xin Peng 0001 propose a solution called K³Trans, which uses Triple Knowledge Augmentation. This framework retrieves three types of context:

  1. Dependency Usage: How specific APIs are actually used elsewhere in the project.
  2. Target-Language Samples: Examples of idiomatic code in the destination language.
  3. Prior Translations: Successful translations of similar modules within the same project to maintain naming consistency.

By dynamically evolving this knowledge base as the translation progresses, the model gains a "global memory" that prevents it from making contradictory decisions in different files.

Structural Skeletons and Multi-Agent Orchestration

Translating a million-line library is too large a task for a single prompt. Recent work suggests a "top-down" approach to maintain architectural integrity. Xing Zhang and Fangkai Yang introduced Skeleton-Guided-Translation, which first establishes a structural "skeleton"—the interfaces, signatures, and module hierarchies—before filling in the local logic. This ensures the "bones" of the software match across the source and target before the "flesh" (the implementation) is added.

For even more complex migrations, such as moving libraries across hardware architectures (e.g., ARM to RISC-V), researchers are turning to multi-agent systems. Weijia Li and the team behind QM-LibBench use specialized agents to handle hardware-aware optimizations, while Ruishi Li uses an adversarial "generator-discriminator" loop in ACToR to find and fix bugs that only emerge when modules are integrated.

Benchmarking the Repository Era

As the field shifts, traditional metrics like BLEU (which measures text similarity) are being replaced by benchmarks that measure functional correctness at scale.

  • Pengyu Xue introduced ClassEval-T to test how models handle the inter-dependencies of object-oriented classes.
  • Zhiqiang Lin developed C2RUST-BENCH to stress-test transpilers on real-world build systems and module hierarchies.

These benchmarks confirm that repository-level translation is a distinct, more difficult challenge than function-level logic. Success in this area requires models to move beyond pattern matching and toward a deep, structural understanding of how software systems are built and connected.

Papers in this version

History & citationVersion 1 · 2026-10-04

No longer present in the current build · Permanent link

View frozen version 1

Cite this direction

Latest version (a living page):

@misc{lacuna_repository_level_neural_code_translation_eeac46f0,
  title = {Repository Level Neural Code Translation},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/repository-level-neural-code-translation/rdr_eeac46f0447749d2b0a902d474b8a730},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-12-05},
}

This exact version (version 1, frozen text):

@misc{lacuna_repository_level_neural_code_translation_eeac46f0_v1,
  title = {Repository Level Neural Code Translation},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/repository-level-neural-code-translation/rdr_eeac46f0447749d2b0a902d474b8a730/v/1},
  note = {Version 1, frozen 2026-10-04. Accessed 2026-12-05},
}