Instructions to use deepseek-ai/DeepSeek-R1-Distill-Qwen-14B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use deepseek-ai/DeepSeek-R1-Distill-Qwen-14B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="deepseek-ai/DeepSeek-R1-Distill-Qwen-14B", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-R1-Distill-Qwen-14B") model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-R1-Distill-Qwen-14B", 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]:])) - Inference
- HuggingChat
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use deepseek-ai/DeepSeek-R1-Distill-Qwen-14B 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-Distill-Qwen-14B" # 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-Distill-Qwen-14B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-14B
- SGLang
How to use deepseek-ai/DeepSeek-R1-Distill-Qwen-14B 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-Distill-Qwen-14B" \ --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-Distill-Qwen-14B", "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-Distill-Qwen-14B" \ --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-Distill-Qwen-14B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use deepseek-ai/DeepSeek-R1-Distill-Qwen-14B with Docker Model Runner:
docker model run hf.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-14B
Disable Think text
Hi, I am trying to use this model for a special case, is there any way to disable "Think" text generation, and will it result in faster inference. Thanks
i dont think its possible to disable thinking generation as its the way that the model work, they spit out first and then from there it will output the actual respond that you use
Include an empty CoT in the prompt for text generation, like so:
<| User |>Hello!<| Assistant |><think>\n\n</think>\n\n
Hello, I have a question. Why not place <think>\n\n</think> before <| Assistant |>, like this:
<| User |>Hello!<think>\n\n</think>\n\n<| Assistant |>
I'm curious about the difference between these two approaches, but I'm not sure if there are any official recommendations or references on this. Thank you!
The assistant uses the think-tags, not the user. The <| Assistant |> token acts as a label for conversation turns in the text generation, so that the model understands who is currently replying to whom.
According to the chat template, <think> and </think> belong in the assistant's domain. This is because the model was trained using reinforcement learning (RL) and one of the rewarded factors was its use of reasoning between think-tags during its conversation turns.
When an empty CoT is included in the prompt for text generation...
<| User |>Hello!<| Assistant |><think>\n\n</think>\n\n
...you're actually mimicking part of the model's response.
Now, the model is tricked into believing that it had already typed its own CoT, and it will continue therefrom. This prevents the model from generating a new CoT because it sees that one is already present, and no extra tokens are wasted.
Note: Wrappers like Ollama and LM Studio may not allow you to generate from the raw chat template, as these tokens are automatically added by the software. For this to work, you may have to use your own Python (of which examples are present on the model card), or understand advanced features in your application of choice.
Has anyone even thought of using the normal Qwen 14B?