ONNX Model Zoo

webnn/DeepSeek-R1-Distill-ONNX

By webnn · ↓ 0 · ♥ 0 · Updated 2025-05-07

What's in this repo

This page lists the files in webnn/DeepSeek-R1-Distill-ONNX, including model.onnx, model_fp16.onnx.

  • 2 ONNX models (.onnx files)
  • 10 files, including 4 .json, 2 .onnx, 2 .data, 1 .md
  • Last updated 2025-05-07

ONNX files

File Size Download
model.onnx — Download
onnx/model_fp16.onnx — Download

How to use

These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.

README

DeepSeek-R1-Distill-Qwen ONNX models

https://huggingface.co/onnxruntime/DeepSeek-R1-Distill-ONNX/resolve/main/deepseek-r1-distill-qwen-1.5B/gpu/gpu-int4-rtn-block-32/

This repository hosts the optimized versions of DeepSeek-R1-Distill-Qwen-1.5B and DeepSeek-R1-Distill-Qwen-7B to accelerate inference with ONNX Runtime. Optimized models are published here in ONNX format to run with ONNX Runtime on CPU and GPU across devices, including server platforms, Windows, Linux and Mac desktops, and mobile CPUs, with the precision best suited to each of these targets.

To easily get started with the model, you can use our ONNX Runtime Generate() API. See instructions here

For CPU:

# Download the model directly using the Hugging Face CLI
huggingface-cli download onnxruntime/DeepSeek-R1-Distill-ONNX --include deepseek-r1-distill-qwen-1.5B/cpu_and_mobile/* --local-dir .

# Install the CPU package of ONNX Runtime GenAI
pip install onnxruntime-genai

# Please adjust the model directory (-m) accordingly 
curl -o https://raw.githubusercontent.com/microsoft/onnxruntime-genai/refs/heads/main/examples/python/model-chat.py
python model-chat.py -m /path/to/cpu-int4-rtn-block-32-acc-level-4/ -e cpu --chat_template "<|begin▁of▁sentence|><|User|>{input}<|Assistant|>"

For CUDA:

# Download the model directly using the Hugging Face CLI
huggingface-cli download onnxruntime/DeepSeek-R1-Distill-ONNX --include deepseek-r1-distill-qwen-1.5B/gpu/* --local-dir .

# Install the CUDA package of ONNX Runtime GenAI
pip install onnxruntime-genai-cuda

# Please adjust the model directory (-m) accordingly 
curl -o https://raw.githubusercontent.com/microsoft/onnxruntime-genai/refs/heads/main/examples/python/model-chat.py
python model-chat.py -m /path/to/gpu-int4-rtn-block-32/ -e cuda --chat_template "<|begin▁of▁sentence|><|User|>{input}<|Assistant|>"

For DirectML:

# Download the model directly using the Hugging Face CLI
huggingface-cli download onnxruntime/DeepSeek-R1-Distill-ONNX --include deepseek-r1-distill-qwen-1.5B/gpu/* --local-dir .

# Install the DirectML package of ONNX Runtime GenAI
pip install onnxruntime-genai-directml

# Please adjust the model directory (-m) accordingly 
curl -o https://raw.githubusercontent.com/microsoft/onnxruntime-genai/refs/heads/main/examples/python/model-chat.py
python model-chat.py -m /path/to/gpu-int4-rtn-block-32/ -e dml --chat_template "<|begin▁of▁sentence|><|User|>{input}<|Assistant|>"

ONNX Models

Here are some of the optimized configurations we have added:

  1. ONNX model for CPU and mobile using int4 quantization via RTN.
  2. ONNX model for GPU using int4 quantization via RTN.

Performance

ONNX enables you to run your models on-device across CPU, GPU, NPU. With ONNX, you can run your models on any machine across all silica (Qualcomm, AMD, Intel, Nvidia, etc).

See the table below for some key benchmarks for Windows GPU and CPU devices that the ONNX models were tested on.

Model Precisionl Device Type Execution Provider Device Token Generation Throughput Speed up vs base model
deepseek-ai_DeepSeek-R1-Distill-Qwen-1.5B ONNX fp16 CUDA RTX 4090 197.195 4X
deepseek-ai_DeepSeek-R1-Distill-Qwen-1.5B ONNX int4 CUDA RTX 4090 313.32 6.3X
deepseek-ai_DeepSeek-R1-Distill-Qwen-1.5B ONNX int4 CPU Intel i9 11.749 1.4x
deepseek-ai_DeepSeek-R1-Distill-Qwen-7B ONNX fp16 CUDA RTX 4090 57.316 1.3X
deepseek-ai_DeepSeek-R1-Distill-Qwen-7B ONNX int4 CUDA RTX 4090 161.00 3.7X
deepseek-ai_DeepSeek-R1-Distill-Qwen-7B ONNX int4 CPU Intel i9 3.184 20X

CPU build specs:

  • onnxruntime-genai==0.6.0-dev
  • transformers==4.46.2
  • onnxruntime==1.20.01

CUDA build specs:

  • onnxruntime-genai-cuda==0.6.0-dev
  • transformers==4.46.2
  • onnxruntime-gpu==1.20.1

Model Description

  • Developed by: ONNX Runtime
  • Model type: ONNX
  • Language(s) (NLP): Python, C, C++
  • License: MIT
  • Model Description: This is a conversion of the Deepseek R1 for ONNX Runtime inference.
  • Disclaimer: Model is only an optimization of the base model, any risk associated with the model is the responsibility of the user of the model. Please verify and test for you scenarios. There may be a slight difference in output from the base model with the optimizations applied. **

Base Model Information

See HF links DeepSeek-R1-Distill-Qwen-1.5B and DeepSeek-R1-Distill-Qwen-7B for details.

Model info

text-generation transformers
transformers onnx ONNX ONNXRuntime text-generation conversational license:mit endpoints_compatible region:us
↓ 0 ♥ 0

Created: 2025-05-07

Updated: 2025-05-07

View on Hugging Face

Files (10)

.gitattributes
README.md
genai_config.json
model.onnx ONNX
model.onnx.data
onnx/model.onnx.data
onnx/model_fp16.onnx ONNX
special_tokens_map.json
tokenizer.json
tokenizer_config.json

Related models