LLMs之MoE之DeepSeek-V3:DeepSeek-V3的简介、安装和使用方法、案例应用之详细攻略
DeepSeek-V3的简介

DeepSeek-V3 是一个拥有 671B 个总参数,每个 token 激活 37B 参数的强大混合专家 (MoE) 语言模型。为了实现高效的推理和经济高效的训练,DeepSeek-V3 采用了在 DeepSeek-V2 中经过充分验证的多头潜在注意力 (MLA) 和 DeepSeekMoE 架构。 它在 14.8 万亿个多样化且高质量的 tokens 上进行预训练,随后进行监督微调和强化学习,以充分发挥其能力。 DeepSeek-V3 的训练过程非常稳定,没有出现任何不可恢复的损失峰值或回滚。其全部训练仅需 2.788M H800 GPU 小时。
总而言之,DeepSeek-V3 是一个高性能、高效训练且易于部署的开源大型语言模型,其在多个领域展现出强大的能力,并支持多种硬件平台和推理框架。
GitHub地址:GitHub - deepseek-ai/DeepSeek-V3
1、DeepSeek-V3 特点
>> 高效的 MoE 架构:使用多头潜在注意力 (MLA) 和 DeepSeekMoE 架构,实现高效推理和经济高效的训练。
>> 创新的负载均衡策略:采用无辅助损失的负载均衡策略,最大限度地减少了由于鼓励负载均衡而导致的性能下降。
>> 多标记预测 (MTP) 目标:采用多标记预测目标,提高模型性能,并可用于推测解码以加速推理。
>> FP8 混合精度训练:首次验证了 FP8 训练在大规模模型上的可行性和有效性,显著提高训练效率并降低训练成本。
>> 推理优化:支持 FP8 和 BF16 推理,并与多个开源推理框架集成,例如 DeepSeek-Infer Demo、SGLang、LMDeploy 和 TensorRT-LLM 等,支持在 NVIDIA 和 AMD GPU 以及华为 Ascend NPU 上运行。
>> 知识蒸馏:从 DeepSeek-R1 系列模型中蒸馏推理能力,提升 DeepSeek-V3 的推理性能,同时控制输出风格和长度。
>> 优秀的性能:在各种基准测试中超越其他开源模型,并与领先的闭源模型性能相当。
2、模型性能
综合评估表明,DeepSeek-V3 优于其他开源模型,并实现了与领先的闭源模型相当的性能。尽管性能出色,但 DeepSeek-V3 仅需要 2.788M H800 GPU 小时即可完成完整训练。此外,它的训练过程非常稳定。在整个训练过程中,我们没有遇到任何无法恢复的损失峰值或执行任何回滚。

Base Model
Standard Benchmarks
| Benchmark (Metric) | # Shots | DeepSeek-V2 | Qwen2.5 72B | LLaMA3.1 405B | DeepSeek-V3 |
---|
| Architecture | - | MoE | Dense | Dense | MoE |
| # Activated Params | - | 21B | 72B | 405B | 37B |
| # Total Params | - | 236B | 72B | 405B | 671B |
English | Pile-test (BPB) | - | 0.606 | 0.638 | 0.542 | 0.548 |
| BBH (EM) | 3-shot | 78.8 | 79.8 | 82.9 | 87.5 |
| MMLU (Acc.) | 5-shot | 78.4 | 85.0 | 84.4 | 87.1 |
| MMLU-Redux (Acc.) | 5-shot | 75.6 | 83.2 | 81.3 | 86.2 |
| MMLU-Pro (Acc.) | 5-shot | 51.4 | 58.3 | 52.8 | 64.4 |
| DROP (F1) | 3-shot | 80.4 | 80.6 | 86.0 | 89.0 |
| ARC-Easy (Acc.) | 25-shot | 97.6 | 98.4 | 98.4 | 98.9 |
| ARC-Challenge (Acc.) | 25-shot | 92.2 | 94.5 | 95.3 | 95.3 |
| HellaSwag (Acc.) | 10-shot | 87.1 | 84.8 | 89.2 | 88.9 |
| PIQA (Acc.) | 0-shot | 83.9 | 82.6 | 85.9 | 84.7 |
| WinoGrande (Acc.) | 5-shot | 86.3 | 82.3 | 85.2 | 84.9 |
| RACE-Middle (Acc.) | 5-shot | 73.1 | 68.1 | 74.2 | 67.1 |
| RACE-High (Acc.) | 5-shot | 52.6 | 50.3 | 56.8 | 51.3 |
| TriviaQA (EM) | 5-shot | 80.0 | 71.9 | 82.7 | 82.9 |
| NaturalQuestions (EM) | 5-shot | 38.6 | 33.2 | 41.5 | 40.0 |
| AGIEval (Acc.) | 0-shot | 57.5 | 75.8 | 60.6 | 79.6 |
Code | HumanEval (Pass@1) | 0-shot | 43.3 | 53.0 | 54.9 | 65.2 |
| MBPP (Pass@1) | 3-shot | 65.0 | 72.6 | 68.4 | 75.4 |
| LiveCodeBench-Base (Pass@1) | 3-shot | 11.6 | 12.9 | 15.5 | 19.4 |
| CRUXEval-I (Acc.) | 2-shot | 52.5 | 59.1 | 58.5 | 67.3 |
| CRUXEval-O (Acc.) | 2-shot | 49.8 | 59.9 | 59.9 | 69.8 |
Math | GSM8K (EM) | 8-shot | 81.6 | 88.3 | 83.5 | 89.3 |
| MATH (EM) | 4-shot | 43.4 | 54.4 | 49.0 | 61.6 |
| MGSM (EM) | 8-shot | 63.6 | 76.2 | 69.9 | 79.8 |
| CMath (EM) | 3-shot | 78.7 | 84.5 | 77.3 | 90.7 |
Chinese | CLUEWSC (EM) | 5-shot | 82.0 | 82.5 | 83.0 | 82.7 |
| C-Eval (Acc.) | 5-shot | 81.4 | 89.2 | 72.5 | 90.1 |
| CMMLU (Acc.) | 5-shot | 84.0 | 89.5 | 73.7 | 88.8 |
| CMRC (EM) | 1-shot | 77.4 | 75.8 | 76.0 | 76.3 |
| C3 (Acc.) | 0-shot | 77.4 | 76.7 | 79.7 | 78.6 |
| CCPM (Acc.) | 0-shot | 93.0 | 88.5 | 78.6 | 92.0 |
Multilingual | MMMLU-non-English (Acc.) | 5-shot | 64.0 | 74.8 | 73.8 | 79.4 |
注意:最佳结果以粗体显示。分差不超过 0.3 的分数被视为处于同一水平。DeepSeek-V3 在大多数基准测试中表现最佳,尤其是在数学和代码任务方面。更多评估详情,请查阅我们的论文。
Context Window上下文窗口

