Instructions to use mlx-community/DeepSeek-R1-Distill-Qwen-14B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mlx-community/DeepSeek-R1-Distill-Qwen-14B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mlx-community/DeepSeek-R1-Distill-Qwen-14B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("mlx-community/DeepSeek-R1-Distill-Qwen-14B") model = AutoModelForCausalLM.from_pretrained("mlx-community/DeepSeek-R1-Distill-Qwen-14B") 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]:])) - MLX
How to use mlx-community/DeepSeek-R1-Distill-Qwen-14B with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("mlx-community/DeepSeek-R1-Distill-Qwen-14B") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- LM Studio
- vLLM
How to use mlx-community/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 "mlx-community/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": "mlx-community/DeepSeek-R1-Distill-Qwen-14B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/mlx-community/DeepSeek-R1-Distill-Qwen-14B
- SGLang
How to use mlx-community/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 "mlx-community/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": "mlx-community/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 "mlx-community/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": "mlx-community/DeepSeek-R1-Distill-Qwen-14B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - MLX LM
How to use mlx-community/DeepSeek-R1-Distill-Qwen-14B with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "mlx-community/DeepSeek-R1-Distill-Qwen-14B"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "mlx-community/DeepSeek-R1-Distill-Qwen-14B" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mlx-community/DeepSeek-R1-Distill-Qwen-14B", "messages": [ {"role": "user", "content": "Hello"} ] }' - Docker Model Runner
How to use mlx-community/DeepSeek-R1-Distill-Qwen-14B with Docker Model Runner:
docker model run hf.co/mlx-community/DeepSeek-R1-Distill-Qwen-14B
[WIP] Upload folder using huggingface_hub (multi-commit e44f82b7022bec4af0ab884b8ad3d54f880c21f62bde764d1e1e2c7aa7ef433c)
Upload folder using huggingface_hub
Multi commit ID: e44f82b7022bec4af0ab884b8ad3d54f880c21f62bde764d1e1e2c7aa7ef433c
Scheduled commits:
- Upload 1 file(s) totalling 5.4G (f4a6896b4b791b0755298d0b8a1329123fe0fef3180a406d86c2bbcfaf09d817)
- Upload 1 file(s) totalling 5.3G (32df25afe61b2a202a1261d8612808b9b4fdce97998c6c2408c5ac1a249f166b)
- Upload 1 file(s) totalling 5.3G (e2b46f41ba802fd153a5455679a8f4e25541a381f0bc004bbef99416a8d35a0a)
- Upload 1 file(s) totalling 5.4G (a7438e97e18e0b76867d5dda79c6c9b86432ddeced3d105a324cd09371651e00)
- Upload 1 file(s) totalling 5.4G (5aa71867411416a5fffdd4f7d984d38a586d13432efc7384e8b4d95de20d043a)
- Upload 1 file(s) totalling 5.4G (64154a47645c220a7c0d3281f9d19f23ac349cd030a360a48489afd3e2781e79)
- Upload 1 file(s) totalling 2.4G (9fd475030f1f64821f04fb990f5082410704a2e5ffb6793729164ba78fc2a5a1)
- Upload 1 file(s) totalling 5.2G (04ee2b467e5b3db34e6f6b33df5d229ec51840a0c771be6f571c0304a38a6a52)
- Upload 1 file(s) totalling 5.4G (be60e00c78367a9ac7e20ffb3aed5da445cbd8198cb43861d50c13d5df9b6f07)
- Upload 1 file(s) totalling 2.9G (83e45ee71c3e8f3aed5a4c0e0cebea5a82cc54393dfa5a105393c83791dc0deb)
- Upload 6 file(s) totalling 11.6M (67893bf47e2c09b860cba6e4a36e0c68a096e45899f29fd46f91987b02ff209a)
This is a PR opened using the huggingface_hub library in the context of a multi-commit. PR can be commented as a usual PR. However, please be aware that manually updating the PR description, changing the PR status, or pushing new commits, is not recommended as it might corrupt the commit process. Learn more about multi-commits in this guide.