Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
D

DeepSeek-Coder

> 编程语言
Open source

DeepSeek Coder: Let the Code Write Itself

24.0K stars0 likes1 views
WebsiteGitHub

About

DeepSeek Coder: Let the Code Write Itself

[ Homepage] | [🤖 Chat with DeepSeek Coder] | [🤗 Models Download] | [Discord] | [WeChat (微信)]

Paper Link👁️


1. Introduction of DeepSeek Coder

DeepSeek Coder is composed of a series of code language models, each trained from scratch on 2T tokens, with a composition of 87% code and 13% natural language in both English and Chinese. We provide various sizes of the code model, ranging from 1B to 33B versions. Each model is pre-trained on project-level code corpus by employing a window size of 16K and an extra fill-in-the-blank task, to support project-level code completion and infilling. For coding capabilities, DeepSeek Coder achieves state-of-the-art performance among open-source code models on multiple programming languages and various benchmarks.

  • Massive Training Data: Trained from scratch on 2T tokens, including 87% code and 13% linguistic data in both English and Chinese languages.

  • Highly Flexible & Scalable: Offered in model sizes of 1B, 5.7B, 6.7B and 33B, enabling users to choose the setup most suitable for their requirements.

  • Superior Model Performance: State-of-the-art performance among publicly available code models on HumanEval, MultiPL-E, MBPP, DS-1000, and APPS benchmarks.

  • Advanced Code Completion Capabilities: A window size of 16K and a fill-in-the-blank task, supporting project-level code completion and infilling tasks.

Supported Programming Languages

['ada', 'agda', 'alloy', 'antlr', 'applescript', 'assembly', 'augeas', 'awk', 'batchfile', 'bluespec', 'c', 'c-sharp', 'clojure', 'cmake', 'coffeescript', 'common-lisp', 'cpp', 'css', 'cuda', 'dart', 'dockerfile', 'elixir', 'elm', 'emacs-lisp', 'erlang', 'f-sharp', 'fortran', 'glsl', 'go', 'groovy', 'haskell', 'html', 'idris', 'isabelle', 'java', 'java-server-pages', 'javascript', 'json', 'julia', 'jupyter-notebook', 'kotlin', 'lean', 'literate-agda', 'literate-coffeescript', 'literate-haskell', 'lua', 'makefile', 'maple', 'markdown', 'mathematica', 'matlab', 'ocaml', 'pascal', 'perl', 'php', 'powershell', 'prolog', 'protocol-buffer', 'python', 'r', 'racket', 'restructuredtext', 'rmarkdown', 'ruby', 'rust', 'sas', 'scala', 'scheme', 'shell', 'smalltalk', 'solidity', 'sparql', 'sql', 'stan', 'standard-ml', 'stata', 'systemverilog', 'tcl', 'tcsh', 'tex', 'thrift', 'typescript', 'verilog', 'vhdl', 'visual-basic', 'xslt', 'yacc', 'yaml', 'zig']

2. Evaluation Results

We evaluate DeepSeek Coder on various coding-related benchmarks. Only pass@1 results on HumanEval (Python and Multilingual), MBPP, and DS-1000 are reported here:

The result shows that DeepSeek-Coder-Base-33B significantly outperforms existing open-source code LLMs. Compared with CodeLlama-34B, it leads by 7.9%, 9.3%, 10.8% and 5.9% respectively on HumanEval Python, HumanEval Multilingual, MBPP and DS-1000. Surprisingly, our DeepSeek-Coder-Base-7B reaches the performance of CodeLlama-34B. The DeepSeek-Coder-Instruct-33B model after instruction tuning outperforms GPT35-turbo on HumanEval and achieves comparable results with GPT35-turbo on MBPP.

More evaluation details can be found in the Detailed Evaluation.

3. Procedure of Data Creation and Model Training

Data Creation

  • Step 1: Collect code data from GitHub and apply the same filtering rules as StarCoder Data to filter data.
  • Step 2: Parsing the dependencies of files within the same repository to rearrange the file positions based on their dependencies.
  • Step 3: Concatenating dependent files to form a single example and employ repo-level minhash for deduplication.
  • Step 4: Further filtering out low-quality code, such as codes with syntax errors or poor readability.

Model Training

  • Step 1: Initially pre-trained with a dataset consisting of 87% code, 10% code-related language (Github Markdown and StackExchange), and 3% non-code-related Chinese language. Models are pre-trained using 1.8T tokens and a 4K window size in this step.
  • Step 2: Further Pre-training using an extended 16K window size on an additional 200B tokens, resulting in foundational models (DeepSeek-Coder-Base).
  • Step 3: Instruction Fine-tuning on 2B tokens of instruction data, resulting in instruction-tuned models (DeepSeek-Coder-Instruct).

4. How to Use

Before proceeding, you'll need to install the necessary dependencies. You can do this by running the following command:

bash
pip install -r requirements.txt

A demo is also available on the 🤗 Hugging Face Space, and you can run the demo locally using app.py in the demo folder. (Thanks to all the HF team for their support)

Here are some examples of how to use our model.

1) Code Completion

python
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/deepseek-coder-6.7b-base", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("deepseek-ai/deepseek-coder-6.7b-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))

This code will output the following result:

def quick_sort(arr):
    if len(arr) <= 1:
        return arr
    pivot = arr[0]
    left = []
    right = []
    for i in range(1, len(arr)):
        if arr[i] < pivot:
            left.append(arr[i])
        else:
            right.append(arr[i])
    return quick_sort(left) + [pivot] + quick_sort(right)

2) Code Insertion

…

This code will output the following result:

   for i in range(1, len(arr)):

