DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligence
1. Introduction
We present DeepSeek-Coder-V2, an open-source Mixture-of-Experts (MoE) code language model that achieves performance comparable to GPT4-Turbo in code-specific tasks. Specifically, DeepSeek-Coder-V2 is further pre-trained from an intermediate checkpoint of DeepSeek-V2 with additional 6 trillion tokens. Through this continued pre-training, DeepSeek-Coder-V2 substantially enhances the coding and mathematical reasoning capabilities of DeepSeek-V2, while maintaining comparable performance in general language tasks. Compared to DeepSeek-Coder-33B, DeepSeek-Coder-V2 demonstrates significant advancements in various aspects of code-related tasks, as well as reasoning and general capabilities. Additionally, DeepSeek-Coder-V2 expands its support for programming languages from 86 to 338, while extending the context length from 16K to 128K.
In standard benchmark evaluations, DeepSeek-Coder-V2 achieves superior performance compared to closed-source models such as GPT4-Turbo, Claude 3 Opus, and Gemini 1.5 Pro in coding and math benchmarks. The list of supported programming languages can be found here.
2. Model Downloads
We release the DeepSeek-Coder-V2 with 16B and 236B parameters based on the DeepSeekMoE framework, which has actived parameters of only 2.4B and 21B , including base and instruct models, to the public.
You can chat with the DeepSeek-Coder-V2 on DeepSeek's official website: coder.deepseek.com
4. API Platform
We also provide OpenAI-Compatible API at DeepSeek Platform: platform.deepseek.com, and you can also pay-as-you-go at an unbeatable price.
5. How to run locally
Here, we provide some examples of how to use DeepSeek-Coder-V2-Lite model. If you want to utilize DeepSeek-Coder-V2 in BF16 format for inference, 80GB*8 GPUs are required.
1from transformers import AutoTokenizer
2from vllm import LLM, SamplingParams
34max_model_len, tp_size =8192,15model_name ="deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct"6tokenizer = AutoTokenizer.from_pretrained(model_name)7llm = LLM(model=model_name, tensor_parallel_size=tp_size, max_model_len=max_model_len, trust_remote_code=True, enforce_eager=True)8sampling_params = SamplingParams(temperature=0.3, max_tokens=256, stop_token_ids=[tokenizer.eos_token_id])910messages_list =[11[{"role":"user","content":"Who are you?"}],12[{"role":"user","content":"write a quick sort algorithm in python."}],13[{"role":"user","content":"Write a piece of quicksort code in C++."}],14]1516prompt_token_ids =[tokenizer.apply_chat_template(messages, add_generation_prompt=True)for messages in messages_list]1718outputs = llm.generate(prompt_token_ids=prompt_token_ids, sampling_params=sampling_params)1920generated_text =[output.outputs[0].text for output in outputs]21print(generated_text)
6. License
This code repository is licensed under the MIT License. The use of DeepSeek-Coder-V2 Base/Instruct models is subject to the Model License. DeepSeek-Coder-V2 series (including Base and Instruct) supports commercial use.
7. Contact
If you have any questions, please raise an issue or contact us at service@deepseek.com.