-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Create DeepSeek-R1-Distill-Qwen-python.md #23709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1792401
Create DeepSeek-R1-Distill-Qwen-python.md
parinitarahi 46463eb
Update docs/genai/tutorials/DeepSeek-R1-Distill-Qwen-python.md
parinitarahi 882813c
Add metadata and title to tutorial
parinitarahi 818fc64
Rename and update DeepSeek-R1-Distill tutorial
parinitarahi 80334f5
Clarify GPU chat inference instructions
parinitarahi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| ## 1. Pre-Requisites: Make a virtual environment and install ONNX Runtime GenAI | ||
| ```bash | ||
| # Installing onnxruntime-genai, olive, and dependencies for CPU | ||
| python -m venv .venv && source .venv/bin/activate | ||
| pip install requests numpy --pre onnxruntime-genai olive-ai" | ||
| ``` | ||
|
|
||
| ```bash | ||
| # Installing onnxruntime-genai, olive, and dependencies for CUDA GPU | ||
| python -m venv .venv && source .venv/bin/activate | ||
| pip install requests numpy --pre onnxruntime-genai-cuda "olive-ai[gpu]" | ||
| ``` | ||
|
|
||
| ## 2. Acquire model | ||
|
|
||
| Choose your model and convert to ONNX. Note that many LLMs work, so feel free to try with other models too: | ||
|
|
||
| ```bash | ||
| # Using Olive auto-opt to pull a huggingface model, optimize for CPU, and quantize to INT4 using RTN. | ||
| olive auto-opt --model_name_or_path deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B --output_path ./deepseek-r1-distill-qwen-1.5B --device cpu --provider CPUExecutionProvider --precision int4 --use_model_builder --log_level 1 | ||
| ``` | ||
|
|
||
| ```bash | ||
| # Using Olive auto-opt to pull a huggingface model, optimize for CUDA GPUs, and quantize to INT4 using RTN. | ||
| olive auto-opt --model_name_or_path deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B --output_path ./deepseek-r1-distill-qwen-1.5B --device gpu --provider CUDAExecutionProvider --precision int4 --use_model_builder --log_level 1 | ||
| ``` | ||
|
|
||
| OR download directly using the Huggingface CLI: | ||
|
|
||
| ```bash | ||
| # Download the model directly using the huggingface cli | ||
| huggingface-cli download onnxruntime/DeepSeek-R1-Distill-ONNX --include 'deepseek-r1-distill-qwen-1.5B/*' --local-dir . | ||
| ``` | ||
|
|
||
| ## 3. Play with your model on device! | ||
| ```bash | ||
| # CPU Chat inference. If you pulled the model from huggingface, 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 deepseek-r1-distill-qwen-1.5B/model -e cpu --chat_template "<|begin▁of▁sentence|><|User|>{input}<|Assistant|>" | ||
| ``` | ||
|
|
||
| ```bash | ||
| # GPU Chat inference. If you pulled the model from huggingface, 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 deepseek-r1-distill-qwen-1.5B/model -e cuda --chat_template "<|begin▁of▁sentence|><|User|>{input}<|Assistant|>" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.