Instructions to use deepseek-ai/deepseek-moe-16b-chat with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use deepseek-ai/deepseek-moe-16b-chat with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="deepseek-ai/deepseek-moe-16b-chat", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("deepseek-ai/deepseek-moe-16b-chat", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use deepseek-ai/deepseek-moe-16b-chat with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "deepseek-ai/deepseek-moe-16b-chat" # 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-moe-16b-chat", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/deepseek-ai/deepseek-moe-16b-chat
- SGLang
How to use deepseek-ai/deepseek-moe-16b-chat 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-moe-16b-chat" \ --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-moe-16b-chat", "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-moe-16b-chat" \ --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-moe-16b-chat", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use deepseek-ai/deepseek-moe-16b-chat with Docker Model Runner:
docker model run hf.co/deepseek-ai/deepseek-moe-16b-chat
add chat_template in tokenizer_config.json
Browse filesI think you forgot to add chat_template in tokenizer_config.json.
I picked chat_template from deepseek-llm-67b-chat
The response looks good.
```
<|begin▁of▁sentence|>User: hello
Assistant: Hello! How can I assist you today?<|end▁of▁sentence|>User: who are you?
Assistant: I am an artificial intelligence language model developed by OpenAI. I am designed to assist with a wide range of tasks, including answering questions and providing information on a variety of topics. How can I assist you today?<|end▁of▁sentence|>User: tell me a joke?
Assistant: Sure! Here's a joke for you:
Why don't scientists trust atoms?
Because they make up everything!<|end▁of▁sentence|>User: one more
Assistant:Sure! Here's another joke for you:
Why don't some couples go to the gym?
Because some relationships don't work out!
```
- tokenizer_config.json +2 -1
|
@@ -30,5 +30,6 @@
|
|
| 30 |
},
|
| 31 |
"sp_model_kwargs": {},
|
| 32 |
"unk_token": null,
|
|
|
|
| 33 |
"tokenizer_class": "LlamaTokenizerFast"
|
| 34 |
-
}
|
|
|
|
| 30 |
},
|
| 31 |
"sp_model_kwargs": {},
|
| 32 |
"unk_token": null,
|
| 33 |
+
"chat_template": "{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{{ bos_token }}{% for message in messages %}{% if message['role'] == 'user' %}{{ 'User: ' + message['content'] + '\n\n' }}{% elif message['role'] == 'assistant' %}{{ 'Assistant: ' + message['content'] + eos_token }}{% elif message['role'] == 'system' %}{{ message['content'] + '\n\n' }}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ 'Assistant:' }}{% endif %}",
|
| 34 |
"tokenizer_class": "LlamaTokenizerFast"
|
| 35 |
+
}
|