CodeShell Technical Report

📄 arXiv: 2403.15747v1 📥 PDF

作者: Rui Xie, Zhengran Zeng, Zhuohao Yu, Chang Gao, Shikun Zhang, Wei Ye

分类: cs.SE, cs.AI

发布日期: 2024-03-23


💡 一句话要点

提出CodeShell-Base以提升代码理解与生成能力

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 代码生成 大型语言模型 数据预处理 代码理解 机器学习

📋 核心要点

  1. 现有的代码生成模型在代码理解和生成能力上仍存在不足,难以满足复杂编程任务的需求。
  2. 论文提出的CodeShell-Base模型通过创新的架构设计和高质量数据预处理,显著提升了代码理解和生成的效率。
  3. 实验结果显示,CodeShell-Base在Humaneval上超越了CodeLlama,展现出强大的基础能力,尤其是在Python、Java和C++等语言上。

📝 摘要(中文)

代码大型语言模型标志着人工智能领域的重大突破,专门用于理解和生成编程语言,显著提升编码开发工作流的效率。本技术报告介绍了CodeShell-Base,一个拥有70亿参数和8K上下文长度的基础模型,展现出卓越的代码理解能力。通过将Grouped-Query Attention和Rotary Positional Embedding整合到GPT-2中,CodeShell-Base结合了StarCoder和CodeLlama的结构优势,形成独特的架构设计。我们还构建了全面的数据预处理流程,包括相似数据去重、基于困惑度的数据过滤和基于模型的数据过滤,从GitHub中精心策划了1000亿高质量的预训练数据。得益于高质量的数据,CodeShell-Base在经过500亿个标记(5个周期)的训练后,在Humaneval上超越了CodeLlama。我们在多个语言数据集(包括Python、Java和C++)上进行了广泛的实验,结果表明我们的模型在代码理解和生成方面具有强大的基础能力。

🔬 方法详解

问题定义:本论文旨在解决现有代码生成模型在代码理解和生成能力上的不足,尤其是在处理复杂编程任务时的局限性。

核心思路:通过设计一个具有70亿参数的基础模型CodeShell-Base,并结合Grouped-Query Attention和Rotary Positional Embedding,提升模型对代码的理解和生成能力。

技术框架:整体架构包括数据预处理、模型训练和评估三个主要阶段。数据预处理阶段采用相似数据去重、困惑度过滤和模型过滤,确保数据质量。

关键创新:最重要的技术创新在于将Grouped-Query Attention和Rotary Positional Embedding引入到GPT-2中,形成独特的模型架构,结合了StarCoder和CodeLlama的优点。

关键设计:模型的参数设置为70亿,使用8K的上下文长度,损失函数采用标准的交叉熵损失,网络结构基于GPT-2进行改进,确保模型在训练时能够有效捕捉代码的语义信息。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

在Humaneval基准测试中,CodeShell-Base在经过500亿个标记的训练后,超越了CodeLlama,展现出更强的代码理解和生成能力。实验结果表明,该模型在Python、Java和C++等多种语言数据集上均表现出色,显示出其强大的基础能力。

🎯 应用场景

CodeShell-Base模型在编程语言的理解和生成方面具有广泛的应用潜力,能够用于自动化代码生成、代码补全、代码审查等场景。其高效的编码能力将极大地提升软件开发的效率,降低开发成本,未来可能在教育、软件开发工具和智能助手等领域发挥重要作用。

📄 摘要(原文)

Code large language models mark a pivotal breakthrough in artificial intelligence. They are specifically crafted to understand and generate programming languages, significantly boosting the efficiency of coding development workflows. In this technical report, we present CodeShell-Base, a seven billion-parameter foundation model with 8K context length, showcasing exceptional proficiency in code comprehension. By incorporating Grouped-Query Attention and Rotary Positional Embedding into GPT-2, CodeShell-Base integrates the structural merits of StarCoder and CodeLlama and forms its unique architectural design. We then carefully built a comprehensive data pre-processing process, including similar data deduplication, perplexity-based data filtering, and model-based data filtering. Through this process, We have curated 100 billion high-quality pre-training data from GitHub. Benefiting from the high-quality data, CodeShell-Base outperforms CodeLlama in Humaneval after training on just 500 billion tokens (5 epochs). We have conducted extensive experiments across multiple language datasets, including Python, Java, and C++, and the results indicate that our model possesses robust foundational capabilities in code comprehension and generation.