
如果你在2026年选择一个开放权重的代码模型,DeepSeek Coder V2实际上适合在哪里——现在V4已经发布,它是否仍然值得运行?本指南将介绍其架构、原始报告中的基准测试数字、许可以及今天获取模型的现实方法(本地或在Hugging Face——原始托管端点于2024年退役,不再映射到当前V4模型)。 deepseek-coder DeepSeek Coder V2是DeepSeek公司于2024年6月推出的开源混合专家(MoE)代码语言模型。它进一步从DeepSeek-V2的中间检查点进行预训练,并额外增加了600亿个token,这显著提高了编码和数学推理能力,同时保持了可比的一般语言性能。项目的目标很简单:生产一个开放权重的编码器,能够在代码特定任务上与GPT-4-Turbo相匹配,而不需要封闭源代码的价格标签。
什么是DeepSeek Coder V2?

本发布包含两个大小——一个16B的轻量级模型和一个完整的236B模型——以及Base和Instruct变体。它将编程语言支持从86种扩展到338种,并将上下文长度从16K扩展到128K。如果您想更全面地了解该模型在系列中的位置,请参阅。
(此处省略了部分内容,因为原文中未提供完整信息) DeepSeek models hub 是索引。
Architecture and lineage
DeepSeek Coder V2基于DeepSeekMoE框架构建。DeepSeek基于DeepSeekMoE框架发布了V2版本,包含16B和236B参数,其中活动参数分别为2.4B和21B,包括基础模型和指令模型。这种稀疏性是整个架构的核心——完整的236B模型每处理一个标记只激活21B参数,因此推理成本与活动参数而非总参数量成正比。
它是 原始DeepSeek V2的延续 基础,而不是从头开始的模型。早期的 DeepSeek Coder系列 (1.3B–33B密集型)在2T个标记上,使用16K窗口进行训练;Coder V2继承了MoE,并增加了针对6T标记代码的更大规模预训练。
| Spec | DeepSeek Coder V2-Lite | DeepSeek Coder V2 (全功能版) |
|---|---|---|
| Total parameters | 16B | 236B |
| 激活参数 | 2.4B | 21B |
| Architecture | MoE | MoE |
| Context length | 128K | 128K |
| 支持的语言 | 338 | 338 |
| Release | 2024-06-17 | 2024-06-17 |
| 变体 | 基础版,指令版 | 基础版,指令版 |
深Seek Coder V2 一段式训练配方
DeepSeek Coder V2进一步从DeepSeek-V2的中间检查点进行预训练,额外使用6万亿个标记,显著提升了DeepSeek-V2的编码和数学推理能力,同时在一般语言任务中保持了可比的性能。该混合训练以代码权重为主,覆盖多语言,并具有填补中间目标——如果你计划将其用作编辑器后端,这两者都很有相关性。
基准测试(来自 V2 报告)

