HuggingFace镜像/DeepSeek-V3-Base
模型介绍模型推理文件和版本分析
下载使用量0
DeepSeek-V3

Homepage Chat Hugging Face
Discord Wechat Twitter Follow
Code License Model License

论文链接👁️

1. 引言

本文介绍 DeepSeek-V3,这是一个拥有 6710 亿个参数的强大混合专家 (MoE) 语言模型,每个标记激活 370 亿个参数。为了实现高效的推理和经济高效的训练,DeepSeek-V3 采用了多头潜伏注意力 (MLA) 和 DeepSeekMoE 架构,这些架构已经在 DeepSeek-V2 中得到了充分验证。此外,DeepSeek-V3 开创性地采用了一种无辅助损失的负载均衡策略,并设定了一个多标记预测训练目标,以获得更强的性能。 我们在 14.8 万亿个多样且高质量的标记上对 DeepSeek-V3 进行了预训练,随后进行了监督式微调和强化学习阶段,以充分发挥其能力。综合评估表明,DeepSeek-V3 的性能优于其他开源模型,并且达到了与领先的闭源模型相当的水平。 尽管性能出色,但 DeepSeek-V3 的完整训练只需要 278.8 万个 H800 GPU 小时。此外,其训练过程非常稳定。在整个训练过程中,我们没有遇到任何不可恢复的损失峰值或执行任何回滚操作。

2. 模型概览


架构:创新的负载均衡策略和训练目标

  • 在 DeepSeek-V2 高效架构的基础上,我们开创性地采用了一种无辅助损失的负载均衡策略,将由于鼓励负载均衡而产生的性能下降降到最低。
  • 我们研究了多标记预测 (MTP) 目标,并证明它有利于模型性能。它也可以用于推理加速的推测式解码。

预训练:走向极致的训练效率

  • 我们设计了一个 FP8 混合精度训练框架,并首次验证了 FP8 训练在超大规模模型上的可行性和有效性。
  • 通过算法、框架和硬件的协同设计,我们克服了跨节点 MoE 训练中的通信瓶颈,几乎实现了计算和通信的完全重叠。这显着提高了我们的训练效率,并降低了训练成本,使我们能够在没有额外开销的情况下扩展模型规模。
  • 仅需 266.4 万个 H800 GPU 小时,我们就完成了 DeepSeek-V3 在 14.8 万亿个标记上的预训练,使其成为目前最强劲的开源基础模型。预训练之后的后续训练阶段只需要 0.1 万个 GPU 小时。

后训练:从 DeepSeek-R1 中蒸馏知识

  • 我们引入了一种创新的方法,将长链思想 (CoT) 模型(特别是 DeepSeek R1 系列模型之一)中的推理能力蒸馏到标准 LLM(特别是 DeepSeek-V3)中。我们的管道优雅地将 R1 的验证和反思模式融入 DeepSeek-V3,并显著提高了其推理性能。同时,我们也控制了 DeepSeek-V3 的输出样式和长度。

3. 模型下载

模型总参数数激活参数数上下文长度下载
DeepSeek-V3-Base6710亿370亿12.8万🤗 HuggingFace
DeepSeek-V36710亿370亿12.8万🤗 HuggingFace

注意:DeepSeek-V3 模型在 HuggingFace 上的总大小为 6850 亿,其中包括 6710 亿的主模型权重和 140 亿的多标记预测 (MTP) 模块权重。

为了确保最佳性能和灵活性,我们与开源社区和硬件供应商合作,提供了多种方式可以在本地运行该模型。有关分步指南,请查看第 6 节:如何在本地运行。

对于希望深入研究的开发人员,我们建议查看 README_WEIGHTS.md,了解主模型权重和多标记预测 (MTP) 模块的详细信息。请注意,MTP 支持目前正在社区中积极开发,我们欢迎您的贡献和反馈。

4. Evaluation Results

Base Model

Standard Benchmarks

Benchmark (Metric)# ShotsDeepSeek-V2Qwen2.5 72BLLaMA3.1 405BDeepSeek-V3
Architecture-MoEDenseDenseMoE
# Activated Params-21B72B405B37B
# Total Params-236B72B405B671B
EnglishPile-test (BPB)-0.6060.6380.5420.548
BBH (EM)3-shot78.879.882.987.5
MMLU (Acc.)5-shot78.485.084.487.1
MMLU-Redux (Acc.)5-shot75.683.281.386.2
MMLU-Pro (Acc.)5-shot51.458.352.864.4
DROP (F1)3-shot80.480.686.089.0
ARC-Easy (Acc.)25-shot97.698.498.498.9
ARC-Challenge (Acc.)25-shot92.294.595.395.3
HellaSwag (Acc.)10-shot87.184.889.288.9
PIQA (Acc.)0-shot83.982.685.984.7
WinoGrande (Acc.)5-shot86.382.385.284.9
RACE-Middle (Acc.)5-shot73.168.174.267.1
RACE-High (Acc.)5-shot52.650.356.851.3
TriviaQA (EM)5-shot80.071.982.782.9
NaturalQuestions (EM)5-shot38.633.241.540.0
AGIEval (Acc.)0-shot57.575.860.679.6
CodeHumanEval (Pass@1)0-shot43.353.054.965.2
MBPP (Pass@1)3-shot65.072.668.475.4
LiveCodeBench-Base (Pass@1)3-shot11.612.915.519.4
CRUXEval-I (Acc.)2-shot52.559.158.567.3
CRUXEval-O (Acc.)2-shot49.859.959.969.8
MathGSM8K (EM)8-shot81.688.383.589.3
MATH (EM)4-shot43.454.449.061.6
MGSM (EM)8-shot63.676.269.979.8
CMath (EM)3-shot78.784.577.390.7
ChineseCLUEWSC (EM)5-shot82.082.583.082.7
C-Eval (Acc.)5-shot81.489.272.590.1
CMMLU (Acc.)5-shot84.089.573.788.8
CMRC (EM)1-shot77.475.876.076.3
C3 (Acc.)0-shot77.476.779.778.6
CCPM (Acc.)0-shot93.088.578.692.0
MultilingualMMMLU-non-English (Acc.)5-shot64.074.873.879.4