3) Chat Model Inference

…

This code will output the following result:

…

If you don't want to use the provided API apply_chat_template which loads the template from tokenizer_config.json, you can use the following template to chat with our model. Replace the ['content'] with your instructions and the model's previous (if any) responses, then the model will generate the response to the currently given instruction.

You are an AI programming assistant, utilizing the DeepSeek Coder model, developed by DeepSeek Company, and you only answer questions related to computer science. For politically sensitive questions, security and privacy issues, and other non-computer science questions, you will refuse to answer.
### Instruction:
['content']
### Response:
['content']
<|EOT|>
### Instruction:
['content']
### Response:

4) Repository Level Code Completion

…

In the following scenario, the DeepSeek-Coder-6.7B model effectively calls a class IrisClassifier and its member function from the model.py file, and also utilizes functions from the utils.py file, to correctly complete the main function in the main.py file for model training and evaluation.

5. How to Fine-tune DeepSeek-Coder

We provide script finetune/finetune_deepseekcoder.py for users to finetune our models on downstream tasks.

The script supports the training with DeepSpeed. You need install required packages by:

bash
pip install -r finetune/requirements.txt

Please follow Sample Dataset Format to prepare your training data. Each line is a json-serialized string with two required fields instruction and output.

After data preparation, you can use the sample shell script to finetune deepseek-ai/deepseek-coder-6.7b-instruct. Remember to specify DATA_PATH, OUTPUT_PATH. And please choose appropriate hyper-parameters(e.g., learning_rate, per_device_train_batch_size) according to your scenario.

…

6. Detailed Evaluation Results

The reproducible code for the following evaluation results can be found in the Evaluation directory.

1) Multilingual HumanEval Benchmark

2) MBPP Benchmark

3) DS-1000 Benchmark

4) Program-Aid Math Reasoning Benchmark

Inference with vLLM

You can also employ vLLM for high-throughput inference.

Text Completion

…

Chat Completion

…

7. Q&A

Could You Provide the tokenizer.model File for Model Quantization?

DeepSeek Coder utilizes the HuggingFace Tokenizer to implement the Bytelevel-BPE algorithm, with specially designed pre-tokenizers to ensure optimal performance. Currently, there is no direct way to convert the tokenizer into a SentencePiece tokenizer. We are contributing to the open-source quantization methods facilitate the usage of HuggingFace Tokenizer.

GGUF(llama.cpp)

We have submitted a PR to the popular quantization repository llama.cpp to fully support all HuggingFace pre-tokenizers, including ours.

While waiting for the PR to be merged, you can generate your GGUF model using the following steps:

bash
git clone https://github.com/DOGEwbx/llama.cpp.git
cd llama.cpp
git checkout regex_gpt2_preprocess
# set up the environment according to README
make
python3 -m pip install -r requirements.txt
# generate GGUF model
python convert-hf-to-gguf.py <MODEL_PATH> --outfile <GGUF_PATH> --model-name deepseekcoder
# use q4_0 quantization as an example
./quantize <GGUF_PATH> <OUTPUT_PATH> q4_0
./main -m <OUTPUT_PATH> -n 128 -p <PROMPT>
GPTQ(exllamav2)

UPDATE:exllamav2 has been able to support Huggingface Tokenizer. Please pull the latest version and try out.

Remember to set RoPE scaling to 4 for correct output, more discussion could be found in this PR.

How to use the deepseek-coder-instruct to complete the code?

Although the deepseek-coder-instruct models are not specifically trained for code completion tasks during supervised fine-tuning (SFT), they retain the capability to perform code completion effectively. To enable this functionality, you simply need to adjust the eos_token_id parameter. Set the eos_token_id to 32014, as opposed to its default value of 32021 in the deepseek-coder-instruct configuration. This modification prompts the model to recognize the end of a sequence differently, thereby facilitating code completion tasks.

8. Resources

awesome-deepseek-coder is a curated list of open-source projects related to DeepSeek Coder.

9. License

This code repository is licensed under the MIT License. The use of DeepSeek Coder models is subject to the Model License. DeepSeek Coder supports commercial use.

See the LICENSE-CODE and LICENSE-MODEL for more details.

10. Citation

@misc{deepseek-coder,
  author = {Daya Guo, Qihao Zhu, Dejian Yang, Zhenda Xie, Kai Dong, Wentao Zhang, Guanting Chen, Xiao Bi, Y. Wu, Y.K. Li, Fuli Luo, Yingfei Xiong, Wenfeng Liang},
  title = {DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligence},
  journal = {CoRR},
  volume = {abs/2401.

Issues· 173 open

View all issuesOpen on GitHub
  • #4

    建议提供全中文的注释和使用手册 :)

    documentationUpdated Sep 1, 2026
  • #717

    How DeepSeek-V4-Pro formulated "Conscience as an Operating System" via Semantic Resonance

    Updated Aug 29, 2026
  • #106

    Training loss extremely noisy during fine-tuning and randomly goes to 0

    Updated Aug 24, 2026
  • #715

    Broken Link

    Updated Aug 22, 2026
  • #716

    Bug Report – Shell script code blocks are corrupted in output

    Updated Aug 9, 2026
  • #714

    交流群满人了,加不进去了

    Updated Aug 3, 2026
  • #711

    ZigZag Color PRO FIX V2 (Auto) |

    Updated Jul 21, 2026
  • #709

    baru

    Updated Jul 14, 2026
  • #707

    file:///C:/Users/MR.%20ALGHALI/Downloads/gemini-code-1781199660318.html

    Updated Jun 18, 2026
  • #706

    111

    Updated Jun 16, 2026

> Tags

Python

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 30, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言