Skip to main content
QUICK REVIEW

[论文解读] MultiPL-E: A Scalable and Extensible Approach to Benchmarking Neural Code Generation

Federico Cassano, John Gouwar|arXiv (Cornell University)|Aug 17, 2022
Software Engineering Research被引用 13
一句话总结

本文提出 MultiPL-E,一个可扩展且可扩展的框架,将单元测试驱动的代码生成基准从 Python 翻译为 18 种其他编程语言,实现了神经代码模型的多语言评估。主要贡献在于创建了并行的多语言基准(MultiPL-HumanEval 和 MultiPL-MBPP),揭示了 Codex 在多种非 Python 语言上的表现优于 Python,挑战了关于语言特异性性能和模型泛化能力的既有假设。

ABSTRACT

Large language models have demonstrated the ability to generate both natural language and programming language text. Such models open up the possibility of multi-language code generation: could code generation models generalize knowledge from one language to another? Although contemporary code generation models can generate semantically correct Python code, little is known about their abilities with other languages. We propose MultiPL-E, a system for translating unit test-driven code generation benchmarks to new languages. We create the first massively multilingual code generation benchmark by using MultiPL-E to translate two popular Python code generation benchmarks to 18 additional programming languages. We use MultiPL-E to extend the HumanEval benchmark and MBPP benchmark to 18 languages that encompass a range of programming paradigms and popularity. Using these new parallel benchmarks, we evaluate the multi-language performance of three state-of-the-art code generation models: Codex, CodeGen, and InCoder. We find that Codex matches or even exceeds its performance on Python for several other languages. The range of programming languages represented in MultiPL-E allow us to explore the impact of language frequency and language features on model performance. Finally, the MultiPL-E approach of compiling code generation benchmarks to new programming languages is both scalable and extensible, making it straightforward to evaluate new models, benchmarks, and languages.

研究动机与目标

  • 为解决神经代码生成领域中多语言评估的缺乏,将现有以 Python 为中心的基准扩展至其他编程语言。
  • 在多种编程范式和流行度各异的编程语言之间,实现一致且并行的代码生成模型评估。
  • 探究语言特性、流行度以及提示设计如何影响代码生成模型的性能。
  • 开发一个可重用、可扩展的框架,用于在无需完整编译器开销的情况下,对新编程语言中的代码生成模型进行基准测试。

提出的方法

  • MultiPL-E 使用轻量级、基于规则的编译器(每种约 200 行代码)将四个组件从 Python 翻译为目标语言:函数签名、单元测试、文档字符串和类型注解。
  • 采用与语言相适应的术语翻译模块,将 Python 特定术语(例如 'list' → 'vector' 在 C++ 中)转换,以提升提示的清晰度。
  • 通过容器化沙盒环境执行生成的代码,设置超时机制,验证输出是否符合单元测试,并将结果分类为正确、语法错误或运行时错误。
  • 该框架支持 18 种涵盖多种编程范式和流行度水平的编程语言,每种语言的评估脚本长度约为 20 行代码。
  • 通过将现有基准(HumanEval 和 MBPP)的测试用例和提示翻译为新语言,同时保持语义等价性,复用现有基准。
  • 该系统通过使用一致的问题集,实现了跨语言的零样本代码生成模型评估。

实验结果

研究问题

  • RQ1代码生成模型能否将来自 Python 的知识泛化到其他编程语言?性能在不同语言间如何变化?
  • RQ2语言流行度和语法特性(例如静态类型)如何影响模型在代码生成中的表现?
  • RQ3模型困惑度是否与不同语言中的代码正确性存在相关性?
  • RQ4在多语言环境下,模型性能对提示设计和语言特异性术语的敏感性如何?
  • RQ5类型注解在静态类型语言中在多大程度上提升或阻碍代码生成?

主要发现

  • Codex 在 JavaScript、C++、Scala 和 TypeScript 中的表现与在 Python 中相当或更优,表明其具备强大的跨语言泛化能力。
  • 模型性能与语言流行度呈中等相关性,但 Racket 和 Swift 等小众语言的表现与主流语言相当。
  • 模型困惑度与代码正确性之间并无强相关性,表明困惑度是代码生成质量的弱代理指标。
  • 静态类型并未显著提升或降低模型性能,表明类型注解既非主要助力也非主要障碍。
  • 提示设计的敏感性在主流语言和小众语言中均显著,模型输出质量随提示格式变化而显著波动。
  • 错误分析揭示了语言特异性陷阱,例如 Swift 中的错误字符串索引和 Python 中的输入处理问题,凸显了模型在处理语言特异性惯用法方面的局限性。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。