Note: Best results are shown in bold. Scores with a gap not exceeding 0.3 are considered to be at the same level. DeepSeek-V3 achieves the best performance on most benchmarks, especially on math and code tasks.

For more evaluation details, please check our paper.

Context Window

Evaluation results on the Needle In A Haystack (NIAH) tests. DeepSeek-V3 performs well across all context window lengths up to 128K.

Chat Model

Standard Benchmarks (Models larger than 67B)

Benchmark (Metric)DeepSeek V2-0506DeepSeek V2.5-0905Qwen2.5 72B-Inst.Llama3.1 405B-Inst.Claude-3.5-Sonnet-1022GPT-4o 0513DeepSeek V3
ArchitectureMoEMoEDenseDense--MoE
# Activated Params21B21B72B405B--37B
# Total Params236B236B72B405B--671B
EnglishMMLU (EM)78.280.685.388.688.387.288.5
MMLU-Redux (EM)77.980.385.686.288.988.089.1
MMLU-Pro (EM)58.566.271.673.378.072.675.9
DROP (3-shot F1)83.087.876.788.788.383.791.6
IF-Eval (Prompt Strict)57.780.684.186.086.584.386.1
GPQA-Diamond (Pass@1)35.341.349.051.165.049.959.1
SimpleQA (Correct)9.010.29.117.128.438.224.9
FRAMES (Acc.)66.965.469.870.072.580.573.3
LongBench v2 (Acc.)31.635.439.436.141.048.148.7
CodeHumanEval-Mul (Pass@1)69.377.477.377.281.780.582.6
LiveCodeBench (Pass@1-COT)18.829.231.128.436.333.440.5
LiveCodeBench (Pass@1)20.328.428.730.132.834.237.6
Codeforces (Percentile)17.535.624.825.320.323.651.6
SWE Verified (Resolved)-22.623.824.550.838.842.0
Aider-Edit (Acc.)60.371.665.463.984.272.979.7
Aider-Polyglot (Acc.)-18.27.65.845.316.049.6
MathAIME 2024 (Pass@1)4.616.723.323.316.09.339.2
MATH-500 (EM)56.374.780.073.878.374.690.2
CNMO 2024 (Pass@1)2.810.815.96.813.110.843.2
ChineseCLUEWSC (EM)89.990.491.484.785.487.990.9
C-Eval (EM)78.679.586.161.576.776.086.5
C-SimpleQA (Correct)48.554.148.450.451.359.364.8

Note: All models are evaluated in a configuration that limits the output length to 8K. Benchmarks containing fewer than 1000 samples are tested multiple times using varying temperature settings to derive robust final results. DeepSeek-V3 stands as the best-performing open-source model, and also exhibits competitive performance against frontier closed-source models.

Open Ended Generation Evaluation

ModelArena-HardAlpacaEval 2.0
DeepSeek-V2.5-090576.250.5
Qwen2.5-72B-Instruct81.249.1
LLaMA-3.1 405B69.340.5
GPT-4o-051380.451.1
Claude-Sonnet-3.5-102285.252.0
DeepSeek-V385.570.0

Note: English open-ended conversation evaluations. For AlpacaEval 2.0, we use the length-controlled win rate as the metric.

5. Chat Website & API Platform

You can chat with DeepSeek-V3 on DeepSeek's official website: chat.deepseek.com

We also provide OpenAI-Compatible API at DeepSeek Platform: platform.deepseek.com

6. How to Run Locally

DeepSeek-V3 can be deployed locally using the following hardware and open-source community software:

  1. DeepSeek-Infer Demo: We provide a simple and lightweight demo for FP8 and BF16 inference.
  2. SGLang: Fully support the DeepSeek-V3 model in both BF16 and FP8 inference modes.
  3. LMDeploy: Enables efficient FP8 and BF16 inference for local and cloud deployment.
  4. TensorRT-LLM: Currently supports BF16 inference and INT4/8 quantization, with FP8 support coming soon.
  5. vLLM: Support DeekSeek-V3 model with FP8 and BF16 modes for tensor parallelism and pipeline parallelism.
  6. AMD GPU: Enables running the DeepSeek-V3 model on AMD GPUs via SGLang in both BF16 and FP8 modes.
  7. Huawei Ascend NPU: Supports running DeepSeek-V3 on Huawei Ascend devices.

