Text Generation
Transformers
Safetensors
deepseek_v3
conversational
custom_code
text-generation-inference
fp8
Instructions to use m8than/DeepSeek-R1-ChatFix with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use m8than/DeepSeek-R1-ChatFix with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="m8than/DeepSeek-R1-ChatFix", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("m8than/DeepSeek-R1-ChatFix", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("m8than/DeepSeek-R1-ChatFix", trust_remote_code=True, device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use m8than/DeepSeek-R1-ChatFix with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "m8than/DeepSeek-R1-ChatFix" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "m8than/DeepSeek-R1-ChatFix", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/m8than/DeepSeek-R1-ChatFix
- SGLang
How to use m8than/DeepSeek-R1-ChatFix with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "m8than/DeepSeek-R1-ChatFix" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "m8than/DeepSeek-R1-ChatFix", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "m8than/DeepSeek-R1-ChatFix" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "m8than/DeepSeek-R1-ChatFix", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use m8than/DeepSeek-R1-ChatFix with Docker Model Runner:
docker model run hf.co/m8than/DeepSeek-R1-ChatFix
Duplicate from deepseek-ai/DeepSeek-R1
Browse filesCo-authored-by: Shirong Ma <msr2000@users.noreply.huggingface.co>
This view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- .gitattributesAdded+35
- LICENSEAdded+21
- README.mdAdded+239
- config.jsonAdded+67
- configuration_deepseek.pyAdded+199
- figures/benchmark.jpgAdded
- generation_config.jsonAdded+9
- model-00001-of-000163.safetensorsAdded+3
- model-00002-of-000163.safetensorsAdded+3
- model-00003-of-000163.safetensorsAdded+3
- model-00004-of-000163.safetensorsAdded+3
- model-00005-of-000163.safetensorsAdded+3
- model-00006-of-000163.safetensorsAdded+3
- model-00007-of-000163.safetensorsAdded+3
- model-00008-of-000163.safetensorsAdded+3
- model-00009-of-000163.safetensorsAdded+3
- model-00010-of-000163.safetensorsAdded+3
- model-00011-of-000163.safetensorsAdded+3
- model-00012-of-000163.safetensorsAdded+3
- model-00013-of-000163.safetensorsAdded+3
- model-00014-of-000163.safetensorsAdded+3
- model-00015-of-000163.safetensorsAdded+3
- model-00016-of-000163.safetensorsAdded+3
- model-00017-of-000163.safetensorsAdded+3
- model-00018-of-000163.safetensorsAdded+3
- model-00019-of-000163.safetensorsAdded+3
- model-00020-of-000163.safetensorsAdded+3
- model-00021-of-000163.safetensorsAdded+3
- model-00022-of-000163.safetensorsAdded+3
- model-00023-of-000163.safetensorsAdded+3
- model-00024-of-000163.safetensorsAdded+3
- model-00025-of-000163.safetensorsAdded+3
- model-00026-of-000163.safetensorsAdded+3
- model-00027-of-000163.safetensorsAdded+3
- model-00028-of-000163.safetensorsAdded+3
- model-00029-of-000163.safetensorsAdded+3
- model-00030-of-000163.safetensorsAdded+3
- model-00031-of-000163.safetensorsAdded+3
- model-00032-of-000163.safetensorsAdded+3
- model-00033-of-000163.safetensorsAdded+3
- model-00034-of-000163.safetensorsAdded+3
- model-00035-of-000163.safetensorsAdded+3
- model-00036-of-000163.safetensorsAdded+3
- model-00037-of-000163.safetensorsAdded+3
- model-00038-of-000163.safetensorsAdded+3
- model-00039-of-000163.safetensorsAdded+3
- model-00040-of-000163.safetensorsAdded+3
- model-00041-of-000163.safetensorsAdded+3
- model-00042-of-000163.safetensorsAdded+3
- model-00043-of-000163.safetensorsAdded+3
1234567891011121314151617181920212223242526272829303132333435*.7z filter=lfs diff=lfs merge=lfs -text*.arrow filter=lfs diff=lfs merge=lfs -text*.bin filter=lfs diff=lfs merge=lfs -text*.bz2 filter=lfs diff=lfs merge=lfs -text*.ckpt filter=lfs diff=lfs merge=lfs -text*.ftz filter=lfs diff=lfs merge=lfs -text*.gz filter=lfs diff=lfs merge=lfs -text*.h5 filter=lfs diff=lfs merge=lfs -text*.joblib filter=lfs diff=lfs merge=lfs -text*.lfs.* filter=lfs diff=lfs merge=lfs -text*.mlmodel filter=lfs diff=lfs merge=lfs -text*.model filter=lfs diff=lfs merge=lfs -text*.msgpack filter=lfs diff=lfs merge=lfs -text*.npy filter=lfs diff=lfs merge=lfs -text*.npz filter=lfs diff=lfs merge=lfs -text*.onnx filter=lfs diff=lfs merge=lfs -text*.ot filter=lfs diff=lfs merge=lfs -text*.parquet filter=lfs diff=lfs merge=lfs -text*.pb filter=lfs diff=lfs merge=lfs -text*.pickle filter=lfs diff=lfs merge=lfs -text*.pkl filter=lfs diff=lfs merge=lfs -text*.pt filter=lfs diff=lfs merge=lfs -text*.pth filter=lfs diff=lfs merge=lfs -text*.rar filter=lfs diff=lfs merge=lfs -text*.safetensors filter=lfs diff=lfs merge=lfs -textsaved_model/**/* filter=lfs diff=lfs merge=lfs -text*.tar.* filter=lfs diff=lfs merge=lfs -text*.tar filter=lfs diff=lfs merge=lfs -text*.tflite filter=lfs diff=lfs merge=lfs -text*.tgz filter=lfs diff=lfs merge=lfs -text*.wasm filter=lfs diff=lfs merge=lfs -text*.xz filter=lfs diff=lfs merge=lfs -text*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text123456789101112131415161718192021MIT License
Copyright (c) 2023 DeepSeek
Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239---license: mitlibrary_name: transformers---# DeepSeek-R1<!-- markdownlint-disable first-line-h1 --><!-- markdownlint-disable html --><!-- markdownlint-disable no-duplicate-header -->
<div align="center"> <img src="https://github.com/deepseek-ai/DeepSeek-V2/blob/main/figures/logo.svg?raw=true" width="60%" alt="DeepSeek-V3" /></div><hr><div align="center" style="line-height: 1;"> <a href="https://www.deepseek.com/" target="_blank" style="margin: 2px;"> <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;"/> </a> <a href="https://chat.deepseek.com/" target="_blank" style="margin: 2px;"> <img alt="Chat" src="https://img.shields.io/badge/🤖%20Chat-DeepSeek%20R1-536af5?color=536af5&logoColor=white" style="display: inline-block; vertical-align: middle;"/> </a> <a href="https://huggingface.co/deepseek-ai" target="_blank" style="margin: 2px;"> <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;"/> </a></div>
<div align="center" style="line-height: 1;"> <a href="https://discord.gg/Tc7c45Zzu5" target="_blank" style="margin: 2px;"> <img alt="Discord" src="https://img.shields.io/badge/Discord-DeepSeek%20AI-7289da?logo=discord&logoColor=white&color=7289da" style="display: inline-block; vertical-align: middle;"/> </a> <a href="https://github.com/deepseek-ai/DeepSeek-V2/blob/main/figures/qr.jpeg?raw=true" target="_blank" style="margin: 2px;"> <img alt="Wechat" src="https://img.shields.io/badge/WeChat-DeepSeek%20AI-brightgreen?logo=wechat&logoColor=white" style="display: inline-block; vertical-align: middle;"/> </a> <a href="https://twitter.com/deepseek_ai" target="_blank" style="margin: 2px;"> <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;"/> </a></div>
<div align="center" style="line-height: 1;"> <a href="https://github.com/deepseek-ai/DeepSeek-R1/blob/main/LICENSE" style="margin: 2px;"> <img alt="License" src="https://img.shields.io/badge/License-MIT-f5de53?&color=f5de53" style="display: inline-block; vertical-align: middle;"/> </a></div>
<p align="center"> <a href="https://github.com/deepseek-ai/DeepSeek-R1/blob/main/DeepSeek_R1.pdf"><b>Paper Link</b>👁️</a></p>
## 1. Introduction
We introduce our first-generation reasoning models, DeepSeek-R1-Zero and DeepSeek-R1. DeepSeek-R1-Zero, a model trained via large-scale reinforcement learning (RL) without supervised fine-tuning (SFT) as a preliminary step, demonstrated remarkable performance on reasoning.With RL, DeepSeek-R1-Zero naturally emerged with numerous powerful and interesting reasoning behaviors.However, DeepSeek-R1-Zero encounters challenges such as endless repetition, poor readability, and language mixing. To address these issues and further enhance reasoning performance,we introduce DeepSeek-R1, which incorporates cold-start data before RL.DeepSeek-R1 achieves performance comparable to OpenAI-o1 across math, code, and reasoning tasks. To support the research community, we have open-sourced DeepSeek-R1-Zero, DeepSeek-R1, and six dense models distilled from DeepSeek-R1 based on Llama and Qwen. DeepSeek-R1-Distill-Qwen-32B outperforms OpenAI-o1-mini across various benchmarks, achieving new state-of-the-art results for dense models.
**NOTE: Before running DeepSeek-R1 series models locally, we kindly recommend reviewing the [Usage Recommendation](#usage-recommendations) section.**
<p align="center"> <img width="80%" src="figures/benchmark.jpg"></p>
## 2. Model Summary
---
**Post-Training: Large-Scale Reinforcement Learning on the Base Model**
- We directly apply reinforcement learning (RL) to the base model without relying on supervised fine-tuning (SFT) as a preliminary step. This approach allows the model to explore chain-of-thought (CoT) for solving complex problems, resulting in the development of DeepSeek-R1-Zero. DeepSeek-R1-Zero demonstrates capabilities such as self-verification, reflection, and generating long CoTs, marking a significant milestone for the research community. Notably, it is the first open research to validate that reasoning capabilities of LLMs can be incentivized purely through RL, without the need for SFT. This breakthrough paves the way for future advancements in this area.
- We introduce our pipeline to develop DeepSeek-R1. The pipeline incorporates two RL stages aimed at discovering improved reasoning patterns and aligning with human preferences, as well as two SFT stages that serve as the seed for the model's reasoning and non-reasoning capabilities. We believe the pipeline will benefit the industry by creating better models.
---
**Distillation: Smaller Models Can Be Powerful Too**
- We demonstrate that the reasoning patterns of larger models can be distilled into smaller models, resulting in better performance compared to the reasoning patterns discovered through RL on small models. The open source DeepSeek-R1, as well as its API, will benefit the research community to distill better smaller models in the future. - Using the reasoning data generated by DeepSeek-R1, we fine-tuned several dense models that are widely used in the research community. The evaluation results demonstrate that the distilled smaller dense models perform exceptionally well on benchmarks. We open-source distilled 1.5B, 7B, 8B, 14B, 32B, and 70B checkpoints based on Qwen2.5 and Llama3 series to the community.
## 3. Model Downloads
### DeepSeek-R1 Models
<div align="center">
| **Model** | **#Total Params** | **#Activated Params** | **Context Length** | **Download** || :------------: | :------------: | :------------: | :------------: | :------------: || DeepSeek-R1-Zero | 671B | 37B | 128K | [🤗 HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-R1-Zero) || DeepSeek-R1 | 671B | 37B | 128K | [🤗 HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-R1) |
</div>
DeepSeek-R1-Zero & DeepSeek-R1 are trained based on DeepSeek-V3-Base. For more details regarding the model architecture, please refer to [DeepSeek-V3](https://github.com/deepseek-ai/DeepSeek-V3) repository.
### DeepSeek-R1-Distill Models
<div align="center">
| **Model** | **Base Model** | **Download** || :------------: | :------------: | :------------: || DeepSeek-R1-Distill-Qwen-1.5B | [Qwen2.5-Math-1.5B](https://huggingface.co/Qwen/Qwen2.5-Math-1.5B) | [🤗 HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B) || DeepSeek-R1-Distill-Qwen-7B | [Qwen2.5-Math-7B](https://huggingface.co/Qwen/Qwen2.5-Math-7B) | [🤗 HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-7B) || DeepSeek-R1-Distill-Llama-8B | [Llama-3.1-8B](https://huggingface.co/meta-llama/Llama-3.1-8B) | [🤗 HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Llama-8B) || DeepSeek-R1-Distill-Qwen-14B | [Qwen2.5-14B](https://huggingface.co/Qwen/Qwen2.5-14B) | [🤗 HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-14B) ||DeepSeek-R1-Distill-Qwen-32B | [Qwen2.5-32B](https://huggingface.co/Qwen/Qwen2.5-32B) | [🤗 HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-32B) || DeepSeek-R1-Distill-Llama-70B | [Llama-3.3-70B-Instruct](https://huggingface.co/meta-llama/Llama-3.3-70B-Instruct) | [🤗 HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Llama-70B) |
</div>
DeepSeek-R1-Distill models are fine-tuned based on open-source models, using samples generated by DeepSeek-R1.We slightly change their configs and tokenizers. Please use our setting to run these models.
## 4. Evaluation Results
### DeepSeek-R1-Evaluation For all our models, the maximum generation length is set to 32,768 tokens. For benchmarks requiring sampling, we use a temperature of $0.6$, a top-p value of $0.95$, and generate 64 responses per query to estimate pass@1.<div align="center">
| Category | Benchmark (Metric) | Claude-3.5-Sonnet-1022 | GPT-4o 0513 | DeepSeek V3 | OpenAI o1-mini | OpenAI o1-1217 | DeepSeek R1 ||----------|-------------------|----------------------|------------|--------------|----------------|------------|--------------|| | Architecture | - | - | MoE | - | - | MoE || | # Activated Params | - | - | 37B | - | - | 37B || | # Total Params | - | - | 671B | - | - | 671B || English | MMLU (Pass@1) | 88.3 | 87.2 | 88.5 | 85.2 | **91.8** | 90.8 || | MMLU-Redux (EM) | 88.9 | 88.0 | 89.1 | 86.7 | - | **92.9** || | MMLU-Pro (EM) | 78.0 | 72.6 | 75.9 | 80.3 | - | **84.0** || | DROP (3-shot F1) | 88.3 | 83.7 | 91.6 | 83.9 | 90.2 | **92.2** || | IF-Eval (Prompt Strict) | **86.5** | 84.3 | 86.1 | 84.8 | - | 83.3 || | GPQA-Diamond (Pass@1) | 65.0 | 49.9 | 59.1 | 60.0 | **75.7** | 71.5 || | SimpleQA (Correct) | 28.4 | 38.2 | 24.9 | 7.0 | **47.0** | 30.1 || | FRAMES (Acc.) | 72.5 | 80.5 | 73.3 | 76.9 | - | **82.5** || | AlpacaEval2.0 (LC-winrate) | 52.0 | 51.1 | 70.0 | 57.8 | - | **87.6** || | ArenaHard (GPT-4-1106) | 85.2 | 80.4 | 85.5 | 92.0 | - | **92.3** || Code | LiveCodeBench (Pass@1-COT) | 33.8 | 34.2 | - | 53.8 | 63.4 | **65.9** || | Codeforces (Percentile) | 20.3 | 23.6 | 58.7 | 93.4 | **96.6** | 96.3 || | Codeforces (Rating) | 717 | 759 | 1134 | 1820 | **2061** | 2029 || | SWE Verified (Resolved) | **50.8** | 38.8 | 42.0 | 41.6 | 48.9 | 49.2 || | Aider-Polyglot (Acc.) | 45.3 | 16.0 | 49.6 | 32.9 | **61.7** | 53.3 || Math | AIME 2024 (Pass@1) | 16.0 | 9.3 | 39.2 | 63.6 | 79.2 | **79.8** || | MATH-500 (Pass@1) | 78.3 | 74.6 | 90.2 | 90.0 | 96.4 | **97.3** || | CNMO 2024 (Pass@1) | 13.1 | 10.8 | 43.2 | 67.6 | - | **78.8** || Chinese | CLUEWSC (EM) | 85.4 | 87.9 | 90.9 | 89.9 | - | **92.8** || | C-Eval (EM) | 76.7 | 76.0 | 86.5 | 68.9 | - | **91.8** || | C-SimpleQA (Correct) | 55.4 | 58.7 | **68.0** | 40.3 | - | 63.7 |
</div>
### Distilled Model Evaluation
<div align="center">
| Model | AIME 2024 pass@1 | AIME 2024 cons@64 | MATH-500 pass@1 | GPQA Diamond pass@1 | LiveCodeBench pass@1 | CodeForces rating ||------------------------------------------|------------------|-------------------|-----------------|----------------------|----------------------|-------------------|| GPT-4o-0513 | 9.3 | 13.4 | 74.6 | 49.9 | 32.9 | 759 || Claude-3.5-Sonnet-1022 | 16.0 | 26.7 | 78.3 | 65.0 | 38.9 | 717 || o1-mini | 63.6 | 80.0 | 90.0 | 60.0 | 53.8 | **1820** || QwQ-32B-Preview | 44.0 | 60.0 | 90.6 | 54.5 | 41.9 | 1316 || DeepSeek-R1-Distill-Qwen-1.5B | 28.9 | 52.7 | 83.9 | 33.8 | 16.9 | 954 || DeepSeek-R1-Distill-Qwen-7B | 55.5 | 83.3 | 92.8 | 49.1 | 37.6 | 1189 || DeepSeek-R1-Distill-Qwen-14B | 69.7 | 80.0 | 93.9 | 59.1 | 53.1 | 1481 || DeepSeek-R1-Distill-Qwen-32B | **72.6** | 83.3 | 94.3 | 62.1 | 57.2 | 1691 || DeepSeek-R1-Distill-Llama-8B | 50.4 | 80.0 | 89.1 | 49.0 | 39.6 | 1205 || DeepSeek-R1-Distill-Llama-70B | 70.0 | **86.7** | **94.5** | **65.2** | **57.5** | 1633 |
</div>
## 5. Chat Website & API PlatformYou can chat with DeepSeek-R1 on DeepSeek's official website: [chat.deepseek.com](https://chat.deepseek.com), and switch on the button "DeepThink"
We also provide OpenAI-Compatible API at DeepSeek Platform: [platform.deepseek.com](https://platform.deepseek.com/)
## 6. How to Run Locally
### DeepSeek-R1 Models
Please visit [DeepSeek-V3](https://github.com/deepseek-ai/DeepSeek-V3) repo for more information about running DeepSeek-R1 locally.
**NOTE: Hugging Face's Transformers has not been directly supported yet.**
### DeepSeek-R1-Distill Models
DeepSeek-R1-Distill models can be utilized in the same manner as Qwen or Llama models.
For instance, you can easily start a service using [vLLM](https://github.com/vllm-project/vllm):
```shellvllm serve deepseek-ai/DeepSeek-R1-Distill-Qwen-32B --tensor-parallel-size 2 --max-model-len 32768 --enforce-eager```
You can also easily start a service using [SGLang](https://github.com/sgl-project/sglang)
```bashpython3 -m sglang.launch_server --model deepseek-ai/DeepSeek-R1-Distill-Qwen-32B --trust-remote-code --tp 2```
### Usage Recommendations
**We recommend adhering to the following configurations when utilizing the DeepSeek-R1 series models, including benchmarking, to achieve the expected performance:**
1. Set the temperature within the range of 0.5-0.7 (0.6 is recommended) to prevent endless repetitions or incoherent outputs.2. **Avoid adding a system prompt; all instructions should be contained within the user prompt.**3. For mathematical problems, it is advisable to include a directive in your prompt such as: "Please reason step by step, and put your final answer within \boxed{}."4. When evaluating model performance, it is recommended to conduct multiple tests and average the results.
Additionally, we have observed that the DeepSeek-R1 series models tend to bypass thinking pattern (i.e., outputting "\<think\>\n\n\</think\>") when responding to certain queries, which can adversely affect the model's performance.**To ensure that the model engages in thorough reasoning, we recommend enforcing the model to initiate its response with "\<think\>\n" at the beginning of every output.**
## 7. LicenseThis code repository and the model weights are licensed under the [MIT License](https://github.com/deepseek-ai/DeepSeek-R1/blob/main/LICENSE).DeepSeek-R1 series support commercial use, allow for any modifications and derivative works, including, but not limited to, distillation for training other LLMs. Please note that:- DeepSeek-R1-Distill-Qwen-1.5B, DeepSeek-R1-Distill-Qwen-7B, DeepSeek-R1-Distill-Qwen-14B and DeepSeek-R1-Distill-Qwen-32B are derived from [Qwen-2.5 series](https://github.com/QwenLM/Qwen2.5), which are originally licensed under [Apache 2.0 License](https://huggingface.co/Qwen/Qwen2.5-1.5B/blob/main/LICENSE), and now finetuned with 800k samples curated with DeepSeek-R1.- DeepSeek-R1-Distill-Llama-8B is derived from Llama3.1-8B-Base and is originally licensed under [llama3.1 license](https://huggingface.co/meta-llama/Llama-3.1-8B/blob/main/LICENSE).- DeepSeek-R1-Distill-Llama-70B is derived from Llama3.3-70B-Instruct and is originally licensed under [llama3.3 license](https://huggingface.co/meta-llama/Llama-3.3-70B-Instruct/blob/main/LICENSE).
## 8. Citation```@misc{deepseekai2025deepseekr1incentivizingreasoningcapability, title={DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning}, author={DeepSeek-AI}, year={2025}, eprint={2501.12948}, archivePrefix={arXiv}, primaryClass={cs.CL}, url={https://arxiv.org/abs/2501.12948}, }
```
## 9. ContactIf you have any questions, please raise an issue or contact us at [service@deepseek.com](service@deepseek.com).12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667{ "architectures": [ "DeepseekV3ForCausalLM" ], "attention_bias": false, "attention_dropout": 0.0, "auto_map": { "AutoConfig": "configuration_deepseek.DeepseekV3Config", "AutoModel": "modeling_deepseek.DeepseekV3Model", "AutoModelForCausalLM": "modeling_deepseek.DeepseekV3ForCausalLM" }, "bos_token_id": 0, "eos_token_id": 1, "ep_size": 1, "first_k_dense_replace": 3, "hidden_act": "silu", "hidden_size": 7168, "initializer_range": 0.02, "intermediate_size": 18432, "kv_lora_rank": 512, "max_position_embeddings": 163840, "model_type": "deepseek_v3", "moe_intermediate_size": 2048, "moe_layer_freq": 1, "n_group": 8, "n_routed_experts": 256, "n_shared_experts": 1, "norm_topk_prob": true, "num_attention_heads": 128, "num_experts_per_tok": 8, "num_hidden_layers": 61, "num_key_value_heads": 128, "num_nextn_predict_layers": 1, "q_lora_rank": 1536, "qk_nope_head_dim": 128, "qk_rope_head_dim": 64, "quantization_config": { "activation_scheme": "dynamic", "fmt": "e4m3", "quant_method": "fp8", "weight_block_size": [ 128, 128 ] }, "rms_norm_eps": 1e-06, "rope_scaling": { "beta_fast": 32, "beta_slow": 1, "factor": 40, "mscale": 1.0, "mscale_all_dim": 1.0, "original_max_position_embeddings": 4096, "type": "yarn" }, "rope_theta": 10000, "routed_scaling_factor": 2.5, "scoring_func": "sigmoid", "tie_word_embeddings": false, "topk_group": 4, "topk_method": "noaux_tc", "torch_dtype": "bfloat16", "transformers_version": "4.46.3", "use_cache": true, "v_head_dim": 128, "vocab_size": 129280}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199from transformers.configuration_utils import PretrainedConfigfrom transformers.utils import logging
logger = logging.get_logger(__name__)
DEEPSEEK_PRETRAINED_CONFIG_ARCHIVE_MAP = {}class DeepseekV3Config(PretrainedConfig): r""" This is the configuration class to store the configuration of a [`DeepseekV3Model`]. It is used to instantiate an DeepSeek model according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yield a similar configuration to that of the DeepSeek-V3.
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the documentation from [`PretrainedConfig`] for more information.
Args: vocab_size (`int`, *optional*, defaults to 129280): Vocabulary size of the Deep model. Defines the number of different tokens that can be represented by the `inputs_ids` passed when calling [`DeepseekV3Model`] hidden_size (`int`, *optional*, defaults to 4096): Dimension of the hidden representations. intermediate_size (`int`, *optional*, defaults to 11008): Dimension of the MLP representations. moe_intermediate_size (`int`, *optional*, defaults to 1407): Dimension of the MoE representations. num_hidden_layers (`int`, *optional*, defaults to 32): Number of hidden layers in the Transformer decoder. num_nextn_predict_layers (`int`, *optional*, defaults to 1): Number of nextn predict layers in the DeepSeekV3 Model. num_attention_heads (`int`, *optional*, defaults to 32): Number of attention heads for each attention layer in the Transformer decoder. n_shared_experts (`int`, *optional*, defaults to None): Number of shared experts, None means dense model. n_routed_experts (`int`, *optional*, defaults to None): Number of routed experts, None means dense model. routed_scaling_factor (`float`, *optional*, defaults to 1.0): Scaling factor or routed experts. topk_method (`str`, *optional*, defaults to `gready`): Topk method used in routed gate. n_group (`int`, *optional*, defaults to None): Number of groups for routed experts. topk_group (`int`, *optional*, defaults to None): Number of selected groups for each token(for each token, ensuring the selected experts is only within `topk_group` groups). num_experts_per_tok (`int`, *optional*, defaults to None): Number of selected experts, None means dense model. moe_layer_freq (`int`, *optional*, defaults to 1): The frequency of the MoE layer: one expert layer for every `moe_layer_freq - 1` dense layers. first_k_dense_replace (`int`, *optional*, defaults to 0): Number of dense layers in shallow layers(embed->dense->dense->...->dense->moe->moe...->lm_head). \--k dense layers--/ norm_topk_prob (`bool`, *optional*, defaults to False): Whether to normalize the weights of the routed experts. scoring_func (`str`, *optional*, defaults to 'softmax'): Method of computing expert weights. aux_loss_alpha (`float`, *optional*, defaults to 0.001): Auxiliary loss weight coefficient. seq_aux = (`bool`, *optional*, defaults to True): Whether to compute the auxiliary loss for each individual sample. num_key_value_heads (`int`, *optional*): This is the number of key_value heads that should be used to implement Grouped Query Attention. If `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if `num_key_value_heads=1 the model will use Multi Query Attention (MQA) otherwise GQA is used. When converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed by meanpooling all the original heads within that group. For more details checkout [this paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to `num_attention_heads`. hidden_act (`str` or `function`, *optional*, defaults to `"silu"`): The non-linear activation function (function or string) in the decoder. max_position_embeddings (`int`, *optional*, defaults to 2048): The maximum sequence length that this model might ever be used with. initializer_range (`float`, *optional*, defaults to 0.02): The standard deviation of the truncated_normal_initializer for initializing all weight matrices. rms_norm_eps (`float`, *optional*, defaults to 1e-06): The epsilon used by the rms normalization layers. use_cache (`bool`, *optional*, defaults to `True`): Whether or not the model should return the last key/values attentions (not used by all models). Only relevant if `config.is_decoder=True`. pad_token_id (`int`, *optional*): Padding token id. bos_token_id (`int`, *optional*, defaults to 1): Beginning of stream token id. eos_token_id (`int`, *optional*, defaults to 2): End of stream token id. tie_word_embeddings (`bool`, *optional*, defaults to `False`): Whether to tie weight embeddings rope_theta (`float`, *optional*, defaults to 10000.0): The base period of the RoPE embeddings. rope_scaling (`Dict`, *optional*): Dictionary containing the scaling configuration for the RoPE embeddings. Currently supports two scaling strategies: linear and dynamic. Their scaling factor must be a float greater than 1. The expected format is `{"type": strategy name, "factor": scaling factor}`. When using this flag, don't update `max_position_embeddings` to the expected new maximum. attention_bias (`bool`, defaults to `False`, *optional*, defaults to `False`): Whether to use a bias in the query, key, value and output projection layers during self-attention. attention_dropout (`float`, *optional*, defaults to 0.0): The dropout ratio for the attention probabilities.
```python >>> from transformers import DeepseekV3Model, DeepseekV3Config
>>> # Initializing a Deepseek-V3 style configuration >>> configuration = DeepseekV3Config()
>>> # Accessing the model configuration >>> configuration = model.config ```"""
model_type = "deepseek_v3" keys_to_ignore_at_inference = ["past_key_values"]
def __init__( self, vocab_size=129280, hidden_size=7168, intermediate_size=18432, moe_intermediate_size = 2048, num_hidden_layers=61, num_nextn_predict_layers=1, num_attention_heads=128, num_key_value_heads=128, n_shared_experts = 1, n_routed_experts = 256, ep_size = 1, routed_scaling_factor = 2.5, kv_lora_rank = 512, q_lora_rank = 1536, qk_rope_head_dim = 64, v_head_dim = 128, qk_nope_head_dim = 128, topk_method = 'noaux_tc', n_group = 8, topk_group = 4, num_experts_per_tok = 8, moe_layer_freq = 1, first_k_dense_replace = 3, norm_topk_prob = True, scoring_func = 'sigmoid', hidden_act="silu", max_position_embeddings=4096, initializer_range=0.02, rms_norm_eps=1e-6, use_cache=True, pad_token_id=None, bos_token_id=0, eos_token_id=1, tie_word_embeddings=False, rope_theta=10000.0, rope_scaling=None, attention_bias=False, attention_dropout=0.0, **kwargs, ): self.vocab_size = vocab_size self.max_position_embeddings = max_position_embeddings self.hidden_size = hidden_size self.intermediate_size = intermediate_size self.moe_intermediate_size = moe_intermediate_size self.num_hidden_layers = num_hidden_layers self.num_nextn_predict_layers = num_nextn_predict_layers self.num_attention_heads = num_attention_heads self.n_shared_experts = n_shared_experts self.n_routed_experts = n_routed_experts self.ep_size = ep_size self.routed_scaling_factor = routed_scaling_factor self.kv_lora_rank = kv_lora_rank self.q_lora_rank = q_lora_rank self.qk_rope_head_dim = qk_rope_head_dim self.v_head_dim = v_head_dim self.qk_nope_head_dim = qk_nope_head_dim self.topk_method = topk_method self.n_group = n_group self.topk_group = topk_group self.num_experts_per_tok = num_experts_per_tok self.moe_layer_freq = moe_layer_freq self.first_k_dense_replace = first_k_dense_replace self.norm_topk_prob = norm_topk_prob self.scoring_func = scoring_func # for backward compatibility if num_key_value_heads is None: num_key_value_heads = num_attention_heads
self.num_key_value_heads = num_key_value_heads self.hidden_act = hidden_act self.initializer_range = initializer_range self.rms_norm_eps = rms_norm_eps self.use_cache = use_cache self.rope_theta = rope_theta self.rope_scaling = rope_scaling self.attention_bias = attention_bias self.attention_dropout = attention_dropout
super().__init__( pad_token_id=pad_token_id, bos_token_id=bos_token_id, eos_token_id=eos_token_id, tie_word_embeddings=tie_word_embeddings, **kwargs, )123456789{ "_from_model_config": true, "bos_token_id": 0, "eos_token_id": 1, "do_sample": true, "temperature": 0.6, "top_p": 0.95, "transformers_version": "4.39.3"}123version https://git-lfs.github.com/spec/v1oid sha256:c2388e6b127ce6664e35c5e2529c3ce4bfc99f4f7fb6fa48e92b29ed5e4922afsize 5234139343123version https://git-lfs.github.com/spec/v1oid sha256:5f450c75da7eb897b74a092eee65df8bb115fce81cccd2bbaeb220bd97197875size 4302383966123version https://git-lfs.github.com/spec/v1oid sha256:c79b3418357348d089e88f9de17ac52d7b7a1cfe5dfc7c1b2f1ac1451298b080size 4302384375123version https://git-lfs.github.com/spec/v1oid sha256:ad5ca32dcb6c50a954bbeac833f767fcfe398b0d05aea63473907322c1a5bed5size 4302349996123version https://git-lfs.github.com/spec/v1oid sha256:e06768f65df4c19a033253a1994fe7145be9ce28131398ad9f320e3d03e8ab73size 4302384154123version https://git-lfs.github.com/spec/v1oid sha256:3eb84d165db019a61e5ca4754d3c6c6aa298b88af5a7617b15b0eca42f64e14fsize 4372073602123version https://git-lfs.github.com/spec/v1oid sha256:d6f299f7b410b9a7806927b5d2d413fae1f2c1dfa340bb0037d02d220cd8c080size 4306080097123version https://git-lfs.github.com/spec/v1oid sha256:da197fe67d243284d133310255e436759ea1eff8c3f2a684da53496a76d11ce2size 4302384356123version https://git-lfs.github.com/spec/v1oid sha256:dbd2a790cc3d94aa3d13a0301e23de8bb81e0168e100650dbcac36695533e1d3size 4302350190123version https://git-lfs.github.com/spec/v1oid sha256:137f0f0407290d8d45d1a3f60c67aa10a2a5434e95d8d07eaf82df6f475d8cf8size 4302383960123version https://git-lfs.github.com/spec/v1oid sha256:47b308ea2f7f7a4a812a28c0a5c75d5f648a08b0c118bd0863fd2f7320e6bc76size 4302384375123version https://git-lfs.github.com/spec/v1oid sha256:4cda99d04536d50e067c3a2c8c9ead34d307b2002500b1a8b8c7ad4ac85a9061size 1321583941123version https://git-lfs.github.com/spec/v1oid sha256:33adbb52d544cac90603081e871ff3260ee993c479fd96194716da54cfc57040size 4302317244123version https://git-lfs.github.com/spec/v1oid sha256:05b19f1bd14644e5e6db24575322d3e74a611f26b71a8021345caf0d9b416fd9size 4302384328123version https://git-lfs.github.com/spec/v1oid sha256:0484ca365f84ed446f992e3e43eeb4e182a05c8d554be385f1e1535d4d80f4fesize 4302350218123version https://git-lfs.github.com/spec/v1oid sha256:1a70800c3373608f3b3f8dd4643c9574360896e3dd647acb39f4e794284e6ee6size 4302383932123version https://git-lfs.github.com/spec/v1oid sha256:bd5abae258a54b0b4ded4f85c272b34a05f968b32dfc46412af8f5775b95ece9size 4302384377123version https://git-lfs.github.com/spec/v1oid sha256:b5418a2987ad8d4a188592c014fbb107f7605266375c5b29d42b50d449a0a9b0size 4302350026123version https://git-lfs.github.com/spec/v1oid sha256:69bbd687eafeb7e7d7ff111af3233a10e7c74c459b6d3b466a7d93f6878d4915size 4302384124123version https://git-lfs.github.com/spec/v1oid sha256:2560e878221496c2326c0538d7898e28b30cec87c70c599b321c4292bac91fe1size 4302384377123version https://git-lfs.github.com/spec/v1oid sha256:09e6825f850ba74ac9293d8179b3e7ebe3a69a3193fb0a129bf5dcaebf0b6201size 4302350413123version https://git-lfs.github.com/spec/v1oid sha256:083a0025a915e3eb8077b24abf6d26cbbf60709f308e6eaec4a3121ab368788fsize 4302384900123version https://git-lfs.github.com/spec/v1oid sha256:a10ddf9357a7603dc603fa1bbc4e0e947637f33cb6f2bfc0725a721f93622342size 4302350808123version https://git-lfs.github.com/spec/v1oid sha256:5f13210eca8ecf63123dce2ebcc9de5833b6d31b47f85970b6e6f7f00997ef78size 4302384504123version https://git-lfs.github.com/spec/v1oid sha256:d511a1879fd6cdba6823f29af05242e3f46374eec1d957a5b4db01c5d83ebc8csize 4302384961123version https://git-lfs.github.com/spec/v1oid sha256:0c50460d2ee189e76fc3eb111ef0ecd4d28dd05b5bca619bdd122827fca31e10size 4302350620123version https://git-lfs.github.com/spec/v1oid sha256:260ad43d8099317e55c97d7931941419d04a45f2169967328dd721104f9ed63dsize 4302384692123version https://git-lfs.github.com/spec/v1oid sha256:1acbd0856de26f397bef297165e6a12d2fd419fdda8237891b0da5c43c27a2a9size 4302384963123version https://git-lfs.github.com/spec/v1oid sha256:20d3ef472a46a6c7d340476b6ac105c7502ce71d1903022502cc5069c1971792size 4302350448123version https://git-lfs.github.com/spec/v1oid sha256:ac1d12d32f3a95e111cfd09f0255ed6af2b9237187aef1dcf78230c1f637abddsize 4302384884123version https://git-lfs.github.com/spec/v1oid sha256:eace4ef31c4ff04f22501b93eb476fd8e0289c749d0dd30c9c510ec520b98055size 4302350824123version https://git-lfs.github.com/spec/v1oid sha256:ac7f5250660b596b6e3c430c9f0d3139b0e6b7aa1fc08069dc0e3966f08c92bfsize 4302384488123version https://git-lfs.github.com/spec/v1oid sha256:f71549c7a33eaacdff8a2406a82957562404548a7fe5f2130a3573b36dbddef0size 4302384963123version https://git-lfs.github.com/spec/v1oid sha256:dc52ac9cd64be1135b3ed03df71d9c63af56b62738156b95af65b3400abe781fsize 1747417474123version https://git-lfs.github.com/spec/v1oid sha256:5f4677233a2a36db63ea5fb010dc3a5ef882285f3ceb2c428ba4c1cdae9ed585size 4302317817123version https://git-lfs.github.com/spec/v1oid sha256:f0b62c567e3c9e0bcf51bcd994d0ed67d5df44c2cadcf407522e445be8ecf6b2size 4302384914123version https://git-lfs.github.com/spec/v1oid sha256:9d7c8a1c35d1df030c95186eb6acaceebabbef95374de6c8a385c4b87e1895d2size 4302350794123version https://git-lfs.github.com/spec/v1oid sha256:ea241680b9422782815a20eb1d7a99e37a65260b08a17557e946b9c20219649dsize 4302384518123version https://git-lfs.github.com/spec/v1oid sha256:6dfd35cf8163ebcdd73ee4cc6beacf011b1d00f82b842fc3d914f7230e52800bsize 4302384963123version https://git-lfs.github.com/spec/v1oid sha256:fc4c69c0e91ece15f1a1bc0bf17e1d36c514bbb138c1412a0ced41118d75a052size 4302350602123version https://git-lfs.github.com/spec/v1oid sha256:333c52631a3de667f9c4a01dd644a9520832ca4a933be7c6ddfdfe6525573c3esize 4302384710123version https://git-lfs.github.com/spec/v1oid sha256:450f75fd01ff57776f0679d9b3c819be08d7057e265d43dda2c65d4851efd89dsize 4302384963123version https://git-lfs.github.com/spec/v1oid sha256:aab6deabc7117de24a14a81aae0c5ff6e10be064913cc48b21d9a89fa511b45csize 4302350432.gitattributesAdded+35
LICENSEAdded+21
README.mdAdded+239
config.jsonAdded+67
configuration_deepseek.pyAdded+199
figures/benchmark.jpgAdded

generation_config.jsonAdded+9
model-00001-of-000163.safetensorsAdded+3
model-00002-of-000163.safetensorsAdded+3
model-00003-of-000163.safetensorsAdded+3
model-00004-of-000163.safetensorsAdded+3
model-00005-of-000163.safetensorsAdded+3
model-00006-of-000163.safetensorsAdded+3
model-00007-of-000163.safetensorsAdded+3
model-00008-of-000163.safetensorsAdded+3
model-00009-of-000163.safetensorsAdded+3
model-00010-of-000163.safetensorsAdded+3
model-00011-of-000163.safetensorsAdded+3
model-00012-of-000163.safetensorsAdded+3
model-00013-of-000163.safetensorsAdded+3
model-00014-of-000163.safetensorsAdded+3
model-00015-of-000163.safetensorsAdded+3
model-00016-of-000163.safetensorsAdded+3
model-00017-of-000163.safetensorsAdded+3
model-00018-of-000163.safetensorsAdded+3
model-00019-of-000163.safetensorsAdded+3
model-00020-of-000163.safetensorsAdded+3
model-00021-of-000163.safetensorsAdded+3
model-00022-of-000163.safetensorsAdded+3
model-00023-of-000163.safetensorsAdded+3
model-00024-of-000163.safetensorsAdded+3
model-00025-of-000163.safetensorsAdded+3
model-00026-of-000163.safetensorsAdded+3
model-00027-of-000163.safetensorsAdded+3
model-00028-of-000163.safetensorsAdded+3
model-00029-of-000163.safetensorsAdded+3
model-00030-of-000163.safetensorsAdded+3
model-00031-of-000163.safetensorsAdded+3
model-00032-of-000163.safetensorsAdded+3
model-00033-of-000163.safetensorsAdded+3
model-00034-of-000163.safetensorsAdded+3
model-00035-of-000163.safetensorsAdded+3
model-00036-of-000163.safetensorsAdded+3
model-00037-of-000163.safetensorsAdded+3
model-00038-of-000163.safetensorsAdded+3
model-00039-of-000163.safetensorsAdded+3
model-00040-of-000163.safetensorsAdded+3
model-00041-of-000163.safetensorsAdded+3
model-00042-of-000163.safetensorsAdded+3
model-00043-of-000163.safetensorsAdded+3