[论文解读] CodeGeeX: A Pre-Trained Model for Code Generation with Multilingual Benchmarking on HumanEval-X
CodeGeeX 是一个 13B 的多语言代码生成模型,在 850B 令牌、23 种语言的训练数据上,优于同规模基线,在代码生成和翻译方面表现更佳,并且有开源发布和 HumanEval-X 基准。
Large pre-trained code generation models, such as OpenAI Codex, can generate syntax- and function-correct code, making the coding of programmers more productive and our pursuit of artificial general intelligence closer. In this paper, we introduce CodeGeeX, a multilingual model with 13 billion parameters for code generation. CodeGeeX is pre-trained on 850 billion tokens of 23 programming languages as of June 2022. Our extensive experiments suggest that CodeGeeX outperforms multilingual code models of similar scale for both the tasks of code generation and translation on HumanEval-X. Building upon HumanEval (Python only), we develop the HumanEval-X benchmark for evaluating multilingual models by hand-writing the solutions in C++, Java, JavaScript, and Go. In addition, we build CodeGeeX-based extensions on Visual Studio Code, JetBrains, and Cloud Studio, generating 4.7 billion tokens for tens of thousands of active users per week. Our user study demonstrates that CodeGeeX can help to increase coding efficiency for 83.4% of its users. Finally, CodeGeeX is publicly accessible and in Sep. 2022, we open-sourced its code, model weights (the version of 850B tokens), API, extensions, and HumanEval-X at https://github.com/THUDM/CodeGeeX.
研究动机与目标
- 开发一个支持广泛语言(23 种语言)并具备强大跨语言能力的多语言代码生成模型。
- 创建并发布 HumanEval-X,以在生成和翻译任务上评估多语言代码模型的功能正确性。
- 提供实用工具(IDE 扩展),以提升编码生产力并展示真实世界的影响。
- 开源模型、权重、API 和评估基准,以实现可重复性并促进进一步研究。
提出的方法
- 采用 GPT 风格的解码器架构,具有 39 层 Transformer,用于自回归代码建模。
- 在涵盖 23 种语言的代码语料库上,以两个月的 Ascend 910 集群运行,在 850B 令牌上训练 CodeGeeX (13B 参数)。
- 为输入序列打上语言指示标签,以帮助模型在训练中区分语言。
- 使用 Top Query Layer 进行最终标记预测,并暴露多种解码策略(贪婪、Top-k、nucleus、束搜索)。
- 在 HumanEval-X 基准上使用 pass@k 进行评估,并通过多语言预算分配来优化跨语言求解率。
- 提供推理优化,包括 FP16/FP32 精度调优、后训练量化到 INT8,以及通过 NVIDIA FasterTransformer 的加速。

实验结果
研究问题
- RQ1与同规模的多语言基线相比,CodeGeeX 在 Python、C++、Java、JavaScript 和 Go 的代码生成上表现如何?
- RQ2在功能正确性方面,CodeGeeX 在语言对之间的代码翻译(5 种语言,20 对源-目标)的表现如何?
- RQ3将生成预算分配到多种语言对对多语言模型的求解性能(pass@k)有何影响?
- RQ4CodeGeeX 的扩展(VS Code、JetBrains、Cloud Studio)在真实编码任务中带来哪些实际好处?
主要发现
- CodeGeeX 在 HumanEval-X 上的代码生成和翻译任务均超越同规模的多语言基线模型。
- CodeGeeX 在各语言上的平均性能最佳,相对于若干基线有提升,并且在与更大规模的 CodeGen-Multi-16B 的对比中具有竞争力。
- HumanEval-X 包含 164 个问题,820 个语言特定的解答,使通过测试用例评估跨语言生成和翻译的功能正确性成为可能。
- CodeGeeX 在 IDE 中的扩展支持代码补全、生成、翻译和解释,用户调查显示效率提升 83.4%。
- 该项目为开源(850B-token 版本的模型权重)、API、扩展和 HumanEval-X,于 2022 年 9 月发布,并报告了显著的实际应用(每周生成 47 亿令牌)。

更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。