DeepSeek-Coder-V2 的训练数据主要由 60% 的源代码、10% 的数学语料和 30% 的自然语言语料构成。由于自然语言语料直接采样自 DeepSeek-V2 的训练数据集,本节将重点阐述代码与数学数据的收集、清洗及过滤流程。同时,我们通过对比分析实验进一步验证了该数据的质量。我们收集了 GitHub 上创建于 2023 年 11 月之前的公开代码仓库。首先,我们应用与 DeepSeek-Coder (Guo et al., 2024 ) 相同的过滤规则与近去重策略,以剔除低质量及重复的源代码。为保证论文的自包含性,我们简要说明这些过滤规则。首先,过滤掉平均行长超过 100 个字符或最大行长超过 1000 个字符的文件。此外,移除字母字符占比低于 25% 的文件。除 XSLT 编程语言外,进一步过滤掉前 100 个字符内包含字符串 "
2. Data Collection
DeepSeek-Coder-V2 的预训练数据主要由 60% 的源代码、10% 的数学语料和 30% 的自然语言语料组成。由于自然语言语料直接采样自 DeepSeek-V2 的训练数据集,本节将重点介绍代码和数学数据的收集、清洗与过滤流程。同时,我们通过对比分析实验进一步验证了该数据的质量。我们收集了 GitHub 上创建于 2023 年 11 月之前的公开代码仓库。我们首先应用与 DeepSeek-Coder(Guo 等,2024)相同的过滤规则和近去重方法,以剔除低质量和重复的源代码。为保证论文的完整性,我们简要描述这些过滤规则。首先,我们过滤掉平均行长超过 100 个字符或最大行长超过 1000 个字符的文件。此外,我们移除字母字符占比低于 25% 的文件。除 XSLT 编程语言外,我们进一步过滤掉前 100 个字符中包含字符串 "
[原文]The pre-training data for DeepSeek-Coder-V2 primarily consists of 60% source code, 10% math
corpus, and 30% natural language corpus. Since the natural language corpus is directly sampled
from the training dataset of DeepSeek-V2, this section focuses on the collection, cleaning, and
filtering processes of the code and math data. Meanwhile, we further validate the quality of this
data through comparative analysis experiments. We collect public repositories created before November 2023 on GitHub. We first apply the
same filtering rules and near-deduplication as those used in the DeepSeek-Coder (G...
2. Data Collection
对于每个域名,我们计算在第一次迭代中收集的网页所占比例。收集网页比例超过10%的域名被归类为代码相关或数学相关。随后,我们在这些已识别的域名内,对与代码或数学内容相关的URL进行标注。与这些URL关联的未收集网页将被加入种子语料库。经过三轮数据收集迭代,我们从网页中收集了700亿个代码相关token和2210亿个数学相关token。为了进一步从GitHub获取高质量的源代码,我们将相同的流程应用于GitHub,经过两轮数据收集迭代,共收集了940亿个源代码token。初始种子语料库是通过手动收集高质量的源代码构建的,例如包含详细描述的代码。最终,新的代码语料库由来自GitHub和CommonCrawl的1.17万亿个代码相关token组成。为验证新代码语料库的有效性,我们使用一个10亿参数模型进行了消融实验(见表1),并将其与用于训练DeepSeek-Coder的语料库进行对比。使用1万亿token在新代码语料库上对该10亿参数模型进行预训练后,其在HumanEval(从30.5%提升至36.0%)和MBPP(从44.6%提升至49.0%)基准测试上的准确率分别提升了5.5%和4.4%。使用2万亿token对该10亿参数模型进行进一步训练后,性能得到进一步提升,HumanEval和MBPP的得分分别上升至37.2%和54.0%。因此,新的代码语料库优于用于训练DeepSeek-Coder的代码语料库。 | 模型 | Token数量 | Python | C++ | Java | PHP | TS | C# | Bash | JS | 平均 | MBPP | |---|---|---|---|---|---|---|---|---|---|---|---| | DeepSeek-Coder-1B | 1T | 30.5% | 28.0% | 31.7% | 23.0% | 30.8% | 31.7% | 9.5% | 28.6% | 26.7% | 44.6% | | DeepSeek-Coder-V2-1B | 1T | 36.0% | 34.8% | 31.7% | 27.3% | 37.7% | 34.2% | 6.3% | 38.5% | 31.2% | 49.0% | | DeepSeek-Coder-V2-1B | 2T | 37.2% | 39.1% | 32.3% | 31.7% | 34.6% | 36.7% | 12.0% | 32.9% | 32.0% | 54.0% |
[原文]For
each domain, we calculate the percentage of web pages collected in the first iteration.Domains
with over 10% of web pages collected are classified as code-related or math-related. We then
annotate the URLs associated with code-related or math-related content within these identified
domains. Uncollected web pages linked to these URLs are added to the seed corpus. After three
iterations of data collection, we gather 70 billion code-related tokens and 221B math-related
tokens from web pages. To further collect high-quality source code from GitHub, we also
apply the same pipeline on GitHub wit...
3.1. Training Strategy
针对 DeepSeek-Coder-v2 16B 模型,我们采用了两种训练目标:下一词元预测(Next-Token-Prediction)与中间填充(Fill-In-Middle, FIM)(Bavarian et al., 2022; Guo et al., 2024; Li et al., 2023b)。对于 DeepSeek-Coder-v2 236B 模型,我们仅使用下一词元预测目标。在此,我们简要介绍 FIM 训练策略。在 DeepSeek-Coder-v2-16B 的开发过程中,我们采用了基于 PSM(前缀、后缀、中间)模式的 FIM 训练方法。该方法按照“前缀、后缀、中间”的顺序对内容重建进行结构化处理,具体格式如下所示: 𝑓𝑝𝑟𝑒 𝑓𝑠𝑢𝑓 𝑓𝑚𝑖𝑑𝑑𝑙𝑒 该结构作为预打包(pre-packing)流程的一部分,在文档级别进行应用。我们与 PSM 框架保持一致,将 FIM 的使用比例设定为 0.5,以提升训练效果和模型性能。
[原文]We use two training objectives for DeepSeek-Coder-v2 16B: Next-Token-Prediction and Fill-In-
Middle (FIM) (Bavarian et al., 2022; Guo et al., 2024; Li et al., 2023b). For DeepSeek-Coder-v2
1https://stackoverflow.com
2https://pytorch.org/docs
3https://math.stackexchange.com
4
236B, we only utilize the Next-Token-Prediction objective. Here we give a brief introduction of
the FIM training policy. We adopt the FIM training approach for the development of DeepSeek-
Coder-v2-16B, leveraging the PSM (Prefix, Suffix, Middle) mode. This method structures the
content reconstruction in the sequence: Pre...
3.2. Model Architecture
本模型的架构与 DeepSeekV2 (DeepSeek-AI, 2024) 保持一致。16B 与 236B 的超参数配置分别对应 DeepSeek-V2-Lite 和 DeepSeek-V2 的设定。值得注意的是,训练过程中出现了不稳定性及梯度值激增现象,我们将其归因于指数归一化技术。为解决该问题,我们改回采用传统的归一化方法。
[原文]Our architecture aligns with that of DeepSeekV2 (DeepSeek-AI, 2024). The hyperparameters
settings, 16B and 236B, correspond to those used in DeepSeek-V2-Lite and DeepSeek-V2, respec-
tively. Notably, we encountered instability during training and spikes in gradient values, which
we attributed to the exponential normalization technique. To address this, we reverted to the
conventional normalization method.
3.3. Training Hyper-Parameters
与 DeepSeek V2 的方法保持一致(DeepSeek-AI, 2024),我们采用 AdamW 优化器(Loshchilov and Hutter, 2019),配置参数为 𝛽1 = 0.9,𝛽2 = 0.95,权重衰减为 0.1。批次大小与学习率依据 DeepSeek-V2 的规范进行调整。在学习率调度方面,我们采用余弦衰减策略,初始设置 2000 步预热,随后逐渐将学习率降至初始值的 10%。 DeepSeek-Coder-V2 与 DeepSeek-Coder-V2-Lite 均采用相同的训练方法。为保持 DeepSeek-Coder-V2 强大的自然语言理解能力,我们基于 DeepSeek-V2 的中间检查点继续预训练。该中间检查点已预先在 4.2T 个 token 上完成训练。因此,在预训练阶段,DeepSeek-Coder-V2 累计处理了 10.2T 个高质量 token。
[原文]Consistent with the DeepSeek V2 methodology (DeepSeek-AI, 2024), we utilize the AdamW
optimizer (Loshchilov and Hutter, 2019), configured with 𝛽1 = 0.9, 𝛽2 = 0.95, and a weight decay
of 0.1. Batch sizes and learning rates are adjusted according to DeepSeek-V2 specifications. For
learning rate scheduling, we employ a cosine decay strategy, starting with 2000 warm-up steps
and gradually reducing the learning rate to 10% of its initial value.
Both DeepSeek-Coder-V2 and DeepSeek-Coder-V2-Lite are trained using the same method-
ology. To maintain robust natural language understanding capabilities i...
3.4. Long Context Extension
遵循 DeepSeek-V2 的做法,我们使用 Yarn (Peng et al., 2023) 将 DeepSeek-Coder-V2 的上下文长度扩展至 128K。YARN 的超参数设置与 DeepSeek-V2 保持一致:缩放因子 s 设为 40,\alpha 设为 1,\beta 设为 32。我们进一步通过两个阶段的持续训练来增强模型处理长上下文的能力。在第一阶段,我们使用 32K 的序列长度和 1152 的批大小进行 1000 步训练。在第二阶段,我们使用 128K 的序列长度和 288 的批大小继续训练 1000 步。 通过“大海捞针”测试对 DeepSeek-Coder-V2 Base 128K 上下文进行压力测试 需要指出的是,在长上下文扩展过程中,我们提高了长上下文数据的采样比例。如图2所示,“大海捞针”(NIAH)测试结果表明,DeepSeek-Coder-V2 在高达 128K 的所有上下文窗口长度下均表现良好。
[原文]Following DeepSeek-V2, we extend the context length of DeepSeek-Coder-V2 to 128K using
Yarn (Peng et al., 2023). The hyper-parameters of YARN are the same as DeepSeek-V2: the scale
𝑠to 40, 𝛼to 1, 𝛽to 32. We further continue training the model using two stages to enhance
its capability for handling long contexts. In the first stage, we utilize a sequence length of
32K and a batch size of 1152 for 1000 steps. In the second stage, we train the model for an
additional 1000 steps, employing a sequence length of 128K and a batch size of 288 sequences.
5
1K
13K
26K
39K
51K
64K
77K
89K
102K
115K
128K...
3.5.1. Supervised Fine-Tuning
为构建 DeepSeek-Coder-V2 Chat,我们构建了一个混合代码与数学数据的指令训练数据集。我们首先从 DeepSeek-Coder 和 DeepSeek-Math 中收集了 2 万条代码相关指令数据以及 3 万条数学相关数据。为保持通用能力,我们还从 DeepSeek-V2 的指令数据中采样了部分数据。最终,我们使用的指令数据集包含 3 亿个 token。在训练过程中,我们采用余弦学习率调度策略,设置 100 步预热,初始学习率为 5×10⁻⁶。此外,我们采用 100 万 token 的批次大小,总训练数据量为 10 亿 token。
[原文]To build DeepSeek-Coder-V2 Chat, we construct the instruction training dataset mixed with
code and math data. We first collect 20k code-related instruction data and 30k math related data
from DeepSeek-Coder and DeepSeek-Math. To maintain the general ability, we also sample
several data from the instruction data of DeepSeek-V2. Finally, we use a instruction dataset
of 300M tokens. For training, we use a cosine schedule with 100 warm-up steps and an initial
learning rate 5𝑒−6. We also use a batch size of 1M tokens and 1B tokens in total.
3.5.2. Reinforcement Learning
我们进一步采用强化学习(RL)技术来充分复现 DeepSeek-Coder-V2 的能力,事实证明该方法非常有效。 提示词 我们投入了大量精力从各类来源收集与代码和数学相关的提示词,且每个代码提示词均附带相应的测试用例。经过筛选后,提示词数据总量约为 4 万条。 奖励建模 奖励模型在强化学习训练中起着至关重要的作用。对于数学偏好数据,我们通过真实标签(ground-truth labels)获取。对于代码偏好数据,尽管代码编译器本身已能提供 0-1 反馈(即代码是否通过所有测试用例),但部分代码提示词的测试用例数量有限且未能实现全覆盖,因此直接使用编译器的 0-1 反馈可能会引入噪声且并非最优。因此,我们仍决定在编译器提供的数据上训练一个奖励模型,并在强化学习训练期间使用该奖励模型提供信号。与原始编译器信号相比,该方法具有更强的鲁棒性和更好的泛化能力。如图 3 所示,在我们的内部测试集(LeetCode 和 LeetCode-zh)上,使用奖励模型提供强化学习训练信号的效果明显优于使用原始编译器信号。因此,在后续所有实验中,我们均采用奖励模型信号而非编译器信号。
[原文]We further employ Reinforcement Learning (RL) techniques to fully simulate the capabilities of
DeepSeek-Coder-V2, which is proven to be quite effective.
Prompts
Considerable effort was spent collecting prompts related to code and math from
various sources, and each code prompt comes with corresponding test cases. After filtering the
prompts, there are approximately 40k data in total.
Reward Modeling
Reward models play crucial roles in the RL training. In terms of mathemat-
ical preference data, we obtain them using the ground-truth labels. In terms of code preference
data, although the code co...
强化学习算法 我们采用群体相对策略优化(Group Relative Policy Optimization, GRPO)[Shao et al. (2024)] 作为强化学习算法,这与 DeepSeek-V2 所使用的算法一致。值得注意的是,GRPO 已被证明非常有效,且与 PPO 相比成本更低,因为它无需维护额外的 Critic(评论家)模型。
4. Experimental Results
在本节中,我们在编程、数学和通用自然语言三类任务上对 DeepSeek-Coder-V2 进行了评估。我们将 DeepSeek-Coder-V2 与以往的最先进大语言模型进行了对比。 • CodeLlama (Roziere 等, 2023) 是一系列基于 Llama2 (Touvron 等, 2023) 的代码语言模型,并在包含 5000 亿至 1 万亿个代码 token 的数据集上进行了持续预训练。这些模型提供四种参数规模:7B、13B、34B 和 70B。 • StarCoder (Lozhkov 等, 2024) 是一个公开可用的 150 亿参数模型。它专门在精心筛选的 Stack 数据集 (Kocetkov 等, 2022) 子集上进行训练,涵盖 86 种编程语言。 • StarCoder2 (Lozhkov 等, 2024) 包含 3B、7B 和 15B 参数规模的模型,这些模型在 Stack2 数据集 (Lozhkov 等, 2024) 的 3.3 万亿至 4.3 万亿个 token 上进行训练,涵盖 619 种编程语言。 • DeepSeek-Coder (Guo 等, 2024) 包含一系列代码语言模型,参数规模从 10 亿到 330 亿不等。每个模型均在 2 万亿个 token 上从头训练,数据组成为 87% 的代码和 13% 的中英文自然语言。这些模型在 16K 上下文窗口的项目级代码语料库上进行预训练,并引入了额外的填空任务,从而支持项目级代码补全与插入(infilling)。 • Codestral (MistralAI, 2024) 是由 Mistral 开发的 220 亿参数模型。它在涵盖 80 多种编程语言的多样化数据集上进行训练,包括 Python、Java 和 JavaScript 等流行语言,以及 Swift 和 Fortran 等更专业的语言。 我们对比的通用语言模型包括 Llama3 70B (Meta, 2024)、GPT-4 (OpenAI, 2023)、Claude 3 Opus (Anthropic, 2024) 和 Gemini 1.5 Pro (Reid 等, 2024)。尽管它们并未专门在大型代码语料库上进行训练,但在编程任务上仍取得了最先进的性能。
[原文]In this section, we evaluate DeepSeek-Coder-V2 on three types of tasks, including coding,
mathematics, and general natural language. We compare DeepSeek-Coder-V2 with the previous
state-of-the-art large language models.
• CodeLlama (Roziere et al., 2023) consists of a series of code language models based on
Llama2 (Touvron et al., 2023), and continue pre-training on datasets ranging from 500 to
1000 billion code tokens. These models are available in four sizes: 7B, 13B, 34B, and 70B.
• StarCoder (Lozhkov et al., 2024) is a publicly accessible model with 15 billion parameters.
It is specificall...
4.1. Code Generation
将 ttps://stackoverflow.com、库网站(如 PyTorch 文档 2 2 2 https://pytorch.org/docs)以及数学网站(如 StackExchange 3 3 3 https://math.stackexchange.com)作为我们的初始种子语料库。使用该种子语料库,我们训练了一个 fastText 模型(Joulin et al., 2016),以召回更多与编程和数学相关的网页。由于中文等语言的词元化无法通过空格完成,我们采用了来自 DeepSeek-V2 的字节对编码(BPE)分词器,这显著提高了 fastText 的召回准确率。对于每个域名,我们计算在第一次迭代中收集的网页所占的百分比。收集到的网页比例超过 10% 的域名被归类为代码相关或数学相关。随后,我们在这些已识别的域名内,对与代码或数学内容相关的 URL 进行标注。与这些 URL 关联的未收集网页将被添加至种子语料库中。经过三轮数据收集迭代,我们从网页中收集了 700亿个代码相关词元和 221B 个数学相关词元。为了进一步从 GitHub 收集高质量的源代码,我们还在 GitHub 上应用了相同的流程,经过两轮数据收集迭代,共收集了 94B 源代码。初始种子语料库是通过手动收集高质量的源代码构建的,例如包含详细说明的代码。最终,新的代码语料库由来自 GitHub 和 CommonCrawl 的 1,170B 个代码相关词元组成。为了验证新代码语料库的有效性,我们使用一个 1B 参数模型进行了消融实验(见表 1),并将其与用于训练 DeepSeek-Coder 的语料库进行了对比。使用 1T 个词元在新代码语料库上对该 1B 模型进行预训练后,其在 HumanEval(从 30.5% 提升至 36.0%)和 MBPP(从 44.6% 提升至 49.0%)基准测试上的准确率分别提高了 5.5% 和 4.4%。使用 2T 个词元对该 1B 模型进行进一步训练带来了额外的提升,HumanEval 和 MBPP 的得分分别上升至 37.2% 和 54.0%,分别
[原文]HumanEval and MBPP Benchmarks. The HumanEval (Chen et al., 2021) 4 and MBPP (Austin
et al., 2021b) benchmarks are commonly utilized for assessing the performance of code-generating
Large Language Models (LLMs). HumanEval comprises 164 Python tasks that are verified
through test cases to evaluate the performance of Code LLMs in a zero-shot scenario. For MBPP,
we use the MBPP-Plus version (Liu et al., 2023a) to evaluate the models. To test the multilingual
abilities of models, we extended the HumanEval benchmark problems into seven additional
languages: C++, Java, PHP, TypeScript, C#, Bash, Java...
4.1. Code Generation
有效地。因此,新的代码语料库优于用于训练 DeepSeek-Coder 的代码语料库。
[原文]For both benchmarks, we employed a greedy search strategy and recreated the baseline results
using identical scripts and environments to ensure a fair comparison.
#TP
#AP
Python
Java
C++
C#
TS
JS
PHP
Bash
Closed-Source Models
Gemini-1.5-Pro
-
-
83.5%
81.0%
78.3%
75.3%
77.4%
80.8%
74.5%
39.9%
Claude-3-Opus
-
-
84.2%
78.5%
81.4%
74.7%
76.1%
75.8%
78.3%
48.7%
GPT-4-1106
-
-
87.8%
82.3%
78.9%
80.4%
81.8%
80.1%
77.6%
55.7%
GPT-4-Turbo-0409
-
-
88.2%
81.7%
78.3%
79.1%
79.3%
80.8%
78.9%
55.1%
GPT-4o-0513
-
-
91.0%
80.4%
87.0%
82.9%
86.2%
87.6%
79.5%
53.8%
Open-Source Models
Codestral
22B
22B
78.1%
71...
表1:DeepSeek-Coder 与 DeepSeek-Coder-V2 的 1B 基座模型性能对比。
| 模型 | Token数 | Python | C++ | Java | PHP | TS | C# | Bash | JS | 平均 | MBPP |
|---|---|---|---|---|---|---|---|---|---|---|---|
| DeepSeek-Coder-1B | 1T | 30.5% | 28.0% | 31.7% | 23.0% | 30.8% | 31.7% | 9.5% | 28.6% | 26.7% | 44.6% |
| DeepSeek-Coder-V2-1B | 1T | 36.0% | 34.8% | 31.7% | 27.3% | 37.7% | 34.2% | 6.3% | 38.5% | 31.2% | 49.0% |
| DeepSeek-Coder-V2-1B | 2T | 37.2% | 39.1% | 32.3% | 31.7% | 34.6% | 36.7% | 12.0% | 32.9% | 32.0% | 54.0% |
4.1. Code Generation
这一表现尤为显著,因为它打破了闭源模型通常占据的主导地位,成为领先的开源竞争者之一。其成绩仅被平均分为76.4%的GPT-4o超越。DeepSeek-Coder-V2-Instruct在多种编程语言中均展现出顶尖水平,不仅在Java和PHP中取得最高分,在Python、C++、C#、TypeScript和JavaScript中也表现强劲,凸显了其在应对多样化编程挑战时的鲁棒性与通用性。此外,DeepSeek-Coder-V2-Lite-Instruct的表现同样令人瞩目,超越了参数量更大的33B模型。在平均性能上具有显著优势(65.6% 对比 61.9%),这凸显了16B模型尽管规模较小,仍能交付具有竞争力结果的效能。这进一步印证了该模型的高效性,以及其在模型架构与训练方法上的进步,使其能够超越规模更大的同类模型。 算法竞赛编程。为了进一步验证该模型在真实算法竞赛问题中的能力,我们采用LiveCodeBench(Jain等人,2024)和USACO基准测试(Shi等人,2024)来评估DeepSeek-Coder-V2的有效性。LiveCodeBench是一项针对大语言模型(LLM)代码生成能力的严谨且无数据污染的评估基准,它系统性地从三个知名的算法竞赛平台(LeetCode、AtCoder和CodeForces)随时间推移收集新颖的编程挑战。由于训练数据的截止时间在2023年11月之前,我们使用了LiveCodeBench的子集(1201-0601)。USACO基准测试包含来自美国计算机奥林匹克竞赛(USACO)的307道题目,并为每道题提供了高质量的单元测试、参考代码和官方解析。
[原文]This performance is notable as it breaks the dominance typically seen from
closed-source models, standing out as a leading open-source contender.It is surpassed only
by GPT-4o, which leads with an average score of 76.4%. DeepSeek-Coder-V2-Instruct shows
top-tier results across a variety of languages, including the highest scores in Java and PHP, and
strong performances in Python, C++, C#, TypeScript, and JavaScript, underscoring its robustness
and versatility in handling diverse coding challenges. Furthermore, the DeepSeek-Coder-V2-Lite-Instruct also performs impressively, surpassing
the large...
4.2.1. Repository-Level Code Completion Evaluation
我们使用 RepoBench (Liu et al., 2023b) 来评估当前可用的参数量低于 35B 的开源代码模型在仓库级代码补全任务中的能力。该数据集由多种真实世界、开源且采用宽松许可证的仓库构建而成,涵盖两种流行的编程语言:Python 和 Java。值得注意的是,RepoBench 的最新版本(v1.1)的数据来源于 2023 年 10 月 6 日至 12 月 31 日期间创建的 GitHub 仓库,而我们的预训练数据包含 2023 年 11 月之前创建的代码。为确保该数据集未出现在我们的预训练数据中并避免数据泄露,我们仅使用 2023 年 12 月的数据。我们的评估涵盖五个上下文长度级别——2k、4k、8k、12k 和 16k 个 token——并在三种设置下进行:跨文件首部(cross-file-first)、跨文件随机(cross-file-random)和文件内(in-file)。我们对所有待评估模型均采用贪心搜索策略。模型被限制为每个提示最多生成 64 个新 token,并选取输出中第一行非空且非注释的行作为预测结果。通过截断多余的跨文件上下文,提示的最大 token 长度被设置为 15,800。我们报告了不同上下文长度级别的平均精确匹配率。 如表 5 所示,结果表明,尽管 DeepSeek-Coder-V2-Lite-Base 模型仅拥有 24 亿个激活参数,但其在 Python 上的代码补全能力已可与 DeepSeek-Coder-Base 33B 模型相媲美,在 Java 上的表现则与 DeepSeek-Coder-Base 7B 模型相当。
[原文]We use RepoBench (Liu et al., 2023b) to evaluate the capabilities of currently available open-
source code models with sizes below 35B in repository-level code completion tasks. This dataset
is constructed from a diverse set of real-world, open-sourced, permissively licensed repositories
in two popular programming languages: Python and Java. Notably, the latest version (v1.1)
of RepoBench sources its data from GitHub repositories created between October 6th and
December 31st, 2023, while our pre-training data includes code created before November 2023. To ensure this dataset was not present in...
4.2.1. Repository-Level Code Completion Evaluation
与 CodeStral 相比,DeepSeek-Coder-V2-Lite-Base 模型的激活参数仅为 CodeStral 的十分之一,导致其在代码补全任务中的性能较低。然而,我们认为 DeepSeek-Coder-V2 较少的激活参数使其在代码补全场景中具备更快的推理速度。
[原文]Compared to CodeStral, the DeepSeek-Coder-V2-Lite-Base
model has only one-tenth of the active parameters of CodeStral, resulting in lower performance
in code completion tasks.However, we believe that the smaller number of active parameters in
DeepSeek-Coder-V2 makes it faster for code completion scenarios.
4.2.2. Fill-in-the-Middle Code Completion
DeepSeek-Coder-V2-Lite 采用了一种独特的训练方法,在其预训练阶段包含了 0.5 的中间填充(Fill-In-the-Middle, FIM)比例。该方法使模型能够利用上下文(包括前导和后续代码片段)熟练地通过填空方式完成代码补全。这一能力对于代码补全工具尤为有利。多个开源模型(如 SantaCoder (Allal et al., 2023)、StarCoder (Li et al., 2023b) 和 CodeLlama (Roziere et al., 2023))也利用了类似的能力,并在代码生成与补全领域树立了高标准。 为评估 DeepSeek-Coder-V2 模型的性能,我们将其与主流领先模型进行了对比分析。评估基于单行填充(Single-Line Infilling)基准测试,涵盖 Allal 等人 (2023) 所述的三种不同编程语言。本次评估的主要指标为行级精确匹配准确率^5。 该表展示了各代码模型在 Python、Java 和 JavaScript 三种编程语言上的 FIM(中间填充)任务性能,其中均值分数反映了整体有效性。在对比模型中,配置为 24 亿(2.4B)活跃参数的 DeepSeek-Coder-V2-Lite-Base 取得了卓越的成绩。其在 Python、Java 和 JavaScript 上的得分分别为 80.0%、89.1% 和 87.2%,最终取得了 86.4% 的最高均值分数。这证明了 DeepSeek-Coder-V2-Lite-Base 的优越有效性,尤其在处理跨不同编程语言的 FIM 任务时,其性能与评估中的其他更大规模模型相当。
[原文]DeepSeek-Coder-V2-Lite is trained with a unique approach that includes a 0.5 Fill-In-the-Middle
(FIM) rate during their pre-training phase. This method allows the model to adeptly complete
code by filling in blanks using the surrounding context, which includes both the preceding and
following code segments. This ability is particularly advantageous for code completion tools.
Several open-source models, such as SantaCoder (Allal et al., 2023), StarCoder (Li et al., 2023b),
and CodeLlama (Roziere et al., 2023), also leverage similar capabilities and have established
high standards in the domain ...
4.3. Code Fixing
为评估模型的缺陷修复能力,我们使用 Defects4J [7]、SWE-bench (Jimenez et al., 2023) 和 Aider [8] 数据集进行测试。Defects4J 是软件工程领域广泛使用的数据集,专门用于评估和测试程序修复技术。该数据集包含来自多个开源项目(包括但不限于 Apache Commons、JFreeChart 和 Closure Compiler)的真实软件缺陷集合。数据集中的每个缺陷都附带测试套件,可用于验证程序修复工具的有效性。由于 Defects4J 中的原始缺陷可能需要修改仓库中的多个文件,从而导致上下文过长,我们从此基准测试中筛选出仅需修改单个方法的 238 个缺陷。SWE-bench 是一项综合性基准测试,旨在评估大语言模型在解决源自 GitHub 的真实软件问题方面的性能。该基准测试会提供代码库及特定问题,要求语言模型生成能有效解决所述问题的补丁。这一严谨的评估框架确保了对语言模型理解和修复真实软件问题能力的全面测试,为其在软件开发任务中的实用性和有效性提供了明确的衡量标准。Aider 的代码编辑基准测试评估了大语言模型修改 Python 源文件的能力,共包含 133 个不同的编程任务。该基准测试不仅检验大语言模型的编程能力,还评估其根据提示词规范生成代码修改的一致性。 5 我们采用首行生成结果而非完整的生成代码块,因此结果与 DeepSeek-Coder 略有差异。
[原文]To evaluate the bug-fixing capabilities of the model, we used the Defects4J 7, SWE-bench
(Jimenez et al., 2023), and Aider 8 datasets for testing. Defects4J is a widely used dataset in the
field of software engineering, specifically designed for the purpose of evaluating and testing
program repair techniques. It consists of a collection of real-world software bugs from various
open-source projects, including but not limited to Apache Commons, JFreeChart, and Closure
Compiler. Each bug in the dataset is accompanied by test suites that can be used to validate
the effectiveness of program repair ...
4.3. Code Fixing
由于Llama3-Instruct仅支持8K上下文长度,我们未在SWE-Bench上对其进行评估。表7汇总了不同语言模型在软件修复基准测试(包括Defects4J、SWE-Bench和Aider)上的性能表现。在开源模型中,DeepSeek-Coder-Instruct表现尤为突出,取得了开源模型中的最佳成绩。该模型在Defects4J和SWE-Bench上的得分分别为21%和12.7%,已接近领先闭源模型的水平,并展现出处理较长代码序列的显著能力。值得注意的是,DeepSeek-Coder-V2-Instruct在Aider上取得了73.7%的最高分,超越了列表中所有其他模型(含闭源模型)。这一卓越性能凸显了其在自动化代码修复任务中的高效性与鲁棒性,确立了DeepSeek-Coder-V2-Instruct作为顶尖开源模型的地位,使其成为该领域闭源替代方案的强劲竞争者。
[原文]We do not evaluate
Llama3-Instruct on SWE-Bench as it just supports 8K context length.Table 7 outlines the performances of different language models on software repair bench-
marks, including Defects4J, SWE-Bench, and Aider. Among open-source models, DeepSeek-
Coder-Instruct emerges as a standout, achieving the best performance within the open source
models. It scores 21% in Defects4J and 12.7% in SWE-Bench, closely approaching the results
of leading closed-source models and demonstrating significant capability in handling longer
code sequences. Notably, DeepSeek-Coder-V2-Instruct achieves the...
4.4. Code Understanding and Reasoning
4.4. 代码理解与推理
与 DeepSeek V2 的方法一致(DeepSeek-AI, 2024),我们采用 AdamW 优化器(Loshchilov and Hutter, 2019),配置参数为 \beta_{1}=0.9、\beta_{2}=0.95,权重衰减为 0.1。批量大小与学习率均依据 DeepSeek-V2 的规范进行调整。在学习率调度方面,我们采用余弦衰减策略,初始设置 2000 步预热,随后逐渐将学习率降至初始值的 10%。DeepSeek-Coder-V2 与 DeepSeek-Coder-V2-Lite 均采用相同的训练方法。为保持 DeepSeek-Coder-V2 强大的自然语言理解能力,我们基于 DeepSeek-V2 的中间检查点继续预训练。该中间检查点最初已在 4.2T 个 token 上进行训练。因此,在预训练阶段,DeepSeek-Coder-V2 总共接触了 10.2T 个高质量 token。 | 模型 | DeepSeek-Coder-V2-Lite | DeepSeek-Coder-V2 | |---|---|---| | # 总参数量 (#TP) | 16B | 236B | | # 激活参数量 (#AP) | 2.4B | 21B | | 预训练 Token 数 | 4.2T+6T | 4.2T+6T | | 学习率调度器 | Cosine | Cosine | | FIM | 启用 | 禁用 |
[原文]To assess the code reasoning capabilities of our models, we utilize the CRUXEval benchmark.
This benchmark comprises 800 Python functions paired with corresponding input-output
examples. It is divided into two distinct tasks: CRUXEval-I, which requires the large language
model (LLM) to predict the output based on the given input, and CRUXEval-O, where the model
must predict the input from the known output. This structure challenges the model’s ability
to understand and reason through Python code in both forward and reverse directions. Table
8 presents the performance of various language models...
表 2:DeepSeek-Coder-V2 的训练设置。
4.5. Mathematical Reasoning
4.5. 数学推理
遵循 DeepSeek-V2 的做法,我们使用 Yarn (Peng et al., 2023) 将 DeepSeek-Coder-V2 的上下文长度扩展至 128K。YARN 的超参数与 DeepSeek-V2 保持一致:缩放因子 s 设为 40,\alpha 设为 1,\beta 设为 32。我们进一步采用两阶段训练策略继续训练模型,以增强其处理长上下文的能力。在第一阶段,我们使用 32K 的序列长度和 1152 的批次大小训练 1000 步。在第二阶段,我们额外训练 1000 步,采用 128K 的序列长度和 288 的批次大小。需要指出的是,在长上下文扩展期间,我们提高了长上下文数据的采样比例。如图 2 所示,“大海捞针”(Needle In A Haystack, NIAH)测试结果表明,DeepSeek-Coder-V2 在高达 128K 的所有上下文窗口长度下均表现良好。图 2:“大海捞针”(NIAH)测试的评估结果。DeepSeek-Coder-V2 在高达 128K 的所有上下文窗口长度下均表现良好。
[原文]To assess the mathematical reasoning capabilities of DeepSeekCoder-V2, we utilized the popular
grade-school benchmark GSM8K (Cobbe et al., 2021), along with advanced competition-level
benchmarks including MATH (Hendrycks et al., 2021), the American Invitational Mathematics
Examination (AIME) 2024 (MAA, 2024), and Math Odyssey (Netmind.AI, 2024)9.
Model
#TP
#AP GSM8K MATH AIME 2024 Math Odyssey
Closed-Source Models
Gemini 1.5 Pro
-
-
90.8%
67.7%
2/30
45.0%
Claude-3-Opus
-
-
95.0%
60.1%
2/30
40.6%
GPT-4-1106
-
-
91.4%
64.3%
1/30
49.1%
GPT-4-Turbo-0409
-
-
93.7%
73.4%
3/30
46.8%
GPT-4o-0513
-
-
9...
4.6. General Natural Language
3.5.1 监督微调 为构建 DeepSeek-Coder-V2 Chat,我们构建了混合代码与数学数据的指令训练数据集。我们首先从 DeepSeek-Coder 和 DeepSeek-Math 中收集了 20k 条代码相关指令数据与 30k 条数学相关数据。为维持通用能力,我们还从 DeepSeek-V2 的指令数据中采样了部分数据。最终,我们使用了包含 300M tokens 的指令数据集。在训练过程中,我们采用余弦学习率调度策略,设置 100 步预热,初始学习率为 $5e^{-6}$。此外,我们使用 1M tokens 的批次大小,总训练数据量为 1B tokens。 3.5.2 强化学习 我们进一步采用强化学习(RL)技术以充分激发 DeepSeek-Coder-V2 的能力,该方法已被证明十分有效。 提示词 我们投入了大量精力从各类来源收集与代码和数学相关的提示词,且每个代码提示词均附带相应的测试用例。经过筛选后,提示词数据总量约为 40k 条。 奖励建模 奖励模型在 RL 训练中发挥着至关重要的作用。对于数学偏好数据,我们通过真实标签获取。对于代码偏好数据,尽管代码编译器本身已能提供 0-1 反馈(即代码是否通过所有测试用例),但部分代码提示词的测试用例数量有限,无法提供完整覆盖,因此直接使用编译器提供的 0-1 反馈可能会存在噪声且非最优。因此,我们仍决定在编译器提供的数据上训练一个奖励模型,并在 RL 训练期间使用该奖励模型提供信号。与原始编译器信号相比,该方法更具鲁棒性且泛化能力更强。如图 3 所示,在我们的内部测试集(Leetcode 和 Leetcode-zh)上,使用奖励模型提供 RL 训练信号的效果明显优于使用原始编译器信号。因此,我们在
4.6. General Natural Language
所有后续实验。强化学习算法 我们采用组相对策略优化(GRPO)Shao 等(2024)作为我们的强化学习算法,这与 DeepSeek-V2 所使用的算法相同。值得注意的是,GRPO 已被证明十分有效,且与 PPO 相比成本更低,因为无需维护额外的评论家模型。图3:不同方法的性能
[原文]Moving on to 236B models, DeepSeek-Coder-V2 Instruct exhibits greater strength in rea-
soning benchmarks, particularly in Arena-Hard, which comprises a substantial proportion of
code, math, and reasoning questions.On the other hand, DeepSeek-V2 Chat demonstrates
slightly better results in benchmarks such as MT-bench (Zheng et al., 2023), AlpacaEval 2.0
(Dubois et al., 2024), and AlignBench (Liu et al., 2023c). This advantage can be attributed to the
general-purpose alignment stage of DeepSeek-V2 Chat.
5. Conclusion
本文介绍了 DeepSeek-Coder-V2,旨在进一步推动代码智能领域的发展。该模型基于 DeepSeek-V2 进行持续预训练,使用了源自高质量、多源语料库的 6 万亿 token。通过持续预训练,我们发现 DeepSeek-Coder-V2 在显著提升模型代码编写与数学推理能力的同时,保持了与 DeepSeek-V2 相当的通用语言性能。与 DeepSeek-Coder 相比,DeepSeek-Coder-V2 支持的编程语言数量大幅增加,从 86 种提升至 338 种,并将最大上下文长度从 16K 扩展至 128K token。实验结果表明,在代码与数学专项任务中,DeepSeek-Coder-V2 的性能已达到与 GPT-4 Turbo、Claude 3 Opus 及 Gemini 1.5 Pro 等最先进闭源模型相当的水平。 尽管 DeepSeek-Coder-V2 在标准基准测试中取得了优异的性能,但我们发现,与 GPT-4 Turbo 等当前最先进模型相比,其在指令遵循能力方面仍存在显著差距。这一差距导致模型在 SWEbench 等复杂场景与任务中表现欠佳。因此,我们认为,代码模型不仅需要强大的编程能力,还需具备卓越的指令遵循能力,方能有效应对现实世界中复杂的编程场景。未来,我们将更加专注于提升模型的指令遵循能力,以更好地处理现实世界中的复杂编程任务,进而提升软件开发流程的整体效率。
[原文]In this paper, we introduce DeepSeek-Coder-V2 to further advance the field of code intelligence,
which is continually pre-trained from DeepSeek-V2 with 6 trillion tokens sourced from a high-
quality and multi-source corpus. Through this continued pre-training, we find that DeepSeek-
14
Coder-V2 significantly enhances the model’s capabilities in coding and mathematical reasoning
while maintaining comparable general language performance to DeepSeek-V2. Compared to
DeepSeek-Coder, DeepSeek-Coder-V2 supports a significantly larger number of programming
languages, increasing from 86 to 338, and ex...
References
MBPP 基准测试。HumanEval(Chen et al., 2021)4 4 4 我们使用模板“请完成以下 Python 函数。您的函数的最终完整版本必须在一个代码块中返回。以下是未完成的函数:\n ```python\n{problem_description}\n\n”来构建指令提示。以及 MBPP(Austin et al., 2021b)基准测试通常用于评估代码生成大型语言模型(LLMs)的性能。HumanEval 包含 164 个 Python 任务,通过测试用例进行验证,以评估代码 LLM 在零样本场景下的性能。对于 MBPP,我们使用 MBPP-Plus 版本(Liu et al., 2023a)来评估模型。为了测试模型的多语言能力,我们将 HumanEval 基准测试问题扩展到了七种额外语言:C++、Java、PHP、TypeScript、C#、Bash、JavaScript、Swift、R、Julia、D、Rust 和 Racket。对于这两个基准测试,我们均采用贪婪搜索策略,并使用相同的脚本和环境重新生成基线结果,以确保公平比较。 #TP #AP Python Java C++ C# TS JS PHP Bash 闭源模型 Gemini-1.5-Pro - - 83.5% 81.0% 78.3% 75.3% 77.4% 80.8% 74.5% 39.9% Claude-3-Opus - - 84.2% 78.5% 81.4% 74.7% 76.1% 75.8% 78.3% 48.7% GPT-4-1106 - - 87.8% 82.3% 78.9% 80.4% 81.8% 80.1% 77.6% 55.7% GPT-4-Turbo-0409 - - 88.2% 81.7% 78.3% 79.1% 79.3% 80.8% 78.9% 55.1% GPT-4o-0513 - - 91.0% 80.4% 87.0% 82.9% 86.2% 87.6% 79.5% 53.8% 开源模型 Codestral 22B 22B 78.1% 71.5% 71.4% 77.2% 72.3% 73.9% 69.6% 47.5% DS-Coder-instruct 33B 33B 79.3% 73.4% 68.9% 74.1% 67.9% 73.9% 72.7% 43.0% Llama3-Instruct 70B 70B 81.1% 67.7% 64.0% 69.6% 69.8% 70.2% 65.8% 36.1% DS-Coder-V2-Lite-Instruct 16B 2.4B 81.1% 76.6% 75.8% 76.6% 80.5% 77.6% 74.5% 43.0% DS-Coder-V2-Instruct 236B 21B 90.2% 82.3% 84.8% 82.3% 83.0% 84.5% 79.5% 52.5% #TP #AP Swift R Julia D Rust Racket MBPP + superscript MBPP \text{MBPP}^{+} 平均 闭源模型 Gemini-1.5-Pro - - 66.5% 53.4% 71.7% 55.8% 73.1% 48.4% 74.
[原文]L. B. Allal, R. Li, D. Kocetkov, C. Mou, C. Akiki, C. M. Ferrandis, N. Muennighoff, M. Mishra,
A. Gu, M. Dey, et al. Santacoder: don’t reach for the stars! arXiv preprint arXiv:2301.03988,
2023.
A. Anthropic. The claude 3 model family: Opus, sonnet, haiku. Claude-3 Model Card, 2024.
J. Austin, A. Odena, M. Nye, M. Bosma, H. Michalewski, D. Dohan, E. Jiang, C. Cai, M. Terry,
Q. Le, and C. Sutton. Program synthesis with large language models, 2021a.
J. Austin, A. Odena, M. Nye, M. Bosma, H. Michalewski, D. Dohan, E. Jiang, C. Cai, M. Terry,
Q. Le, et al. Program synthesis with large language mod...
2018. URL http://arxiv.org/abs/1803.05457.
6% 68.9% Claude-3-Opus - - 63.9% 55.9% 76.1% 60.3% 71.2% 64.6% 72.0% 70.8% GPT-4-1106 - - 62.7% 57.8% 69.2% 60.9% 78.8% 64.0% 69.3% 72.5% GPT-4-Turbo-0409 - - 63.9% 56.5% 69.8% 61.5% 78.8% 63.4% 72.2% 72.3% GPT-4o-0513 - - 75.9% 65.2% 78.0% 60.9% 80.1% 64.6% 73.5% 76.4% Open-Source Models Codestral 22B 22B 63.3% 49.7% 67.9% 32.1% 67.3% 37.3% 68.2% 63.2% DS-Coder-instruct 33B 33B 61.4% 44.7% 53.5% 31.4% 68.6% 46.0% 70.1% 61.9% Llama3-Instruct 70B 70B 55.1% 46.0% 62.9% 48.1% 58.3% 46.0% 68.8% 60.6% DS-Coder-V2-Lite-Instruct 16B 2.4B 64.6% 47.8% 67.3% 45.5% 62.2% 41.6% 68.8% 65.6% DS-Coder-V2-Instruct 236B 21B 72.2% 64.0% 72.3% 64.1% 78.2% 63.4% 76.2% 75.3% 表3:各模型在HumanEval与MBPP基准测试上的性能指标
[原文]K. Cobbe, V. Kosaraju, M. Bavarian, M. Chen, H. Jun, L. Kaiser, M. Plappert, J. Tworek,
J. Hilton, R. Nakano, et al. Training verifiers to solve math word problems. arXiv preprint
arXiv:2110.14168, 2021. DeepSeek-AI. Deepseek-v2: A strong, economical, and efficient mixture-of-experts language
model, 2024. Y. Dubois, B. Galambosi, P. Liang, and T. B. Hashimoto. Length-controlled alpacaeval: A simple
way to debias automatic evaluators. arXiv preprint arXiv:2404.04475, 2024.
15
D. Guo, Q. Zhu, D. Yang, Z. Xie, K. Dong, W. Zhang, G. Chen, X. Bi, Y. Wu, Y. Li, et al. Deepseek-
coder: When the larg...
表3全面概述了各模型在HumanEval与MBPP及MBPP\text{MBPP}^{+}基准测试上跨多种编程语言的绩效指标。DeepSeek-Coder-V2-Instruct展现出卓越的性能,以75.3%的平均得分位列第二。该表现尤为引人注目,因其打破了闭源模型通常占据的主导地位,成为领先的开源竞争者。仅GPT-4o以76.4%的平均得分领先于该模型。DeepSeek-Coder-V2-Instruct在多种编程语言中均取得顶尖结果,包括在Java与PHP中斩获最高分,并在Python、C++、C#、TypeScript与JavaScript中表现强劲,凸显了其在应对多样化编程挑战时的鲁棒性与通用性。此外,DeepSeek-Coder-V2-Lite-Instruct的表现同样令人印象深刻,超越了参数量更大的33B模型。凭借在平均性能上的显著优势(65.6%对比61.9%),它凸显了16B模型尽管规模较小,仍能交付具有竞争力结果的效能。这进一步强调了该模型的效率,以及模型架构与训练方法的进步,使其能够超越更大的co
2018. URL http://arxiv.org/abs/1803.05457.
同类模型。竞赛编程。为了进一步验证该模型在真实世界竞赛编程问题中的能力,我们利用 LiveCodeBench (Jain et al., 2024) 和 USACO 基准测试 (Shi et al., 2024) 来评估 DeepSeek-Coder-V2 的有效性。LiveCodeBench 是对大型语言模型(LLMs)代码生成能力的一项细致且无数据污染的评估,它系统性地从三个著名的竞赛编程平台(LeetCode、AtCoder 和 CodeForces)随时间推移收集新颖的挑战题。由于训练数据的截止时间在 2023 年 11 月之前,我们使用了 LiveCodeBench 的子集(1201-0601)。USACO 基准测试包含来自美国计算机奥林匹克竞赛的 307 道题目,并为每道题目提供了高质量的单元测试、参考代码和官方解析。 | 模型 | #TP | #AP | LiveCodeBench 简单 (82) | 中等 (87) | 困难 (57) | 总体 (226) | USACO | |---|---|---|---|---|---|---|---| | **闭源模型** | | | | | | | | | Gemini-1.5-Pro | - | - | 74.9% | 16.8% | 1.8% | 34.1% | 4.9% | | Claude-3-Opus | - | - | 77.2% | 16.7% | 0.7% | 34.6% | 7.8% | | GPT-4-1106 | - | - | 78.4% | 20.2% | 3.5% | 37.1% | 11.1% | | GPT-4-Turbo-0409 | - | - | 84.1% | 35.4% | 6.1% | 45.7% | 12.3% | | GPT-4o-0513 | - | - | 87.4% | 27.5% | 4.9% | 43.4% | 18.8% | | **开源模型** | | | | | | | | | Codestral | 22B | 22B | 66.5% | 17.7% | 0.2% | 31.0% | 4.6% | | DS-Coder-instruct | 33B | 33B | 51.6% | 9.7% | 0.4% | 22.5% | 4.2% | | Llama3-Instruct | 70B | 70B | 62.4% | 14.4% | 2.1% | 28.7% | 3.3% | | DS-Coder-V2-Lite-Instruct | 16B | 2.4B | 58.5% | 8.0% | 0.0% | 24.3% | 6.5% | | DS-Coder-V2-Instruct | 236B | 21B | 84.1% | 29.9% | 5.3% | 43.4% | 12.1% |
[原文]Transactions on
Machine Learning Research, 2022.T. Kwiatkowski, J. Palomaki, O. Redfield, M. Collins, A. P. Parikh, C. Alberti, D. Epstein,
I. Polosukhin, J. Devlin, K. Lee, K. Toutanova, L. Jones, M. Kelcey, M. Chang, A. M. Dai,
J. Uszkoreit, Q. Le, and S. Petrov. Natural questions: a benchmark for question answering
research. Trans. Assoc. Comput. Linguistics, 7:452–466, 2019. doi: 10.1162/tacl\_a\_00276. URL https://doi.org/10.1162/tacl_a_00276. H. Li, Y. Zhang, F. Koto, Y. Yang, H. Zhao, Y. Gong, N. Duan, and T. Baldwin. CMMLU: Measur-
ing massive multitask language understanding in Chines...
表 4:在 LiveCodeBench (LCB) 和 USACO 基准测试上的性能表现。表 4 展示了各种语言模型在这两个基准测试上的性能。值得注意的是,DeepSeek-Coder-V2-Instruct 表现突出,在大模型中以 43.4% 的得分并列最高,与 GPT-4o 持平。这一卓越的成绩使其总体排名第二,仅次于以 45.7% 总体性能领先的 GPT-4-Turbo-0409。DeepSeek-Coder-V2-Instruct 在处理复杂编程挑战方面的出色能力,使其稳居顶尖竞争者之列,紧随其...
2018. URL http://arxiv.org/abs/1803.05457.
ng 领先的 GPT-4-Turbo 变体。
[原文]Codestral. https://mistral.ai/news/codestral/, 2024.Accessed: 2024-05-29. Netmind.AI. Odyssey-math. https://github.com/protagolabs/odyssey-math/tree
/main, 2024. Accessed: April 22, 2024. OpenAI. Gpt-4 technical report, 2023. B. Peng, J. Quesnelle, H. Fan, and E. Shippole. Yarn: Efficient context window extension of large
language models. arXiv preprint arXiv:2309.00071, 2023. M. Reid, N. Savinov, D. Teplyashin, D. Lepikhin, T. Lillicrap, J.-b. Alayrac, R. Soricut, A. Lazari-
dou, O. Firat, J. Schrittwieser, et al. Gemini 1.5: Unlocking multimodal understanding across
millions of tokens of con...
4.2 代码补全
4.2.1 仓库级代码补全评估
我们使用 RepoBench (Liu et al., 2023b) 来评估当前可用的参数量低于 35B 的开源代码模型在仓库级代码补全任务中的能力。该数据集构建自一系列多样化的真实世界、开源且采用宽松许可证的仓库,涵盖两种流行的编程语言:Python 和 Java。值得注意的是,RepoBench 的最新版本(v1.1)的数据来源于 2023 年 10 月 6 日至 12 月 31 日期间创建的 GitHub 仓库,而我们的预训练数据包含 2023 年 11 月之前创建的代码。为确保该数据集未出现在我们的预训练数据中并避免数据泄露,我们仅使用 2023 年 12 月的数据。我们的评估涵盖五个上下文长度级别——2k、4k、8k、12k 和 16k tokens——并在三种设置下进行:跨文件首位(cross-file-first)、跨文件随机(cross-file-random)和文件内(in-file)。我们对所有待评估模型均采用贪婪搜索。模型被限制为每个提示最多生成 64 个新 token,并选取输出的第一个非空且非注释行作为预测结果。通过截断多余的跨文件上下文,提示的最大 token 长度被设置为 15,800。我们报告了不同上下文长度级别的平均精确匹配率。 Model #TP #AP Python Java 2k 4k 8k 12k 16k Avg 2k 4k 8k 12k 16k Avg StarCoder2-Base 15B 15B 35.7% 36.7% 34.6% 27.4% 25.1% 32.1% 46.2% 45.0% 39.8% 30.5% 30.7% 38.7% CodeLlama-Base 7B 7B 32.0% 34.4% 35.3% 33.3% 32.2% 33.5% 43.1% 42.1% 40.4% 37.0% 40.3% 40.6% CodeLlama-Base 13B 13B 33.0% 36.5% 37.0% 34.6% 35.0% 35.2% 43.5% 44.8% 40.7% 38.6% 41.1% 41.8% CodeLlama-Base 34B 34B 35.3% 37.5% 39.5% 34.9% 35.6% 36.6% 45.9% 45.4% 42.5% 41.0% 41.2% 43.3% DS-Coder-Base 6.7B 6.7B 36.1% 37.5% 38.2% 34.0% 35.0% 36.2% 46.8% 46.4% 42.9% 38.8% 40.8% 43.3% DS-Coder-Base 33B 33B 39.7% 40.1% 40.0% 36.9% 38.5% 39.1% 47.9% 47.7% 43.3% 40.9% 43.6% 44.8% Codestral 22B 22B 42.1
2018. URL http://arxiv.org/abs/1803.05457.
% 44.3% 46.6% 46.6% 51.5% 46.1% 48.3% 47.8% 46.0% 42.2% 43.9% 45.7% DS-Coder-V2-Lite-Base 16B 2.4B 38.3% 38.6% 40.6% 38.3% 38.7% 38.9% 48.8% 45.7% 42.4% 38.1% 41.1% 43.3% 表5:不同模型在RepoBench v1.1十二月子集上的性能表现。如表5所示,结果表明,尽管DeepSeek-Coder-V2-Lite-Base模型仅拥有24亿个激活参数,但其在Python中的代码补全能力可与DeepSeek-Coder-Base 33B模型相媲美,在Java中的表现则与DeepSeek-Coder-Base 7B模型相当。与CodeStral相比,DeepSeek-Coder-V2-Lite-Base模型的激活参数仅为CodeStral的十分之一,导致其在代码补全任务上的性能较低。然而,我们认为DeepSeek-Coder-V2较少的激活参数使其在代码补全场景中速度更快。
[原文]Judging llm-as-a-judge with mt-bench and chatbot
arena, 2023.W. Zhong, R. Cui, Y. Guo, Y. Liang, S. Lu, Y. Wang, A. Saied, W. Chen, and N. Duan. AGIEval: A
human-centric benchmark for evaluating foundation models. CoRR, abs/2304.06364, 2023.
doi: 10.48550/arXiv.2304.06364. URL https://doi.org/10.48550/arXiv.2304.06364.
18
A.
4.2.2 中间填充代码补全
DeepSeek-Coder-V2-Lite采用独特的训练策略,在其预训练阶段引入了0.5的中间填充(Fill-In-the-Middle, FIM)比例。该方法使模型能够利用上下文(包含前序与后序代码片段)熟练地通过填空方式完成代码补全。这一能力对于代码补全工具尤为有利。多个开源模型,如SantaCoder (Allal et al., 2023 ) 、StarCoder (Li et al., 2023b ) 和 CodeLlama (Roziere et al., 2023 ) ,也利用了类似的能力,并在代码生成与补全领域树立了高标准。为评估DeepSeek-Coder-V2模型的性能,我们与领先模型进行了对比分析。评估基于单行填充(Single-Line Infilling)基准测试,涵盖Allal等人 ( 2023 ) 所述的三种不同编程语言。本次评估的主要指标为行精确匹配准确率 5 5 5 我们使用首行生成结果而非整个生成代码块,因此结果与DeepS略有不同。
2018. URL http://arxiv.org/abs/1803.05457.
DeepSeek-Coder。
[原文]Supported Programming Languages
ABAP, ActionScript, Ada, Agda, AGS Script, Alloy, AmbientTalk, AMD GPU, AMPL, ANSYS
Parametric Design Language, ANTLR, Apache Configuration, APL, AppleScript, Arc, Arduino,
ASP, AspectJ, Assembly, Asymptote, Augeas, AutoHotkey, AutoIt, AWK, BC, Berry, BitBake,
BlitzBasic, BlitzMax, Bluespec, BNF, Boo, Boogie, Brainfuck, BrightScript, Bro, BST, C, C#,
C2HS Haskell, CADL, CapDL, Ceylon, Chapel, ChucK, Cirru, Click, Clojure, CMake, COBOL,
COBOLFree, CoffeeScript, ColdFusion CFC, Common Lisp, C++, Crystal, Csound, Csound Score,
CSS, CUDA, Cypher, Cython, Darcs Patch...
表6:不同方法在 FIM 任务上的性能表现。
| 模型 | #TP | #AP | python | java | javascript | Mean |
|---|---|---|---|---|---|---|
| StarCoder | 6 | 6 | 71.5% | 82.3% | 83.0% | 80.2% |
| CodeLlama-Base | 7B | 7B | 58.6% | 70.6% | 70.7% | 68.0% |
| CodeLlama-Base | 13B | 13B | 60.7% | 74.3% | 78.5% | 73.1% |
| DS-Coder-Base | 1B | 1B | 74.1% | 85.1% | 82.9% | 81.8% |
| DS-Coder-Base | 7B | 7B | 79.8% | 89.6% | 86.3% | 86.1% |
| DS-Coder-Base | 33B | 33B | 80.5% | 88.4% | 86.6% | 86.4% |
| Codestral | 22B | 22B | 77.2% | 83.2% | 85.9% | 83.0% |
| DS-Coder-V2-Lite-Base | 16B | 2.4B | 80.0% | 89.1% | 87.2% | 86.4% |
(注:StartCoder-2 在 FIM 任务上存在一些问题,因此我们仍使用 StartCoder。)
该表展示了多种代码模型在三种编程语言(Python、Java 和 JavaScript)的 FIM(中间填充)任务上的性能,其中 Mean(平均分)指标反映了整体有效性。在对比的模型中,DeepSeek-Coder-V2-Lite-Base 采用 2.4B 激活参数的配置,取得了卓越的结果。其在 Python 上得分为 80.0%,Java 上为 89.1%,JavaScript 上为 87.2%,最终 Mean 得分高达 86.4%,位居榜首。这证明了 DeepSeek-Coder-V2-Lite-Base 的优越有效性,特别是在处理不同编程语言的 FIM 任务时,其性能与评估中的其他更大规模模型相当。
4.3 代码修复
为了评估模型的缺陷修复能力,我们使用了 Defects4J 7 7 7 https://github.com/rjust/defects4j、SWE-bench (Jimenez et al., 2023) 以及 Aider 8 8 8 https://github.com/paul-gauthier/aider 数据集进行测试。Defects4J 是软件工程领域广泛使用的数据集,专门用于评估和测试程序修复技术。该数据集包含来自多个开源项目(包括但不限于 Apache Commons、JFreeChart 和 Closure Compiler)的真实软件缺陷集合。数据集中的每个缺陷都附带测试套件,可用于验证程序修复工具的有效性。由于 Defec4J 中的原始缺陷可能需要修改