下面的所有数字均来自DeepSeek的技术报告和GitHub README,比较了236B Instruct与2024年中期的闭源生成模型(GPT-4-Turbo、GPT-4o-0513、Claude-3-Opus、Gemini-1.5-Pro)。将这些引用为2024年的数据——当前前沿模型已经发展到了新的阶段。
| Benchmark | Coder V2-Instruct (236B) | Coder V2-Lite-Instruct (16B) | 2024年中最佳闭源版本 |
|---|---|---|---|
| HumanEval | 90.2 | 81.1 | GPT-4o-0513: 91.0 |
| MBPP+ | 76.2 | 68.8 | GPT-4o-0513: 73.5 |
| LiveCodeBench (2023年12月23日-2024年6月24日) | 43.4 | 24.3 | GPT-4o-0513: 43.4 |
| USACO | 12.1 | 6.5 | GPT-4o-0513: 18.8 |
| SWE-Bench | 12.7 | — | GPT-4-Turbo-0409: 18.7 |
DeepSeek的报告指出,在HumanEval上获得90.2%的分数,在MBPP(使用EvalPlus管道的领先结果)上获得76.2%的分数,在LiveCodeBench(2023年12月至2024年6月的问题)上获得43.4%的分数。Coder V2是第一个在SWE-Bench上超过10%的开源模型。详见 官方DeepSeek-Coder-V2技术报告 以查看完整表格。
优势——Coder V2 特别胜出的地方
- 开放重量级商业用途。 基础模型和指令模型的使用受DeepSeek模型许可协议约束,Coder V2系列支持商业使用。
- 两个适当级别的层次。 16B Lite(2.4B有效)适合自托管;完整的236B适用于严肃的基础设施或批量作业。
- 338种语言覆盖范围 强大的多语言HumanEval结果,包括Java和PHP——如果你不在Python单文化环境中工作,这将很有用。
- 128K上下文 用于仓库级别的提示。这些模型支持128K个token的上下文长度,针孔搜索测试显示DeepSeek-Coder-V2在整个128K窗口内保持性能,这对于涉及大型代码库或文档的任务很重要。
- 原生FIM 用于编辑器集成——如果你将其集成到IDE中则相关。
Weaknesses — where it falls short
- SWE-Bench表现平庸。 Coder V2在SWE-Bench上的得分为12.7,落后于GPT-4-Turbo-0409(18.7)和Gemini-1.5-Pro(18.3);它仍然优于Claude-3-Opus(11.7)、Llama-3-70B(2.7)和Codestral。现实世界的仓库修复任务仍存在差距。
- 它已被用于聊天功能所取代。 DeepSeek-V2.5正式合并了DeepSeek-V2-0628和DeepSeek-Coder-V2-0724,保留了Coder模型的代码处理能力,同时增加了通用对话能力和人类偏好对齐。如果你需要一个用于聊天和代码的单个模型,那么V2.5——现在 DeepSeek V4-Flash ——取代它。
- 完整模型的硬件门槛较高。 在BF16格式下运行DeepSeek-Coder-V2进行推理需要80GB×8个GPU。Lite 16B是现实中的本地选项。
- No reasoning mode. 与 DeepSeek R1 或启用思考功能的V4,Coder V2没有逐步推理切换选项。
如何访问 DeepSeek Coder V2
本地 / Hugging Face
四个经典的Hugging Face仓库是 deepseek-ai/DeepSeek-Coder-V2-Base, DeepSeek-Coder-V2-Instruct, DeepSeek-Coder-V2-Lite-Base and DeepSeek-Coder-V2-Lite-Instruct. 最小Python加载模式(Transformers):
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
tok = AutoTokenizer.from_pretrained(
"deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct",
trust_remote_code=True,
)
model = AutoModelForCausalLM.from_pretrained(
"deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct",
trust_remote_code=True,
torch_dtype=torch.bfloat16,
).cuda()
对于量化本地推理,Lite-Instruct GGUF构建在LM Studio或llama.cpp中运行顺畅。如果您不愿意直接调整权重,可以使用 Ollama设置指南 覆盖了更快的路径。
主机 API(当前无 Coder V2 端点)
The original deepseek-coder API端点在2024年9月被弃用,当时DeepSeek V2 Chat和DeepSeek Coder V2合并并升级为DeepSeek V2.5。当前的API模型ID是 deepseek-v4-pro and deepseek-v4-flash; DeepSeek仍然映射的唯一旧版ID是 deepseek-chat and deepseek-reasoner,将于2026年7月24日15:59 UTC退役。
今天,只有 deepseek-chat and deepseek-reasoner 被记录为仍然可路由的;根据DeepSeek的官方通知,它们将于退役 2026-07-24 at 15:59 UTC. deepseek-coder 不在那份退休通知中,并且不再是文档化的当前模型ID。新代码应针对 deepseek-v4-pro or deepseek-v4-flash 直接。聊天请求触达 POST /chat/completions, the OpenAI-compatible endpoint at https://api.deepseek.com;同时也在相同的基URL上暴露了Anthropic兼容的表面。API是无状态的——您的客户端必须在每次调用时重新发送完整的信息历史。chat.deepseek.com上的网页聊天会保留会话历史;API不会。
from openai import OpenAI
client = OpenAI(
base_url="https://api.deepseek.com",
api_key="YOUR_KEY",
)
resp = client.chat.completions.create(
model="deepseek-v4-flash", # current Coder V2 work targets V4-Flash directly; deepseek-coder is no longer a current API ID
messages=[{"role": "user", "content": "Refactor this Python function..."}],
temperature=0.0, # 0.0 for code generation per DeepSeek guidance
max_tokens=2048,
)
print(resp.choices[0].message.content)
对于完整参数参考,请参阅 DeepSeek API documentation. Useful parameters worth knowing: temperature, top_p, max_tokens, response_format (JSON模式),工具调用,流式传输,FIM完成(Beta — 需要) thinking: {"type": "disabled"}),以及聊天前缀完成(Beta)。JSON模式旨在返回有效的JSON,但不保证——在提示中包含单词“json”以及一个小示例模式,并设置 max_tokens high enough to avoid truncation.
Pricing snapshot (as of April 2026)
Coder V2 现在没有单独的价格列表 — 调用落在 V4-Flash 上。每1M个令牌的头条费率:
| Tier | Input (cache hit) | Input (cache miss) | Output |
|---|---|---|---|
| deepseek-v4-flash | $0.0028 | $0.14 | $0.28 |
| deepseek-v4-pro (75% promo through 2026-05-31) | $0.003625 (list $0.0145) | $0.435 (list $1.74) | $0.87 (list $3.48) |
V4-Flash上的工作示例:使用2,000个token的缓存系统提示、200个token的用户消息和300个token的回复,进行了1,000,000次调用。
- Cached input: 2,000,000,000 tokens × $0.0028/M = $5.60
- Uncached input: 200,000,000 tokens × $0.14/M = $28.00
- Output: 300,000,000 tokens × $0.28/M = $84.00
- Total: $117.60
峰时折扣已于2025-09-05结束,尚未恢复。在做出任何承诺之前,请始终重新检查官方定价页面——另请参阅 DeepSeek API pricing breakdown.
Best use cases
- IDE自动补全和FIM补全——与VS Code搭配使用 DeepSeek与VS Code的配置.
- 超过128K-token存储库上下文的批量代码重构
- 在338种语言表面上进行多语言代码生成——详见 DeepSeek for coding 端到端工作流程。
- 在本地或断网部署中,权重至关重要——Lite 16B是现实目标。
- 个体贡献者的工作流程在 DeepSeek for developers.
Comparable alternatives

