README.md
7.1 KB · 151 lines · markdown Raw
1 ---
2 license: mit
3 library_name: transformers
4 ---
5 # DeepSeek-V4-Flash-0731
6
7 <!-- markdownlint-disable first-line-h1 -->
8 <!-- markdownlint-disable html -->
9 <!-- markdownlint-disable no-duplicate-header -->
10
11 <div align="center">
12 <img src="https://github.com/deepseek-ai/DeepSeek-V2/blob/main/figures/logo.svg?raw=true" width="60%" alt="DeepSeek-V4" />
13 </div>
14 <hr>
15 <div align="center" style="line-height: 1;">
16 <a href="https://www.deepseek.com/" target="_blank" style="margin: 2px;">
17 <img alt="Homepage" src="https://github.com/deepseek-ai/DeepSeek-V2/blob/main/figures/badge.svg?raw=true" style="display: inline-block; vertical-align: middle;"/>
18 </a>
19 <a href="https://chat.deepseek.com/" target="_blank" style="margin: 2px;">
20 <img alt="Chat" src="https://img.shields.io/badge/🤖%20Chat-DeepSeek%20V4-536af5?color=536af5&logoColor=white" style="display: inline-block; vertical-align: middle;"/>
21 </a>
22 </div>
23 <div align="center" style="line-height: 1;">
24 <a href="https://huggingface.co/deepseek-ai" target="_blank" style="margin: 2px;">
25 <img alt="Hugging Face" src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-DeepSeek%20AI-ffc107?color=ffc107&logoColor=white" style="display: inline-block; vertical-align: middle;"/>
26 </a>
27 <a href="https://twitter.com/deepseek_ai" target="_blank" style="margin: 2px;">
28 <img alt="Twitter Follow" src="https://img.shields.io/badge/Twitter-deepseek_ai-white?logo=x&logoColor=white" style="display: inline-block; vertical-align: middle;"/>
29 </a>
30 </div>
31 <div align="center" style="line-height: 1;">
32 <a href="LICENSE" style="margin: 2px;">
33 <img alt="License" src="https://img.shields.io/badge/License-MIT-f5de53?&color=f5de53" style="display: inline-block; vertical-align: middle;"/>
34 </a>
35 </div>
36
37 <p align="center">
38 <a href="https://arxiv.org/abs/2606.19348"><b>Technical Report</b>👁️</a>
39 </p>
40
41 ## Introduction
42
43 **DeepSeek-V4-Flash-0731** is the official release of **DeepSeek-V4-Flash**, superseding the preview version, with substantially enhanced agentic capabilities. It has the same model structure as [DeepSeek-V4-Flash-DSpark](https://huggingface.co/deepseek-ai/DeepSeek-V4-Flash-DSpark), i.e. it comes with a speculative decoding module attached.
44
45 DeepSeek-V4-Flash-0731 outperforms DeepSeek-V4-Pro (Preview) on benchmarks listed below despite its far smaller activated parameter count, and is broadly competitive with the strongest proprietary models available.
46
47 <div align="center">
48
49 | Benchmark | DeepSeek-V4-Flash-0731 | DeepSeek-V4-Flash (Preview) | DeepSeek-V4-Pro (Preview) | GLM-5.2 | Opus-4.8 |
50 | :--- | :---: | :---: | :---: | :---: | :---: |
51 | Terminal Bench 2.1 | 82.7 | 61.8 | 72.1 | 81.0 | 85.0 |
52 | NL2Repo | 54.2 | 39.4 | 38.5 | 48.9 | 69.7 |
53 | Cybergym | 76.7 | 38.7 | 52.7 | - | 83.1 |
54 | DeepSWE | 54.4 | 7.3 | 12.8 | 46.2 | 58.0 |
55 | Toolathlon-Verified | 70.3 | 49.7 | 55.9 | 59.9 | 76.2 |
56 | Agents' Last Exam | 25.2 | 15.8 | 16.5 | 23.8 | 25.7 |
57 | AutomationBench Public | 25.1 | 10.8 | 12.8 | 12.9 | 27.2 |
58 | DSBench-FullStack † | 68.7 | 37.0 | 41.8 | 61.8 | 71.6 |
59 | DSBench-Hard † | 59.6 | 25.8 | 31.1 | 54.5 | 71.7 |
60
61 </div>
62
63 Notes:
64
65 1. For the Code Agent tasks among the public benchmarks above, DeepSeek-V4-Flash-0731 is evaluated with the minimal mode of DeepSeek Harness (to be released) as the agent framework, using the `max` reasoning effort level with `temperature = 1.0, top_p = 0.95`.
66 2. † DSBench-FullStack is an internal full-stack development test set; DSBench-Hard is an internal test set of difficult coding-agent problems.
67
68 ## Chat Template
69
70 This release does not include a Jinja-format chat template. Instead, we provide a dedicated `encoding` folder with Python scripts and test cases demonstrating how to encode messages in OpenAI-compatible format into input strings for the model, and how to parse the model's text output. Please refer to the [`encoding`](encoding/README.md) folder for full documentation.
71
72 The `reasoning_effort` parameter now supports three levels — `low`, `high`, and `max` — which control how much deliberation the model spends before answering.
73
74 A brief example:
75
76 ```python
77 from encoding_dsv4 import encode_messages, parse_message_from_completion_text
78
79 messages = [
80 {"role": "user", "content": "hello"},
81 {"role": "assistant", "content": "Hello! I am DeepSeek.", "reasoning_content": "thinking..."},
82 {"role": "user", "content": "1+1=?"}
83 ]
84
85 # messages -> string
86 prompt = encode_messages(messages, thinking_mode="thinking", reasoning_effort="max")
87
88 # string -> tokens
89 import transformers
90 tokenizer = transformers.AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-V4-Flash-0731")
91 tokens = tokenizer.encode(prompt)
92 ```
93
94 ## How to Run with vLLM
95
96 DSpark speculative decoding is enabled with a single flag — add --speculative-config with method: dspark to your vLLM launch command:
97
98 `--speculative-config '{"method":"dspark","num_speculative_tokens":7,"draft_sample_method":"greedy"}'`
99
100 For example, the command below serves the model with vLLM on a single 4×GB300 node.
101 See the [vLLM recipe](https://recipes.vllm.ai/deepseek-ai/DeepSeek-V4-Flash?hardware=b300&features=tool_calling,reasoning) for detailed instructions and other hardware configurations.
102
103 ```bash
104 vllm serve deepseek-ai/DeepSeek-V4-Flash-0731 \
105 --trust-remote-code --kv-cache-dtype fp8 --block-size 256 \
106 --data-parallel-size 4 --enable-expert-parallel \
107 --moe-backend deep_gemm_mega_moe \
108 --attention-config '{"use_fp4_indexer_cache": true}' \
109 --speculative-config '{"method":"dspark","num_speculative_tokens":7,"draft_sample_method":"greedy"}'
110 ```
111
112 ## How to Run with SGLang
113
114 Enable DSpark with `--speculative-algorithm DSPARK` and do not set a separate `--speculative-draft-model-path` as the target and draft weights therefore come from the same checkpoint.
115 See the [SGLang cookbook](https://docs.sglang.io/cookbook/autoregressive/DeepSeek/DeepSeek-V4#hw=gb300&variant=flash-official&quant=fp4&strategy=low-latency&nodes=single) for detailed instructions, benchmarks and other hardwares configurations.
116
117 ```bash
118 sglang serve \
119 --trust-remote-code \
120 --model-path deepseek-ai/DeepSeek-V4-Flash-0731 \
121 --tp 4 \
122 --moe-runner-backend flashinfer_mxfp4 \
123 --speculative-algorithm DSPARK \
124 --mem-fraction-static 0.90 \
125 --chunked-prefill-size 4096 \
126 --swa-full-tokens-ratio 0.1 \
127 ```
128
129 ## How to Run Locally
130
131 Please refer to the [inference](inference/README.md) folder for detailed instructions on running DeepSeek-V4 locally, including model weight conversion and interactive chat demos.
132
133 For local deployment, we recommend setting the sampling parameters to `temperature = 1.0`, with `top_p = 0.95` for agentic scenarios and `top_p = 1.0` otherwise. For the `high` and `max` reasoning effort levels, we recommend a maximum output length of **384K** tokens.
134
135 ## License
136
137 This repository and the model weights are licensed under the [MIT License](LICENSE).
138
139 ## Citation
140
141 ```
142 @misc{deepseekai2026deepseekv4,
143 title={DeepSeek-V4: Towards Highly Efficient Million-Token Context Intelligence},
144 author={DeepSeek-AI},
145 year={2026},
146 }
147 ```
148
149 ## Contact
150
151 If you have any questions, please raise an issue or contact us at [service@deepseek.com](service@deepseek.com).