DeepSeek-Coder-V2
DeepSeek-Coder-V2 is an open-source Mixture-of-Experts (MoE) code language model that achieves performance comparable to GPT4-Turbo in code-specific tasks. It is designed for developers and researchers who need advanced code generation, completion, and mathematical reasoning capabilities, supporting 338 programming languages and a 128K context length.
✨ Key features
- Mixture-of-Experts architecture with 16B and 236B parameter models
- Supports 338 programming languages and 128K context length
- Outperforms GPT-4-Turbo, Claude 3 Opus, and Gemini 1.5 Pro on coding benchmarks
- Available as base and instruct models for fine-tuning or chat
- OpenAI-compatible API and chat website for easy access
- Can be run locally with Hugging Face Transformers or SGLang
🎯 Use cases
- Code generation and completion in multiple programming languages
- Code insertion and fixing in existing codebases
- Mathematical reasoning and problem-solving
- General natural language tasks with coding context
- Building AI-powered coding assistants or tools
📦 Installation
🧰 Requirements: Requires Python and PyTorch; for DeepSeek-Coder-V2 (236B) in BF16, 80GB*8 GPUs are needed; API access available via DeepSeek platform.
To use with Hugging Face Transformers, install the library:
pip install transformers
For SGLang, follow the installation instructions at https://github.com/sgl-project/sglang.
🚀 Usage
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))
⚠️ Good to know
The 236B model requires substantial GPU resources (80GB*8 GPUs) for BF16 inference; the Lite model may have issues with spaces after 'Assistant:' in chat templates.
❓ FAQ
What are the available model sizes?
DeepSeek-Coder-V2 is available in 16B (Lite) and 236B parameter versions, with both base and instruct variants.
How many programming languages does it support?
It supports 338 programming languages, expanded from 86 in the previous version.
What is the context length?
The context length is 128K tokens, allowing processing of long code files.
Can I use it via an API?
Yes, an OpenAI-compatible API is available at platform.deepseek.com with pay-as-you-go pricing.
📊 Repository
🤖 Overview, features, install steps and FAQ were generated from the project's README on Sep 4, 2026. Always check the original source before running commands.