如果您在权衡Coder V2与闭源编码器,自然比较是 DeepSeek Coder与GitHub Copilot 对于IDE工作流程,以及更广泛的聊天编码器评估,例如 DeepSeek与ChatGPT. 对于其他开放权重选项,DeepSeek的替代品汇总涵盖了Codestral、Qwen-Coder和StarCoder2。 专注于编码的DeepSeek替代品汇总 包括Codestral、Qwen-Coder和StarCoder2。
Verdict
当您需要具有强大HumanEval/MBPP+数值、128K上下文和宽松的商业用途许可的开放权重时,DeepSeek Coder V2仍然是正确答案——尤其是适用于自托管的Lite 16B。对于新的托管API工作,请指向 deepseek-v4-flash它按token计费更便宜,并且默认提供思维模式;原始托管端点于2024年退役,不再是当前模型ID。 deepseek-coder 在发送请求之前的一个快速检查方法。
DeepSeek AI Guide is an independent resource and is not affiliated with DeepSeek or its parent company. Model IDs, pricing and API behaviour change; check the official DeepSeek documentation and pricing page before committing to a production decision.
DeepSeek Coder V2 是否可以免费商用?
是的,但关于许可证文件有一些注意事项。代码仓库是MIT许可的,但使用DeepSeek-Coder-V2 Base/Instruct模型受单独的DeepSeek模型许可证约束——并且Coder V2系列(Base和Instruct)支持商业用途。在发货前,请在Hugging Face仓库上阅读模型许可证。有关该系列权限的更广泛总结,请参阅 is DeepSeek open source.
DeepSeek Coder V2 支持的上下文长度是多少?
128,000个token。该模型将编程语言支持从86种扩展到338种,并将上下文长度从16K扩展到128K。这对于大多数仓库级别的提示已经足够,尽管它只是V4中1M上下文窗口的四分之一。如果您需要估计特定的代码库是否适合,请使用 DeepSeek token counter 本地安装DeepSeek指南
DeepSeek Coder V2 在 HumanEval 上与 GPT-4-Turbo 的比较如何?
在关键数字上非常接近。DeepSeek的报告记录了HumanEval上的90.2%得分,MBPP上的76.2%得分,以及LiveCodeBench上的43.4%得分(2023年12月至2024年6月的问题)。在同一表中,GPT-4-Turbo-1106在HumanEval上的得分为87.8。有关编码任务更详细的详细信息,请参阅 DeepSeek Coder review.
我可以在本地运行 DeepSeek Coder V2 吗?
16B Lite模型在量化消费级硬件上运行;236B模型需要高性能GPU。以BF16格式进行推理需要80GB×8个GPU。大多数开发者希望使用llama.cpp或Ollama运行Lite-Instruct GGUF构建。 从头到尾介绍了步骤。 walks through the steps end to end.
DeepSeek Coder V2 仍然是 DeepSeek 的最新编码模型吗?
No. DeepSeek-V2.5正式合并了DeepSeek-V2-0628和DeepSeek-Coder-V2-0724,保留了Coder模型的代码处理能力,同时增加了通用功能和人类偏好对齐。从那时起,DeepSeek发布了V3、V3.2,现在推出了V4——参见[2]了解当前一代。如果您特别想要一个开放权重、专注于代码的模型,并且允许商业使用,Coder V2仍然是一个不错的选择。 DeepSeek V4 overview [2] for the current generation.(此处为占位符,实际内容应与原文一致)
Sources & Methodology
Primary sources
- OfficialDeepSeek API documentationEndpoints, request/response shape, model IDsLast checked: April 30, 2026
- PricingDeepSeek API pricing pagePer-1M-token rates, billing units, cache-hit pricingLast checked: April 30, 2026
- Model cardDeepSeek on Hugging FaceWeights, license, usage notes per modelLast checked: April 30, 2026
- RepositoryDeepSeek-AI on GitHubOpen-weight release details, training/inference notesLast checked: April 30, 2026
- Model cardDeepSeek-Coder-V2 模型卡片中心标准化 V2 Instruct 权重和模型许可证Last checked: April 30, 2026
Technical references
- Technical reportDeepSeek-V3 technical report (arXiv:2412.19437)V3 architecture and training methodologyLast checked: April 30, 2026
- Technical reportDeepSeek-R1 paper (arXiv:2501.12948)R1 reasoning approach, distillation resultsLast checked: April 30, 2026
- BenchmarkSWE-Bench Verified leaderboardSoftware-engineering benchmark scoresLast checked: April 30, 2026
- BenchmarkLiveCodeBenchLive coding benchmark scoresLast checked: April 30, 2026
- Technical reportDeepSeek-Coder-V2 技术报告在 arXiv 上Full benchmark tables and 338种语言覆盖范围 figuresLast checked: April 30, 2026
Methodology
Architecture, parameter counts, context window, and license were checked against the official DeepSeek model card and the corresponding technical report. Benchmark figures are reproduced as they appear in vendor materials and are treated as directional indicators rather than guarantees of real-world performance.
Data confidence
High for official architecture and license; medium for vendor-reported benchmarks; low for projected future capabilities.
Editorial note
Vendor-reported figures are not always independently replicated. Benchmarks at the frontier change quickly; expect this article to need a refresh whenever DeepSeek, OpenAI, Anthropic, or Google ship a new model.