DeepSeek-Coder-V2
A powerful open-source MoE model for code
2 min readupdated
DeepSeek-Coder-V2 is an open-source language model built on a Mixture-of-Experts (MoE) architecture, designed for programming and mathematical reasoning. Trained by further pre-training an intermediate DeepSeek-V2 checkpoint on an additional 6 trillion tokens, it expands language support from 86 to 338 programming languages and extends the context length to 128K. Available in 16B (Lite) and 236B parameter sizes, it keeps inference efficient by activating only 2.4B and 21B parameters per token, respectively.
Key features
- Support for 338 programming languages and an extended 128K context window.
- Coding and math performance on par with closed-source models like GPT-4 Turbo.
- Efficient DeepSeekMoE architecture that activates only a fraction of total parameters.
- Available in both Base and Instruct versions.
What you can do
- Automate code generation, completion, and insertion across hundreds of programming languages.
- Deploy a custom AI coding assistant using Hugging Face Transformers or vLLM.
- Tackle complex programming and math problems requiring long-context reasoning.
Example
Code completion inference example using the Transformers library:
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Base", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Base", trust_remote_code=True, torch_dtype=torch.bfloat16).cuda()
input_text = "#write a quick sort algorithm"
inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_length=128)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Read more
DetailsTotal parameters: 236B (or 16B for Lite versions); active parameters: 21B (or 2.4B for Lite).
Context length: up to 128K tokens.
Running the full version in BF16 requires 8 GPUs with 80GB VRAM each.
Supports commercial use under the model license.










Comments