在“大海捞针”(NIAH)测试中的评估结果。DeepSeek-V3 在所有上下文窗口长度(最长为 128K)上的表现都很出色。
Chat Model
标准基准(大于 670 亿参数的模型)
| Benchmark (Metric) | DeepSeek V2-0506 | DeepSeek V2.5-0905 | Qwen2.5 72B-Inst. | Llama3.1 405B-Inst. | Claude-3.5-Sonnet-1022 | GPT-4o 0513 | DeepSeek V3 |
---|
| Architecture | MoE | MoE | Dense | Dense | - | - | MoE |
| # Activated Params | 21B | 21B | 72B | 405B | - | - | 37B |
| # Total Params | 236B | 236B | 72B | 405B | - | - | 671B |
English | MMLU (EM) | 78.2 | 80.6 | 85.3 | 88.6 | 88.3 | 87.2 | 88.5 |
| MMLU-Redux (EM) | 77.9 | 80.3 | 85.6 | 86.2 | 88.9 | 88.0 | 89.1 |
| MMLU-Pro (EM) | 58.5 | 66.2 | 71.6 | 73.3 | 78.0 | 72.6 | 75.9 |
| DROP (3-shot F1) | 83.0 | 87.8 | 76.7 | 88.7 | 88.3 | 83.7 | 91.6 |
| IF-Eval (Prompt Strict) | 57.7 | 80.6 | 84.1 | 86.0 | 86.5 | 84.3 | 86.1 |
| GPQA-Diamond (Pass@1) | 35.3 | 41.3 | 49.0 | 51.1 | 65.0 | 49.9 | 59.1 |
| SimpleQA (Correct) | 9.0 | 10.2 | 9.1 | 17.1 | 28.4 | 38.2 | 24.9 |
| FRAMES (Acc.) | 66.9 | 65.4 | 69.8 | 70.0 | 72.5 | 80.5 | 73.3 |
| LongBench v2 (Acc.) | 31.6 | 35.4 | 39.4 | 36.1 | 41.0 | 48.1 | 48.7 |
Code | HumanEval-Mul (Pass@1) | 69.3 | 77.4 | 77.3 | 77.2 | 81.7 | 80.5 | 82.6 |
| LiveCodeBench (Pass@1-COT) | 18.8 | 29.2 | 31.1 | 28.4 | 36.3 | 33.4 | 40.5 |
| LiveCodeBench (Pass@1) | 20.3 | 28.4 | 28.7 | 30.1 | 32.8 | 34.2 | 37.6 |
| Codeforces (Percentile) | 17.5 | 35.6 | 24.8 | 25.3 | 20.3 | 23.6 | 51.6 |
| SWE Verified (Resolved) | - | 22.6 | 23.8 | 24.5 | 50.8 | 38.8 | 42.0 |
| Aider-Edit (Acc.) | 60.3 | 71.6 | 65.4 | 63.9 | 84.2 | 72.9 | 79.7 |
| Aider-Polyglot (Acc.) | - | 18.2 | 7.6 | 5.8 | 45.3 | 16.0 | 49.6 |
Math | AIME 2024 (Pass@1) | 4.6 | 16.7 | 23.3 | 23.3 | 16.0 | 9.3 | 39.2 |
| MATH-500 (EM) | 56.3 | 74.7 | 80.0 | 73.8 | 78.3 | 74.6 | 90.2 |
| CNMO 2024 (Pass@1) | 2.8 | 10.8 | 15.9 | 6.8 | 13.1 | 10.8 | 43.2 |
Chinese | CLUEWSC (EM) | 89.9 | 90.4 | 91.4 | 84.7 | 85.4 | 87.9 | 90.9 |
| C-Eval (EM) | 78.6 | 79.5 | 86.1 | 61.5 | 76.7 | 76.0 | 86.5 |
| C-SimpleQA (Correct) | 48.5 | 54.1 | 48.4 | 50.4 | 51.3 | 59.3 | 64.8 |
注意:所有模型均在将输出长度限制为 8K 的配置下进行评估。对于包含少于 1000 个样本的基准测试,会使用不同的温度设置多次进行测试,以得出可靠的最终结果。DeepSeek-V3 是表现最佳的开源模型,并且在与前沿的闭源模型的对比中也展现出具有竞争力的性能。
Open Ended Generation Evaluation
Model | Arena-Hard | AlpacaEval 2.0 |
---|
DeepSeek-V2.5-0905 | 76.2 | 50.5 |
Qwen2.5-72B-Instruct | 81.2 | 49.1 |
LLaMA-3.1 405B | 69.3 | 40.5 |
GPT-4o-0513 | 80.4 | 51.1 |
Claude-Sonnet-3.5-1022 | 85.2 | 52.0 |
DeepSeek-V3 | 85.5 | 70.0 |
注意:英语开放式对话评估。对于 AlpacaEval 2.0,我们使用长度控制下的胜率作为指标。
DeepSeek-V3的安装和使用方法
DeepSeek-V3 提供了多种本地运行方式,但HuggingFace's Transformers 尚未直接支持。
1、安装
克隆仓库并安装依赖
git clone https://github.com/deepseek-ai/DeepSeek-V3.git
cd DeepSeek-V3/inference
pip install -r requirements.txt
下载模型权重
从 HuggingFace 下载模型权重,并将其放入 /path/to/DeepSeek-V3 文件夹。
Model | #Total Params | #Activated Params | Context Length | Download |
---|
DeepSeek-V3-Base | 671B | 37B | 128K | 🤗 HuggingFace |
DeepSeek-V3 | 671B | 37B | 128K | 🤗 HuggingFace |
模型权重转换 (DeepSeek-Infer Demo 示例)
python convert.py --hf-ckpt-path /path/to/DeepSeek-V3 --save-path /path/to/DeepSeek-V3-Demo --n-experts 256 --model-parallel 16
2、模型推理
DeepSeek-V3 可以使用以下硬件和开源社区软件在本地部署:
>> DeepSeek-Infer 演示:我们为 FP8 和 BF16 推理提供了一个简单、轻量级的演示。
>> SGLang:完全支持 BF16 和 FP8 推理模式下的 DeepSeek-V3 模型。
>> LMDeploy:支持本地和云部署的高效 FP8 和 BF16 推理。
>> TensorRT-LLM:目前支持 BF16 推理和 INT4/8 量化,即将支持 FP8。
>> AMD GPU:支持在 BF16 和 FP8 模式下通过 SGLang 在 AMD GPU 上运行 DeepSeek-V3 模型。
>> 华为Ascend NPU:支持在华为Ascend设备上运行DeepSeek-V3。
除了以下两种,项目还推荐使用 SGLang、LMDeploy 和 TensorRT-LLM 等框架进行推理,并提供了相应的链接和说明。 SGLang 特别支持 AMD GPU。 华为 Ascend NPU 的支持也通过 MindIE 框架实现。 如果需要 BF16 权重,可以使用提供的转换脚本进行转换。
运行推理 (DeepSeek-Infer Demo 示例,交互式):
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
运行推理 (DeepSeek-Infer Demo 示例,批量):
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
3、使用方法
T1、在DeepSeek的官方网站上与DeepSeek-V3聊天
地址:DeepSeek
T2、在 DeepSeek 平台上提供与 OpenAI 兼容的 API
地址:DeepSeek
DeepSeek-V3的案例应用
项目提供了 DeepSeek-V3 在各种基准测试上的评估结果,涵盖了自然语言理解、代码生成、数学推理等多个方面,包括英文和中文基准测试,以及多语言基准测试。 DeepSeek-V3 在大多数基准测试中都取得了最佳性能,尤其是在数学和代码任务上。