Skip to main content
Browse Models

Deepseek AI

DeepSeek Coder V2

Released

2024-07-17

Family

DeepSeek V2

Type

Foundation Model

Downloads

External Download

You are about to open a link to an external source. Verify the URL before continuing.

Download

Instruct model, 4-bit GGUF (Q4_K_M)

GGUF · DeepSeek-Coder-V2-Instruct-Q4_K_M.gguf

Ollama Model (q4_K_M)

Ollama

Model Report

Overview

DeepSeek-Coder-V2 is an open-source, Mixture-of-Experts (MoE) code language model developed by DeepSeek-AI. It was designed for advanced code and mathematical reasoning that supports a variety of programming languages and problem domains, and has been evaluated for performance against models such as GPT-4 Turbo in code-centric tasks. Details of its model architecture, training scale, and evaluation methodologies are documented in the arXiv paper and official model repositories.

Bar chart comparing DeepSeek-Coder-V2 and other models on code and math benchmarks

Figure 1. DeepSeek-Coder-V2 performance benchmarked against other leading models (GPT-4-Turbo, Claude 3 Opus, Gemini 1.5 Pro, Llama-3-70B, Codestral) across HumanEval, MBPP+, MATH, GSM8K, Aider, LiveCodeBench, and SWE-Bench.

Model Architecture and Technical Foundations

DeepSeek-Coder-V2 leverages a Mixture-of-Experts (MoE) architecture, with two principal variants: DeepSeek-Coder-V2 (236 billion total parameters, 21 billion active) and DeepSeek-Coder-V2-Lite (16 billion total parameters, 2.4 billion active). The model is built atop an intermediate checkpoint of DeepSeek-V2, inheriting its DeepSeekMoE framework and extending it for coding and mathematical domains. Improvements include resolving previous training instabilities and gradient spikes by reverting to conventional normalization schemes within the transformer blocks.

The architecture supports an extended context window of up to 128,000 tokens—facilitated through the Yarn technique—enabling the model to process and reason over lengthy codebases and documents. Moreover, DeepSeek-Coder-V2-Lite-Base is trained with a fill-in-the-middle (FIM) objective, enhancing its ability to insert code segments given surrounding content and improving code completion flexibility.

Training Data and Methodology

The training of DeepSeek-Coder-V2 encompasses a substantial dataset, accumulating 10.2 trillion tokens, building on DeepSeek-V2's pretraining (4.2T tokens) with an additional 6T tokens specifically curated for code, mathematics, and natural language content. The final dataset composition is approximately 60% source code (spanning 338 programming languages), 10% mathematical corpus, and 30% natural language text. Code sources are drawn primarily from GitHub and CommonCrawl, subjected to rigorous filtering to eliminate low-quality and duplicate instances. The mathematical dataset leverages resources such as Math StackExchange and Odyssey-math.

Pretraining objectives consist of next-token prediction for all model sizes, while the 16B model also utilizes FIM (Prefix, Suffix, Middle) masking, set at a 50% application rate. The optimizer of choice is AdamW, with hyperparameters $\beta_1 = 0.9$, $\beta_2 = 0.95$, and a cosine decay learning rate schedule. For alignment, a multi-phase process includes supervised fine-tuning on a 300M token instruction dataset, combining code, math, and general instruction data, followed by reinforcement learning via the Group Relative Policy Optimization (GRPO) algorithm. Feedback for reward modeling incorporates compiler outputs and test case results, ensuring alignment with human and functional coding preferences.

Performance Evaluation

Evaluations of DeepSeek-Coder-V2 span a suite of code generation, completion, code editing, reasoning, and math benchmarks. On code synthesis, the model achieves 90.2% accuracy on HumanEval (Python) and 76.2% on MBPP+, outperforming both open-source and multiple proprietary models on these measures. Notably, the model attains 43.4% on LiveCodeBench and 12.7% on SWE-Bench (the first time an open-source model exceeded 10% for SWE-Bench).

On multilingual code generation, DeepSeek-Coder-V2-Instruct achieves a 75.3% average across multiple languages on Multilingual HumanEval, yielding high results in Java and PHP and competitive performance across Python, C++, C#, TypeScript, and JavaScript. For competitive programming, the model matches the highest available scores among large models on USACO.

Code completion tasks evaluated by RepoBench v1.1 show that the Lite variant, despite its smaller active parameter count, maintains parity with the 33B variant in Python and the 7B variant in Java. Fill-in-the-middle evaluation yields 86.4% mean accuracy.