Since FP8 training is natively adopted in our framework, we only provide FP8 weights. If you require BF16 weights for experimentation, you can use the provided conversion script to perform the transformation.

Here is an example of converting FP8 weights to BF16:

cd inference
python fp8_cast_bf16.py --input-fp8-hf-path /path/to/fp8_weights --output-bf16-hf-path /path/to/bf16_weights

注意:目前还不直接支持 Huggingface 的 Transformers。

6.1 使用 DeepSeek-Infer 演示进行推理(仅供示例)

模型权重和演示代码准备

首先,克隆我们的 DeepSeek-V3 GitHub 存储库:

git clone https://github.com/deepseek-ai/DeepSeek-V3.git

进入 inference 文件夹,并安装 requirements.txt 中列出的依赖项。

cd DeepSeek-V3/inference
pip install -r requirements.txt

从 HuggingFace 下载模型权重,并将它们放入 /path/to/DeepSeek-V3 文件夹中。

模型权重转换

将 HuggingFace 模型权重转换为特定格式:

python convert.py --hf-ckpt-path /path/to/DeepSeek-V3 --save-path /path/to/DeepSeek-V3-Demo --n-experts 256 --model-parallel 16

运行

然后,您就可以与 DeepSeek-V3 聊天了:

torchrun --nnodes 2 --nproc-per-node 8 generate.py --node-rank $RANK --master-addr $ADDR --ckpt-path /path/to/DeepSeek-V3-Demo --config configs/config_671B.json --interactive --temperature 0.7 --max-new-tokens 200

或者对给定文件进行批量推断:

torchrun --nnodes 2 --nproc-per-node 8 generate.py --node-rank $RANK --master-addr $ADDR --ckpt-path /path/to/DeepSeek-V3-Demo --config configs/config_671B.json --input-file $FILE

6.2 使用 SGLang 进行推理(推荐)

SGLang 目前支持 MLA 优化、FP8 (W8A8)、FP8 KV 缓存和 Torch Compile,在开源框架中提供最先进的延迟和吞吐量性能。

值得注意的是,SGLang v0.4.1 完全支持在 NVIDIA 和 AMD GPU 上运行 DeepSeek-V3,使其成为一个高度通用且强大的解决方案。

以下是 SGLang 团队的启动说明:https://github.com/sgl-project/sglang/tree/main/benchmark/deepseek_v3

6.3 使用 LMDeploy 进行推理(推荐)

LMDeploy 是一款灵活且高性能的推理和服务框架,专为大型语言模型定制,现在支持 DeepSeek-V3。它提供离线管道处理和在线部署功能,无缝集成 PyTorch 基于的工作流。

有关使用 LMDeploy 运行 DeepSeek-V3 的全面分步骤说明,请参考此处:https://github.com/InternLM/lmdeploy/issues/2960

6.4 使用 TRT-LLM 进行推理(推荐)

TensorRT-LLM 现在支持 DeepSeek-V3 模型,提供 BF16 和 INT4/INT8 权重Only 等精度选项。FP8 的支持目前正在进行中,并将很快发布。您可以通过以下链接访问 TRTLLM 的自定义分支,该分支专为 DeepSeek-V3 支持而设计,以便直接体验新功能:https://github.com/NVIDIA/TensorRT-LLM/tree/deepseek/examples/deepseek_v3。

6.5 使用 vLLM 进行推理(推荐)

vLLM v0.6.6 支持在 NVIDIA 和 AMD GPU 上使用 FP8 和 BF16 模式进行 DeepSeek-V3 推理。除了标准技术外,vLLM 还提供 管道并行 功能,使您可以将此模型运行在多个通过网络连接的计算机上。有关详细指南,请参考vLLM 指令。也欢迎您关注 增强计划。

6.6 推荐的 AMD GPU 推理功能

与 AMD 团队合作,我们实现了使用 SGLang 对 AMD GPU 的第一天支持,并完全兼容 FP8 和 BF16 精度。有关详细指南,请参考SGLang 指令。

6.7 推荐的华为昇腾 NPU 推理功能

华为昇腾社区的 MindIE 框架已成功适配了 DeepSeek-V3 的 BF16 版本。有关昇腾 NPU 的分步骤指南,请遵循此处说明。

7. 许可证

此代码仓库在 MIT 许可证 下获得许可。DeepSeek-V3 Base/Chat 模型的使用受 模型许可证 的约束。DeepSeek-V3 系列(包括 Base 和 Chat)支持商业用途。

8. 引文

@misc{deepseekai2024deepseekv3technicalreport,
      title={DeepSeek-V3 Technical Report}, 
      author={DeepSeek-AI},
      year={2024},
      eprint={2412.19437},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2412.19437}, 
}

9. 联系我们

如果您有任何疑问,请创建 issue 或发送电子邮件至 service@deepseek.com。