Overview
This paper introduces MBXP and Multilingual HumanEval, the first large-scale execution-based benchmarks for evaluating code generation across more than 10 programming languages. By transpiling prompts and test cases from existing Python datasets, the authors demonstrate that multi-lingual models often outperform mono-lingual ones and that techniques like few-shot prompting and zero-shot translation can significantly boost a model's ability to "speak" new languages.
The Challenge of Multi-lingual Evaluation
While Large Language Models (LLMs) for code have advanced rapidly, our ability to evaluate them has lagged behind. Most high-quality benchmarks, like OpenAI’s HumanEval or Google’s MBPP, are almost exclusively focused on Python. Evaluating other languages often relies on "match-based" metrics like BLEU, which compare text similarity but fail to capture whether the code actually works.
Creating "execution-based" benchmarks—where code is run against unit tests—is the gold standard, but it is incredibly labor-intensive to manually write prompts and test cases for dozens of different languages. This paper tackles the scalability challenge of multi-lingual evaluation: how do we rigorously test code generation in Java, C++, PHP, and beyond without starting from scratch for every language?
Methodology: The Language Conversion Framework
To solve this, the authors developed a Language Conversion Framework that uses a rule-based transpiler to automatically convert Python-based benchmarks into other languages.
The key insight is that for function-completion tasks, you don't need to translate the entire solution. You only need to translate:
- The Prompt: The function signature and the docstring.
- The Test Cases: The assertion statements used to verify correctness.
For statically typed languages (like Java or C#), the framework performs type inference by analyzing the Python test cases to determine the appropriate argument and return types. Once the prompts and tests are converted, the authors use a "bootstrapping" process: they let a high-capacity model generate thousands of candidate solutions in the target language and keep only those that pass the newly converted unit tests. These become the "canonical solutions" for the new benchmark.
New Multi-lingual Datasets
The paper introduces several major multi-lingual benchmarks:
- MBXP: A multi-lingual version of the "Most Basic Python Problems" (MBPP) dataset.
- Multilingual HumanEval: A conversion of the popular HumanEval dataset.
- Multi-lingual MathQA: A version of the MathQA dataset focused on mathematical programming.
These datasets cover over 10 languages, including Java, JavaScript, TypeScript, Go, Ruby, Kotlin, PHP, C#, Scala, C++, Swift, and Perl. For training, the authors curated a massive corpus of GitHub data totaling 101 GB of Python, 177 GB of Java, and 216 GB of JavaScript.
Key Insights
- The Multi-lingual Advantage: Once a model reaches a certain size (around 2.7B to 13B parameters), a single multi-lingual model trained on many languages starts to outperform specialized mono-lingual models. The shared knowledge across languages helps the model generalize better.
- "Data Spillover": Models can often generate correct code in languages they weren't intentionally trained on (like PHP or Ruby). The authors hypothesize this is due to "spillover" in the training data—for example, JavaScript snippets embedded in Python web development files or multi-lingual comments.
- Few-Shot as a Teacher: Providing just three examples (few-shot prompting) in a new language acts as a powerful "syntax primer," drastically reducing compilation and parsing errors for languages the model hasn't seen much of.
- Zero-Shot Translation: Models exhibit an emergent ability to use a reference solution in one language (e.g., Python) to help them write a solution in another (e.g., Java), even without being explicitly trained to translate.
Key Results
- Scaling Laws: The authors observed a log-linear relationship between model size and performance (pass@k scores) across all languages.
- Translation Boost: In "translation mode"—where the model is given a Python solution as a hint—performance skyrocketed. For example, on the MathQA dataset, models achieved nearly 100% pass@100 scores by translating logic into the target language.
- Robustness: Multi-lingual models proved more robust to "prompt perturbations" (like changing the wording of a docstring) than their mono-lingual counterparts, showing a lower percentage drop in performance when faced with varied inputs.
Limitations and Future Work
The authors acknowledge several constraints:
- Algorithmic Focus: The benchmarks focus on basic programming and algorithmic tasks. They do not cover language-specific idioms or complex domain-specific libraries (e.g., web frameworks in JS or systems programming in C++).
- Naive Conversion: The framework assumes a problem relevant in Python is equally relevant in PHP. This might not always align with how different languages are used in the real world.
- Test Case Quality: The quality of the multi-lingual benchmark is ultimately limited by the thoroughness of the original Python test cases. If the original tests were weak, the converted ones will be too.
Future work involves expanding the framework to more complex datasets like APPS or CodeContests and investigating how to generate more thorough, automated test cases to improve verification.
Summary updated