TL;DR
Large Language Models (LLMs) for code excel at popular languages but struggle with less common ones due to data scarcity. This paper introduces MULTIPL-T, a novel method to generate high-quality, semi-synthetic training data for low-resource languages by translating and validating code from high-resource languages, significantly boosting LLM performance on these underserved languages.
What Problem Does This Paper Address?
Code LLMs, like GitHub Copilot, have revolutionized software development, but their effectiveness is heavily skewed towards "high-resource" programming languages (e.g., Python, Java, JavaScript) that have abundant training data. Conversely, "low-resource" languages (e.g., OCaml, Racket, Julia, Lua, R) suffer from significantly poorer performance from these models. This disparity creates a disadvantage for developers working with these less common languages. The core challenge is the lack of sufficient, high-quality training data for these low-resource languages, making it difficult to fine-tune existing LLMs to perform well. Simply training for longer on existing limited data or generating purely synthetic data has proven ineffective.
Methods
The paper introduces MULTIPL-T, a pipeline for generating semi-synthetic training data for low-resource programming languages. The process involves several key steps:
- High-Quality Source Data Selection: They start with a large corpus of well-documented Python code (from The Stack) and apply aggressive filtering. This includes selecting functions with docstrings, ensuring they are typeable with standard libraries, and excluding incomplete code or known benchmark solutions.
- LLM-Generated Unit Tests: A Code LLM (StarCoderBase-15B) is used to generate unit tests for the filtered Python functions. This step leverages the LLM's ability to detect inconsistencies between code and comments. Tests are validated for correctness and coverage (aiming for >90% line coverage).
- Type Inference: For typed target languages, Python types are inferred from the test cases to ensure accurate translation.
- LLM-Based Translation: The filtered Python functions, along with their comments and inferred types, are fed to a Code LLM to translate them into the target low-resource language. They generate multiple candidate translations.
- Test-Validated Filtering: Crucially, the generated Python unit tests are compiled into the target language using a lightweight compiler. These compiled tests are then used to filter the LLM-generated translations, keeping only those that pass the tests. This ensures the generated data is both syntactically correct and functionally sound in the target language.
- Deduplication: A ROUGE-L based algorithm is used to ensure diversity among the selected solutions, preventing redundancy and improving the dataset's effectiveness.
This approach effectively transfers knowledge from a high-resource language (Python) to low-resource languages by creating validated, semi-synthetic training examples.
Datasets
- The Stack: Used as the source for high-quality Python code.
- MultiPL-E: A polyglot benchmark used for evaluating the performance of fine-tuned models on low-resource languages. The authors also extend it to support OCaml.
- New Benchmark: A custom, manually constructed multi-language benchmark with 14 problems designed to specifically test in-context learning, user-defined types, higher-order functions, and helper functions, aiming to expose potential overfitting to the MULTIPL-T format.
Key Insights and Ideas
- Semi-synthetic data is key: Purely synthetic data generated by LLMs for low-resource languages is often low quality. MULTIPL-T's strength lies in using LLMs to translate and validate existing high-quality code, creating reliable training data.
- Test validation is paramount: The core innovation is using compiled unit tests from the source language to filter LLM-generated translations in the target language. This is a robust way to ensure correctness, overcoming the LLM's inherent unreliability in low-resource settings.
- Weak-to-strong supervision is effective: A smaller, capable LLM (StarCoderBase-15B) can generate high-quality data that improves the performance of much larger, state-of-the-art models (like Code Llama 34B/70B).
- Fine-tuning on MULTIPL-T is more efficient than training longer: The paper demonstrates that fine-tuning on MULTIPL-T data yields significant gains, often outperforming simply training longer on existing, less curated data.
- Low-resource languages benefit most: The largest relative performance gains are observed in the lowest-resource languages, highlighting the method's effectiveness in addressing data scarcity.
Key Results
- Fine-tuned models using MULTIPL-T data significantly outperform their base models on low-resource languages (Julia, Lua, OCaml, R, Racket) across various LLM families (StarCoder, Code Llama) and sizes (1B to 70B parameters).
- For OCaml and Racket, fine-tuned models showed more than double the score of their base models on the MultiPL-E benchmark.
- Fine-tuned models achieved state-of-the-art results on low-resource languages, even surpassing models trained on significantly more data.
- The MULTIPL-T approach demonstrated efficiency, with training times for deduplicated datasets being drastically reduced.
- Qualitative evaluation on Racket showed a slight decrease in coding style score but a significant increase in correctness.
Limitations and Future Work
- "No-resource" languages: MULTIPL-T is unlikely to work "as-is" for languages that the base LLM has not been trained on at all. Future work might explore clever prompting to bootstrap data generation for these languages.
- Source language choice: While Python is used, using a source language closer in syntax or semantics to the target language might yield even better results.
- Overfitting to MULTIPL-T format: The authors acknowledge that fine-tuning on MULTIPL-T data (which consists of standalone functions) might lead to overfitting. They suggest fine-tuning on a mix of natural and MULTIPL-T data to mitigate this.
- Composability: The authors propose combining MULTIPL-T with self-instruct methods, using MULTIPL-T to translate high-resource instruction datasets into low-resource languages.
- New benchmarks: The paper emphasizes the need for more benchmarks for low-resource languages to better understand LLM capabilities.
Summary updated