Text Generation
Transformers
Safetensors
deepseek_v3
conversational
custom_code
text-generation-inference
fp8
Run this model with HF Jobs
Run deepseek-ai/DeepSeek-R1-Zero on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/deepseek-ai/DeepSeek-R1-Zero. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/deepseek-ai/DeepSeek-R1-Zero on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/deepseek-ai/DeepSeek-R1-Zero. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/deepseek-ai/DeepSeek-R1-Zero. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use deepseek-ai/DeepSeek-R1-Zero with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use deepseek-ai/DeepSeek-R1-Zero with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="deepseek-ai/DeepSeek-R1-Zero", 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("deepseek-ai/DeepSeek-R1-Zero", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-R1-Zero", 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 deepseek-ai/DeepSeek-R1-Zero with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "deepseek-ai/DeepSeek-R1-Zero" # 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-R1-Zero", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/deepseek-ai/DeepSeek-R1-Zero
- SGLang
How to use deepseek-ai/DeepSeek-R1-Zero 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-R1-Zero" \ --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-R1-Zero", "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-R1-Zero" \ --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-R1-Zero", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use deepseek-ai/DeepSeek-R1-Zero with Docker Model Runner:
docker model run hf.co/deepseek-ai/DeepSeek-R1-Zero
Small fix
Browse filesFiles changed (3)
8 unmodified lines910111213141516 unmodified lines3233343536373819 unmodified lines585960616263648 unmodified lines"AutoModel": "modeling_deepseek.DeepseekV3Model","AutoModelForCausalLM": "modeling_deepseek.DeepseekV3ForCausalLM"},"aux_loss_alpha": 0.001,"bos_token_id": 0,"eos_token_id": 1,"ep_size": 1,16 unmodified lines"num_hidden_layers": 61,"num_key_value_heads": 128,"num_nextn_predict_layers": 1,"pretraining_tp": 1,"q_lora_rank": 1536,"qk_nope_head_dim": 128,"qk_rope_head_dim": 64,19 unmodified lines"rope_theta": 10000,"routed_scaling_factor": 2.5,"scoring_func": "sigmoid","seq_aux": true,"tie_word_embeddings": false,"topk_group": 4,"topk_method": "noaux_tc",8 unmodified lines9101112131416 unmodified lines31323334353619 unmodified lines5657585960618 unmodified lines"AutoModel": "modeling_deepseek.DeepseekV3Model","AutoModelForCausalLM": "modeling_deepseek.DeepseekV3ForCausalLM"},"bos_token_id": 0,"eos_token_id": 1,"ep_size": 1,16 unmodified lines"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,19 unmodified lines"rope_theta": 10000,"routed_scaling_factor": 2.5,"scoring_func": "sigmoid","tie_word_embeddings": false,"topk_group": 4,"topk_method": "noaux_tc",
81 unmodified lines828384858687888990919248 unmodified lines1411421431441451461471482 unmodified lines15115215315415515615726 unmodified lines1841851861871881891901912 unmodified lines19419519619719819920081 unmodified linesBeginning of stream token id.eos_token_id (`int`, *optional*, defaults to 2):End of stream token id.pretraining_tp (`int`, *optional*, defaults to 1):Experimental feature. Tensor parallelism rank used during pretraining. Please refer to [thisdocument](https://huggingface.co/docs/transformers/parallelism) to understand more about it. This value isnecessary to ensure exact reproducibility of the pretraining results. Please refer to [thisissue](https://github.com/pytorch/pytorch/issues/76232).tie_word_embeddings (`bool`, *optional*, defaults to `False`):Whether to tie weight embeddingsrope_theta (`float`, *optional*, defaults to 10000.0):48 unmodified linesfirst_k_dense_replace = 3,norm_topk_prob = True,scoring_func = 'sigmoid',aux_loss_alpha = 0.001,seq_aux = True,hidden_act="silu",max_position_embeddings=4096,initializer_range=0.02,2 unmodified linespad_token_id=None,bos_token_id=0,eos_token_id=1,pretraining_tp=1,tie_word_embeddings=False,rope_theta=10000.0,rope_scaling=None,26 unmodified linesself.first_k_dense_replace = first_k_dense_replaceself.norm_topk_prob = norm_topk_probself.scoring_func = scoring_funcself.aux_loss_alpha = aux_loss_alphaself.seq_aux = seq_aux# for backward compatibilityif num_key_value_heads is None:num_key_value_heads = num_attention_heads2 unmodified linesself.hidden_act = hidden_actself.initializer_range = initializer_rangeself.rms_norm_eps = rms_norm_epsself.pretraining_tp = pretraining_tpself.use_cache = use_cacheself.rope_theta = rope_thetaself.rope_scaling = rope_scaling81 unmodified lines82838485868748 unmodified lines1361371381391401412 unmodified lines14414514614714814926 unmodified lines1761771781791801812 unmodified lines18418518618718818981 unmodified linesBeginning 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 embeddingsrope_theta (`float`, *optional*, defaults to 10000.0):48 unmodified linesfirst_k_dense_replace = 3,norm_topk_prob = True,scoring_func = 'sigmoid',hidden_act="silu",max_position_embeddings=4096,initializer_range=0.02,2 unmodified linespad_token_id=None,bos_token_id=0,eos_token_id=1,tie_word_embeddings=False,rope_theta=10000.0,rope_scaling=None,26 unmodified linesself.first_k_dense_replace = first_k_dense_replaceself.norm_topk_prob = norm_topk_probself.scoring_func = scoring_func# for backward compatibilityif num_key_value_heads is None:num_key_value_heads = num_attention_heads2 unmodified linesself.hidden_act = hidden_actself.initializer_range = initializer_rangeself.rms_norm_eps = rms_norm_epsself.use_cache = use_cacheself.rope_theta = rope_thetaself.rope_scaling = rope_scaling
397 unmodified lines39839940040140240340450 unmodified lines455456457458459460461397 unmodified linesself.n_routed_experts = config.n_routed_expertsself.routed_scaling_factor = config.routed_scaling_factorself.scoring_func = config.scoring_funcself.seq_aux = config.seq_auxself.topk_method = config.topk_methodself.n_group = config.n_groupself.topk_group = config.topk_group50 unmodified lines).reshape(bsz * seq_len, -1)) # [n, e]tmp_scores = scores_for_choice.masked_fill(~score_mask.bool(), 0.0) # [n, e]_, topk_idx = torch.topk(tmp_scores, k=self.top_k, dim=-1, sorted=False)397 unmodified lines39839940040140240350 unmodified lines454455456457458459460397 unmodified linesself.n_routed_experts = config.n_routed_expertsself.routed_scaling_factor = config.routed_scaling_factorself.scoring_func = config.scoring_funcself.topk_method = config.topk_methodself.n_group = config.n_groupself.topk_group = config.topk_group50 unmodified lines).reshape(bsz * seq_len, -1)) # [n, e]tmp_scores = scores_for_choice.masked_fill(~score_mask.bool(), float("-inf")) # [n, e]_, topk_idx = torch.topk(tmp_scores, k=self.top_k, dim=-1, sorted=False)
config.json-3
configuration_deepseek.py-11
modeling_deepseek.py+1-2