Introduction
The evaluation of Large Language Models (LLMs) for code generation has historically been confined to a "Python silo." While models are trained on vast, multilingual datasets, benchmark suites like OpenAI’s HumanEval and Google’s MBPP are Python-centric. Manually porting these to other languages is a labor-intensive task requiring significant expertise. MultiPL-E addresses this challenge by providing a scalable framework to automate the translation of these benchmarks into 18 additional programming languages.
Methodology
MultiPL-E utilizes a "little compiler" strategy. Rather than a general-purpose source-to-source compiler, the authors developed 18 specialized translators (averaging 200 lines of code each) to convert function signatures, docstrings, and unit tests from Python to target languages. This approach ensures that the prompts remain natural to the model—for example, automatically rephrasing a Python "list" as a C++ "vector"—while providing a robust framework for containerized execution and verification of the generated code against translated unit tests.
Benchmarks and Datasets
The framework produced two major parallel benchmarks: MultiPL-HumanEval (164 problems) and MultiPL-MBPP (401 problems). These cover a spectrum of 19 languages total, categorized by their frequency in training data:
- High-frequency: C++, Java, JavaScript, TypeScript, PHP.
- Medium/Low-frequency: C#, Go, Rust, Ruby, Swift, Scala.
- Niche/Specialized: Lua, R, Perl, Bash, Julia, D, Racket.
Results and Model Performance
Evaluation of three major model families—Codex, CodeGen, and InCoder—reveals that Codex (specifically the davinci-002 variant) is a dominant polyglot. It consistently achieved pass@1 rates exceeding 40% in several languages, including C++, Java, and PHP, often matching or exceeding its performance in Python.
Key Insights
The Perplexity Paradox
A significant finding is the "Perplexity Paradox." In natural language processing, lower perplexity typically correlates with better model performance. However, in code generation, this relationship is decoupled. For instance, JavaScript often exhibits higher perplexity than Python yet yields higher pass rates, suggesting that perplexity is an unreliable proxy for functional correctness in programming tasks.
Generalization and Niche Languages
Models showed surprising proficiency in niche languages like Lua, despite their limited representation in training data compared to mainstream languages. This suggests that LLMs are highly effective at generalizing logic across diverse syntaxes. Additionally, the study highlighted the importance of type systems; for languages like TypeScript, providing precise type annotations was essential for performance, whereas using generic types like Any led to significant degradation.
Conclusion and Future Work
MultiPL-E demonstrates that state-of-the-art LLMs are far more capable polyglots than previously thought, often transcending the Python-centric nature of their evaluation sets. Future work will expand the framework to specialized domains like SQL and hardware description languages (Verilog), while exploring how to further optimize prompt engineering for specific language paradigms.
Summary updated