Knowledge Transfer from High-Resource to Low-Resource Programming Languages for Code LLMs

Federico Cassano, John Gouwar, Francesca Lucchetti, Claire Schlesinger, Anders Freeman, Carolyn Jane Anderson, Molly Q. Feldman, Michael Greenberg, Abhinav Jangda, Arjun Guha

TL;DR

MultiPL-T is a novel pipeline that dramatically boosts Code LLM performance on low-resource programming languages (like OCaml and Racket) by translating and test-validating high-resource (Python) data. By leveraging a deterministic compiler to filter out faulty LLM translations, it creates high-quality semi-synthetic datasets that allow even smaller models to effectively supervise and improve much larger ones.

What Problem Does This Paper Address?

While Large Language Models of Code (Code LLMs) excel at high-resource languages like Python, Java, and JavaScript, their performance plummets when tasked with low-resource languages such as OCaml, Racket, Lua, Julia, or R. This disparity stems directly from data scarcity; for instance, the popular training corpus The Stack contains 64GB of Python code but a meager 0.5GB of Scheme/Racket code.

Standard remedies fail to solve this. Training longer on existing scarce data often leads to overfitting or performance degradation, while standard "self-instruction" techniques (where an LLM generates new code from scratch) fail because the model is already bad at the target language and generates buggy code.

The performance of StarCoderBase-15B vs. training data fraction, showing how MultiPL-T bridges the gap for low-resource languages.

Methods

The authors introduce MultiPL-T, a data-generation pipeline that transfers knowledge from a high-resource source language (Python) to low-resource target languages using a translation-and-validation framework.

The pipeline operates in five distinct stages:

  1. Source Filtering: Extract individual Python functions from The Stack and aggressively filter them using heuristic type-checkers to ensure high code quality.
  2. Test Generation: Use a Code LLM to synthesize multiple independent unit tests for each Python function, keeping only those that achieve at least 90% line coverage.
  3. LLM Translation: Prompt a Code LLM to translate the high-quality Python functions into the target low-resource language.
  4. Deterministic Test Compilation: Instead of asking the LLM to write tests in the target language (which introduces hallucinations), MultiPL-T uses a traditional, deterministic compiler to translate the Python unit tests into the target language. The translated code is executed against these compiled tests, and any failing translations are discarded.
  5. Deduplication: Apply a parallelized ROUGE-L algorithm to remove syntactically redundant solutions, ensuring a diverse and efficient training set.
High-level overview of the MultiPL-T pipeline.

Datasets

The paper utilizes and introduces several key datasets:

  • The Stack (v1.2): The source repository used to extract the initial 22 million Python functions, filtered down to a core set of 133,168 high-coverage, documented functions.
  • MultiPL-T Fine-Tuning Datasets: Newly generated, test-validated datasets for five low-resource languages: R (37,592 items), Racket (40,510 items), OCaml (43,401 items), Julia (45,000 items), and Lua (48,194 items).
  • In-Context Learning Benchmark: A new, manually curated multi-language benchmark consisting of 14 complex problems. Unlike standard benchmarks that evaluate standalone functions, this benchmark tests a model's ability to handle user-defined types, helper functions, and external libraries.

Key Insights and Ideas

  • Weak-to-Strong Supervision: In an uncommon machine learning result, semi-synthetic data generated by a smaller model (StarCoderBase-15B) successfully improved the performance of significantly larger and more capable models (like Code Llama 34B and 70B).
  • Translation Over Generation: LLMs are notoriously bad at writing low-resource code from scratch, but they are surprisingly adept at translating it from a high-resource language, especially when the original Python code is included in the prompt comment.
  • The Power of Deterministic Filters: Bypassing the LLM to compile unit tests via a traditional compiler provides an unyielding, hallucination-free ground truth filter that guarantees the correctness of the synthetic training data.
  • More Epochs Can Hurt: The authors demonstrate that simply training longer on natural low-resource data flatlines or degrades model capabilities, whereas fine-tuning on MultiPL-T data yields immediate, substantial gains.
Comparison of fine-tuning on natural data from The Stack vs. MultiPL-T data over multiple epochs.

Key Results

Fine-tuning with MultiPL-T data yielded massive performance leaps across the board on the MultiPL-E benchmark:

  • StarCoderBase-1B saw its OCaml pass@1 score jump from 1.5 to 9.7, and its Racket score rise from 4.7 to 11.3.
  • StarCoderBase-15B improved from 6.9 to 19.9 on OCaml, and from 11.8 to 21.0 on Racket.
  • CodeLlama-70B achieved a state-of-the-art score of 33.1 on Racket after fine-tuning.
  • Deduplication Efficiency: For Lua, training on the deduplicated dataset took less than 30 minutes on a single GPU compared to 12 hours on the undeduplicated dataset, achieving an identical pass@1 score (17.3).

Limitations and Future Work

  • Overfitting to Standalone Functions: Because the MultiPL-T dataset consists entirely of single, isolated functions, some models (notably the 15B OCaml model) showed signs of overfitting and performed worse on the new in-context learning benchmark.
  • Stylistic Degradation: Qualitative analysis revealed that translated code sometimes inherits Python-centric paradigms (like imperative loops or nested if expressions) rather than utilizing idiomatic functional styles native to languages like Racket.
  • The "No-Resource" Barrier: MultiPL-T requires the base LLM to have at least a baseline understanding of the target language syntax to perform the initial translation; it cannot bootstrap a language the model has never seen before.

Summary updated

BibTeX
@article{cassano2024knowledge,
  author = {Federico Cassano and John Gouwar and Francesca Lucchetti and Claire Schlesinger and Anders Freeman and Carolyn Jane Anderson and Molly Q. Feldman and Michael Greenberg and Abhinav Jangda and Arjun Guha},
  title = {{Knowledge Transfer from High-Resource to Low-Resource Programming Languages for Code LLMs}},
  journal = {Proc. ACM Program. Lang.},
  year = {2024},
  doi = {10.1145/3689735},
}
Figure