In code fixing, DeepSeek-Coder-V2 achieves 21.0% on Defects4J and leads all models with 73.7% on Aider. For code understanding and reasoning, results include 70.0% on CRUXEval-I-COT and 75.1% on CRUXEval-O-COT.

In mathematical reasoning, the model achieves 75.7% accuracy on the MATH benchmark, 94.9% on GSM8K, solving 4 out of 30 AIME 2024 problems, and 53.7% on Math Odyssey.

Finally, in general language understanding, DeepSeek-Coder-V2 remains on par with DeepSeek-V2 across benchmarks like MMLU (79.2% using OpenAI simple-eval pipeline), Arena-Hard (65.0%), MT-Bench (8.77), and Alignbench (7.84).

Limitations

Despite its robust capabilities, DeepSeek-Coder-V2 exhibits certain limitations. Instruction following can lag behind proprietary models such as GPT-4 Turbo, especially in complex, multi-step tasks like those found in SWE-Bench. The Lite variant is also less effective on knowledge-intensive evaluations like TriviaQA, due in part to limited pretraining on web-scale text. While outperforming open-source peers on code reasoning (e.g., CRUXEval), there remain measurable performance gaps compared to the largest closed-source models, a difference partly attributable to active parameter counts and training scale.

Applications and Licensing

DeepSeek-Coder-V2 is suitable for a broad array of code-oriented applications, including code completion, code generation, code insertion, code fixing, and mathematical problem solving. It also powers conversational assistants for technical disciplines.

The model and codebase are available under permissive terms: code is distributed via the MIT License, and model weights are governed by the DeepSeek Model License. The full series—including Base and Instruct variants—are available for commercial use in accordance with these licensing terms.

Relevant External Links

About DeepSeek V2: DeepSeek V2 and its 16-billion-parameter counterpart, DeepSeek V2 Lite, are Mixture-of-Experts (MoE) language models that utilize Multi-head Latent Attention (MLA) and the DeepSeekMoE architecture to achieve efficient inference and economical training, delivering high performance with reduced computational costs.

More from Deepseek AI

Deepseek AI /

DeepSeek R1 Distill Qwen 1.5B

A 1.5 billion parameter language model created through distillation techniques, focusing on mathematical reasoning and chain-of-thought problem-solving capabilities.
Deepseek AI /

DeepSeek R1 Distill Qwen 7B

A 7.62B parameter distilled language model based on Qwen2.5-Math-7B, trained via knowledge distillation for mathematical and logical reasoning tasks.
Deepseek AI /

DeepSeek R1 Distill Qwen 14B

A 14B dense language model distilled from a mixture-of-experts architecture, optimized for mathematical reasoning and code generation tasks.
Deepseek AI /

DeepSeek R1 Distill Qwen 32B

A 32B parameter language model created through knowledge distillation, optimized for mathematical reasoning, code generation, and complex problem-solving tasks.
Deepseek AI /

DeepSeek R1 Distill Llama 8B

Distilled 8B-parameter model optimized for mathematical reasoning and code generation through knowledge transfer from larger reinforcement learning-trained teacher models.
Deepseek AI /

DeepSeek R1 Distill Llama 70B

A 70B parameter dense language model distilled from DeepSeek-R1 using Llama 3.3 architecture, optimized for mathematical and coding reasoning tasks.
Deepseek AI /

DeepSeek R1 (0528)

A 671B-parameter MoE model with 37B active parameters featuring enhanced reasoning capabilities through reinforcement learning and chain-of-thought training methodologies.
Deepseek AI /

DeepSeek R1

A 671B parameter Mixture-of-Experts model trained with reinforcement learning to enhance reasoning capabilities in mathematics, coding, and logical tasks.
Deepseek AI /

DeepSeek V3 (0324)

Large-scale MoE language model utilizing 671B parameters with 37B activated per token, featuring enhanced reasoning and multilingual capabilities.
Deepseek AI /

DeepSeek V3

A 671-billion parameter Mixture-of-Experts language model with 37 billion active parameters per token, featuring auxiliary-loss-free load balancing and FP8 mixed-precision training.
Deepseek AI /

DeepSeek VL2

A Mixture-of-Experts vision-language model series featuring dynamic image tiling, visual grounding capabilities, and efficient sparse computation across three parameter variants.
Deepseek AI /

DeepSeek VL2 Small

A 2.8B parameter mixture-of-experts vision-language model with dynamic tiling for multimodal understanding, OCR, and visual grounding tasks.
Deepseek AI /

DeepSeek VL2 Tiny

A compact Mixture-of-Experts vision-language model with 1.0B activated parameters supporting multimodal tasks including OCR, document analysis, and visual grounding.