Text Generation
Transformers
Safetensors
English
qwen2
optd
on-policy-distillation
transition-distillation
reasoning
text-generation-inference
conversational
Instructions to use ModalityDance/OPTD-DeepSeek-R1-Distill-Qwen-1.5B-ThreeDomain with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ModalityDance/OPTD-DeepSeek-R1-Distill-Qwen-1.5B-ThreeDomain with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ModalityDance/OPTD-DeepSeek-R1-Distill-Qwen-1.5B-ThreeDomain") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ModalityDance/OPTD-DeepSeek-R1-Distill-Qwen-1.5B-ThreeDomain") model = AutoModelForCausalLM.from_pretrained("ModalityDance/OPTD-DeepSeek-R1-Distill-Qwen-1.5B-ThreeDomain", 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ModalityDance/OPTD-DeepSeek-R1-Distill-Qwen-1.5B-ThreeDomain with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ModalityDance/OPTD-DeepSeek-R1-Distill-Qwen-1.5B-ThreeDomain" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ModalityDance/OPTD-DeepSeek-R1-Distill-Qwen-1.5B-ThreeDomain", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ModalityDance/OPTD-DeepSeek-R1-Distill-Qwen-1.5B-ThreeDomain
- SGLang
How to use ModalityDance/OPTD-DeepSeek-R1-Distill-Qwen-1.5B-ThreeDomain 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 "ModalityDance/OPTD-DeepSeek-R1-Distill-Qwen-1.5B-ThreeDomain" \ --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": "ModalityDance/OPTD-DeepSeek-R1-Distill-Qwen-1.5B-ThreeDomain", "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 "ModalityDance/OPTD-DeepSeek-R1-Distill-Qwen-1.5B-ThreeDomain" \ --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": "ModalityDance/OPTD-DeepSeek-R1-Distill-Qwen-1.5B-ThreeDomain", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ModalityDance/OPTD-DeepSeek-R1-Distill-Qwen-1.5B-ThreeDomain with Docker Model Runner:
docker model run hf.co/ModalityDance/OPTD-DeepSeek-R1-Distill-Qwen-1.5B-ThreeDomain
|
Download README.md from ModalityDance/OPTD-DeepSeek-R1-Distill-Qwen-1.5B-ThreeDomain: direct link, hf CLI and curl.
- Browser
- Download file 4.17 kB
-
https://huggingface.co/ModalityDance/OPTD-DeepSeek-R1-Distill-Qwen-1.5B-ThreeDomain/resolve/main/README.md
- Command line
-
hf download hf://ModalityDance/OPTD-DeepSeek-R1-Distill-Qwen-1.5B-ThreeDomain/README.md
-
curl -L -o README.md https://huggingface.co/ModalityDance/OPTD-DeepSeek-R1-Distill-Qwen-1.5B-ThreeDomain/resolve/main/README.md
4.17 kB
| library_name: transformers | |
| pipeline_tag: text-generation | |
| base_model: deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B | |
| base_model_relation: finetune | |
| language: | |
| - en | |
| tags: | |
| - optd | |
| - on-policy-distillation | |
| - transition-distillation | |
| - reasoning | |
| - text-generation-inference | |
| # OPTD-DeepSeek-R1-Distill-Qwen-1.5B-ThreeDomain | |
| [arXiv](https://arxiv.org/abs/2610.28048) · [Hugging Face Paper](https://huggingface.co/papers/2610.28048) · [All OPTD models](https://huggingface.co/collections/ModalityDance/optd) | |
| An OPTD model trained from [deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B) with specialists in **mathematics, coding, and instruction following**. This is a complete model that can be used directly for text generation. | |
| OPTD teaches a student both the teacher’s final prediction and how its predictions change across layers, using responses generated by the student. This checkpoint accompanies *On-Policy Transition Distillation*. | |
| **Three-domain** adds an instruction-following specialist to the math and coding teachers. | |
| Use the model’s **native reasoning chat template**, supplied with its tokenizer. | |
| ## Quick start | |
| Install PyTorch for your hardware, Transformers, and Accelerate: | |
| ```bash | |
| python -m pip install torch transformers accelerate | |
| ``` | |
| The example below uses BF16. Teacher models and the OPTD training framework are not required for inference. | |
| ```python | |
| import torch | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| model_id = "ModalityDance/OPTD-DeepSeek-R1-Distill-Qwen-1.5B-ThreeDomain" | |
| tokenizer = AutoTokenizer.from_pretrained(model_id) | |
| model = AutoModelForCausalLM.from_pretrained( | |
| model_id, torch_dtype=torch.bfloat16, device_map="auto" | |
| ) | |
| messages = [{"role": "user", "content": "Solve 2x + 5 = 17."}] | |
| text = tokenizer.apply_chat_template( | |
| messages, tokenize=False, add_generation_prompt=True | |
| ) | |
| inputs = tokenizer(text, add_special_tokens=False, return_tensors="pt").to(model.device) | |
| with torch.inference_mode(): | |
| output = model.generate( | |
| **inputs, max_new_tokens=1024, do_sample=True, temperature=0.7, top_p=0.95 | |
| ) | |
| response = output[0, inputs.input_ids.shape[-1]:] | |
| print(tokenizer.decode(response, skip_special_tokens=True)) | |
| ``` | |
| The short generation limit is for the example. Paper evaluation uses benchmark-specific token limits and sample counts. | |
| ## Download | |
| ```bash | |
| hf download ModalityDance/OPTD-DeepSeek-R1-Distill-Qwen-1.5B-ThreeDomain --local-dir models/optd-deepseek-r1-distill-qwen-1.5b-threedomain | |
| ``` | |
| Install `huggingface_hub` to use the `hf` command. To load a downloaded copy, replace `model_id` with its local directory. | |
| ## Training and release details | |
| <details> | |
| <summary>Configuration and file contents</summary> | |
| - Student initialization: `deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B`. | |
| - Training updates: 150. | |
| - Intermediate layers (zero-based): 11 / 15 / 19. | |
| - Training domains: mathematics, coding, and instruction following. | |
| - Full BF16 safetensors weights, tokenizer, and generation configuration are included. | |
| - `training_metadata.json` records the training configuration; `checksums.json` records checkpoint/tokenizer SHA256 hashes. | |
| - Optimizer state is not included. | |
| </details> | |
| ## Evaluation | |
| Compare this checkpoint using the paper’s prompt mode, dataset revisions, sample counts, and graders. The example above demonstrates inference rather than reproducing benchmark scores. Generated answers can be incorrect; execute generated code only in an isolated sandbox. | |
| ## Citation | |
| ```bibtex | |
| @misc{optd2026, | |
| title = {On-Policy Transition Distillation}, | |
| author = {You, Runyang and Li, Yongqi and Yu, Tiezheng and Li, Wenjie}, | |
| year = {2026}, | |
| eprint = {2610.28048}, | |
| archivePrefix = {arXiv}, | |
| primaryClass = {cs.CL}, | |
| url = {https://arxiv.org/abs/2610.28048} | |
| } | |
| ``` | |
| ## License and attribution | |
| The underlying student and specialist models retain their respective upstream license terms. Consult the linked base model's license and notices before redistribution or deployment. No new license grant for upstream model weights is implied by this model card. | |