SteloCoder: a Decoder-Only LLM for Multi-Language to Python Code Translation

📄 arXiv: 2310.15539v2 📥 PDF

作者: Jialing Pan, Adrien Sadé, Jin Kim, Eric Soriano, Guillem Sole, Sylvain Flamant

分类: cs.CL, cs.AI

发布日期: 2023-10-24 (更新: 2023-12-15)

🔗 代码/项目: GITHUB


💡 一句话要点

提出SteloCoder以解决多语言代码翻译问题

🎯 匹配领域: 支柱二:RL算法与架构 (RL & Architecture) 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 大型语言模型 代码翻译 混合专家 低秩自适应 多任务学习 编程语言 机器学习

📋 核心要点

  1. 现有的代码生成模型在多语言代码翻译功能上仍存在不足,尤其是在训练效率和准确性方面。
  2. SteloCoder通过引入混合专家技术和自适应低秩方法,优化了模型架构,提升了多语言到Python的翻译能力。
  3. 在XLCoST数据集上的实验结果显示,SteloCoder的CodeBLEU分数达73.76,超出现有最佳模型至少3.5分,且训练时间显著缩短。

📝 摘要(中文)

随着对大型语言模型(LLMs)的关注增加,StarCoder和Code Llama在代码生成方面表现出色。然而,代码翻译功能仍需改进。为此,本文提出了SteloCoder,这是一种基于StarCoder的解码器专用LLM,旨在实现多编程语言到Python的代码翻译。SteloCoder能够在不指定输入编程语言的情况下完成C++、C#、JavaScript、Java或PHP到Python的代码翻译。通过引入五个专家和一个门控网络的混合专家(MoE)技术,SteloCoder在XLCoST数据集上实现了73.76的平均CodeBLEU分数,超越了排行榜的最佳表现,且仅增加了45M参数。

🔬 方法详解

问题定义:本文旨在解决现有代码生成模型在多语言到Python代码翻译中的效率和准确性不足的问题。现有方法在处理多种编程语言时,往往需要明确指定输入语言,限制了模型的灵活性。

核心思路:SteloCoder采用解码器专用的架构,结合混合专家(MoE)技术,允许模型在不指定输入语言的情况下进行多语言翻译。通过专家的细化和门控网络的设计,提升了模型的多任务处理能力。

技术框架:整体架构包括一个基于StarCoder的主模型,结合五个经过微调的专家和一个门控网络。每个专家通过低秩自适应方法(LoRA)进行训练,限制其参数规模,确保训练效率。

关键创新:SteloCoder的主要创新在于引入了混合专家技术,使得模型能够在多语言翻译任务中灵活切换,且仅需增加少量参数(45M),显著提升了翻译性能。

关键设计:在参数设置上,采用了低秩自适应方法(LoRA),每个专家的大小仅为StarCoder参数的0.06%。训练过程中采用了课程学习策略和自我指导数据,确保每个专家仅需6小时即可完成训练。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

在XLCoST数据集上的实验结果显示,SteloCoder的平均CodeBLEU分数为73.76,超出排行榜的最佳表现至少3.5分。该模型仅增加了45M额外参数,并在80GB A100 HBM上进行了32小时的有效训练,显示出显著的性能提升。

🎯 应用场景

SteloCoder的研究成果在软件开发、编程教育和自动化测试等领域具有广泛的应用潜力。通过提高多语言代码翻译的效率和准确性,开发者可以更快速地实现跨语言的代码迁移,降低开发成本。此外,该模型还可用于编程学习平台,帮助学生更好地理解不同编程语言之间的转换关系。

📄 摘要(原文)

With the recent focus on Large Language Models (LLMs), both StarCoder (Li et al., 2023) and Code Llama (Rozière et al., 2023) have demonstrated remarkable performance in code generation. However, there is still a need for improvement in code translation functionality with efficient training techniques. In response to this, we introduce SteloCoder, a decoder-only StarCoder-based LLM designed specifically for multi-programming language-to-Python code translation. In particular, SteloCoder achieves C++, C#, JavaScript, Java, or PHP-to-Python code translation without specifying the input programming language. We modified StarCoder model architecture by incorporating a Mixture-of-Experts (MoE) technique featuring five experts and a gating network for multi-task handling. Experts are obtained by StarCoder fine-tuning. Specifically, we use a Low-Rank Adaptive Method (LoRA) technique, limiting each expert size as only 0.06% of number of StarCoder's parameters. At the same time, to enhance training efficiency in terms of time, we adopt curriculum learning strategy and use self-instruct data for efficient fine-tuning. As a result, each expert takes only 6 hours to train on one single 80Gb A100 HBM. With experiments on XLCoST datasets, SteloCoder achieves an average of 73.76 CodeBLEU score in multi-programming language-to-Python translation, surpassing the top performance from the leaderboard by at least 3.5. This accomplishment is attributed to only 45M extra parameters with StarCoder as the backbone and 32 hours of valid training on one 80GB A100 HBM. The source code is release here: https://github.com/sade-adrien/SteloCoder.