[论文解读] Knowledge Transfer from High-Resource to Low-Resource Programming Languages for Code LLMs
本文提出 MultiPL-T,一种通过从高资源编程语言到低资源编程语言的基于测试的代码翻译,生成高质量、半合成训练数据的方法,以增强代码大模型在低资源编程语言上的表现。利用代码大模型生成并验证测试用例,再进行代码翻译,该方法生成了数以万计经过验证的训练样本,在 Julia、Lua、OCaml、R 和 Racket 等语言上的性能显著优于现有开源模型。
Over the past few years, Large Language Models of Code (Code LLMs) have started to have a significant impact on programming practice. Code LLMs are also emerging as building blocks for research in programming languages and software engineering. However, Code LLMs produce impressive results on programming languages that are well represented in their training data (e.g., Java, Python, or JavaScript), but struggle with low-resource languages that have limited training data available. Low resource languages include OCaml, Racket, and several others. This paper presents an effective approach for boosting the performance of Code LLMs on low-resource languages using semi-synthetic data. Our approach, MultiPL-T, translates training data from high-resource languages into training data for low-resource languages in the following way. 1) We use a Code LLM to synthesize tests for commented code from a high-resource language, filtering out faulty tests and code with low test coverage. 2) We use a Code LLM to translate Python code to a target low-resource language, and use tests to validate the translation. We apply this approach to generate tens of thousands of validated training items for Julia, Lua, OCaml, R, and Racket. Furthermore, we use an open model (StarCoderBase) with open training data (The Stack), which allows us to decontaminate benchmarks, train models without violating licenses, and run experiments that could not otherwise be done. With MultiPL-T generated data, we present fine-tuned versions of StarCoderBase and Code Llama for Julia, Lua, OCaml, R, and Racket. On established benchmarks (MultiPL-E), these models outperform other open Code LLMs. The MultiPL-T approach is easy to apply to new languages, and is significantly more efficient and effective than alternatives such as training longer.
研究动机与目标
- 为解决 OCaml、Racket 和 Julia 等低资源编程语言在代码大模型中因训练数据不足而导致的性能差距。
- 开发一种可扩展、高效的低资源编程语言高质量训练数据生成方法,无需依赖稀缺的真实代码。
- 与较长训练或标准自我指令方法相比,提升微调的效率与效果。
- 通过使用开源模型和去污染数据,实现开放、符合许可证要求的训练与基准测试。
- 证明基于测试验证的从高资源语言到低资源语言的代码翻译,可在标准基准上实现更优性能。
提出的方法
- 使用代码大模型为高资源语言(如 Python)中的注释代码生成单元测试,并过滤掉错误或覆盖率低的测试。
- 训练代码大模型将高资源语言代码翻译为目标低资源语言,利用生成的测试作为正确性验证。
- 通过自动化测试执行验证翻译后的代码,确保源代码与目标代码在语义上等价。
- 收集并整理数以万计高质量、经验证的代码-测试对,用于 Julia、Lua、OCaml、R 和 Racket 等低资源语言。
- 在生成的半合成数据集上微调开源代码大模型(StarCoderBase 和 Code Llama),以提升性能。
- 使用 The Stack 的去污染训练数据和开源模型,确保实验的可复现性与许可证合规性。
实验结果
研究问题
- RQ1基于测试验证的从高资源语言到低资源语言的代码翻译,能否为代码大模型生成高质量的训练数据?
- RQ2在 MultiPL-T 生成的半合成数据上微调,是否优于标准微调或在低资源语言上进行更长训练?
- RQ3该方法能否在极少人工干预下推广至多种低资源语言?
- RQ4与现有开源代码大模型相比,MultiPL-T 微调后的模型在标准基准上的表现如何?
- RQ5对于低资源语言,自我指令或标准合成数据生成是否因代码质量差而失败?
主要发现
- MultiPL-T 生成的数据集显著提升了 StarCoderBase-15B 和 Code Llama 在 MultiPL-E 基准中低资源语言上的表现。
- 使用 MultiPL-T 微调的模型在所有评估的低资源语言(包括 Julia、Lua、OCaml、R 和 Racket)上均优于其他开源代码大模型。
- 在现有低资源数据上进行更长训练反而损害性能,表明对这些语言而言,数据质量比数量更为关键。
- 自我指令在低资源语言上失败,原因在于代码质量差和测试生成错误,验证了基于测试验证的必要性。
- 该方法在多种低资源语言上均具有可扩展性和有效性,表现出一致的性能提升。
- 使用开源模型和去污染数据,使得此前不可行的可复现、符合许可证要求的实验成为可能。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。