Text Generation
Transformers
Safetensors
deepseek_v3
conversational
custom_code
text-generation-inference
fp8
Instructions to use deepseek-ai/DeepSeek-V3.1-Base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use deepseek-ai/DeepSeek-V3.1-Base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="deepseek-ai/DeepSeek-V3.1-Base", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-V3.1-Base", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-V3.1-Base", 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use deepseek-ai/DeepSeek-V3.1-Base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "deepseek-ai/DeepSeek-V3.1-Base" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "deepseek-ai/DeepSeek-V3.1-Base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/deepseek-ai/DeepSeek-V3.1-Base
- SGLang
How to use deepseek-ai/DeepSeek-V3.1-Base 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 "deepseek-ai/DeepSeek-V3.1-Base" \ --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": "deepseek-ai/DeepSeek-V3.1-Base", "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 "deepseek-ai/DeepSeek-V3.1-Base" \ --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": "deepseek-ai/DeepSeek-V3.1-Base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use deepseek-ai/DeepSeek-V3.1-Base with Docker Model Runner:
docker model run hf.co/deepseek-ai/DeepSeek-V3.1-Base
Update ue8m0 config & description
Browse files- README.md +8 -1
- config.json +2 -1
README.md
CHANGED
|
@@ -52,7 +52,9 @@ DeepSeek-V3.1 is a hybrid model that supports both thinking mode and non-thinkin
|
|
| 52 |
|
| 53 |
- **Higher thinking efficiency**: DeepSeek-V3.1-Think achieves comparable answer quality to DeepSeek-R1-0528, while responding more quickly.
|
| 54 |
|
| 55 |
-
DeepSeek-V3.1 is post-trained on the top of DeepSeek-V3.1-Base, which is built upon the original V3 base checkpoint through a two-phase long context extension approach, following the methodology outlined in the original DeepSeek-V3 report. We have expanded our dataset by collecting additional long documents and substantially extending both training phases. The 32K extension phase has been increased 10-fold to 630B tokens, while the 128K extension phase has been extended by 3.3x to 209B tokens.
|
|
|
|
|
|
|
| 56 |
|
| 57 |
## Model Downloads
|
| 58 |
|
|
@@ -196,6 +198,11 @@ tokenizer.apply_chat_template(messages, tokenize=False, thinking=False, add_gene
|
|
| 196 |
|
| 197 |
The model structure of DeepSeek-V3.1 is the same as DeepSeek-V3. Please visit [DeepSeek-V3](https://github.com/deepseek-ai/DeepSeek-V3) repo for more information about running this model locally.
|
| 198 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
## License
|
| 200 |
|
| 201 |
This repository and the model weights are licensed under the [MIT License](LICENSE).
|
|
|
|
| 52 |
|
| 53 |
- **Higher thinking efficiency**: DeepSeek-V3.1-Think achieves comparable answer quality to DeepSeek-R1-0528, while responding more quickly.
|
| 54 |
|
| 55 |
+
DeepSeek-V3.1 is post-trained on the top of DeepSeek-V3.1-Base, which is built upon the original V3 base checkpoint through a two-phase long context extension approach, following the methodology outlined in the original DeepSeek-V3 report. We have expanded our dataset by collecting additional long documents and substantially extending both training phases. The 32K extension phase has been increased 10-fold to 630B tokens, while the 128K extension phase has been extended by 3.3x to 209B tokens.
|
| 56 |
+
|
| 57 |
+
Additionally, DeepSeek-V3.1 is trained using the **UE8M0 FP8 scale data format on both model weights and activations** to ensure compatibility with microscaling data formats. Please refer to [DeepGEMM](https://github.com/deepseek-ai/DeepGEMM) for more details.
|
| 58 |
|
| 59 |
## Model Downloads
|
| 60 |
|
|
|
|
| 198 |
|
| 199 |
The model structure of DeepSeek-V3.1 is the same as DeepSeek-V3. Please visit [DeepSeek-V3](https://github.com/deepseek-ai/DeepSeek-V3) repo for more information about running this model locally.
|
| 200 |
|
| 201 |
+
**Usage Recommendations:**
|
| 202 |
+
|
| 203 |
+
1. **The `mlp.gate.e_score_correction_bias `parameters should be loaded and computed in FP32 precision.**
|
| 204 |
+
2. **Ensure that FP8 model weights and activations are formatted using the UE8M0 scale format.**
|
| 205 |
+
|
| 206 |
## License
|
| 207 |
|
| 208 |
This repository and the model weights are licensed under the [MIT License](LICENSE).
|
config.json
CHANGED
|
@@ -41,7 +41,8 @@
|
|
| 41 |
"weight_block_size": [
|
| 42 |
128,
|
| 43 |
128
|
| 44 |
-
]
|
|
|
|
| 45 |
},
|
| 46 |
"rms_norm_eps": 1e-06,
|
| 47 |
"rope_scaling": {
|
|
|
|
| 41 |
"weight_block_size": [
|
| 42 |
128,
|
| 43 |
128
|
| 44 |
+
],
|
| 45 |
+
"scale_fmt": "ue8m0"
|
| 46 |
},
|
| 47 |
"rms_norm_eps": 1e-06,
|
| 48 |
"rope_scaling": {
|