Text Generation
Transformers
Safetensors
English
qwen3
optd
on-policy-distillation
transition-distillation
reasoning
text-generation-inference
conversational
Instructions to use ModalityDance/OPTD-Qwen3-4B-Mid with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ModalityDance/OPTD-Qwen3-4B-Mid with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ModalityDance/OPTD-Qwen3-4B-Mid") 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-Qwen3-4B-Mid") model = AutoModelForCausalLM.from_pretrained("ModalityDance/OPTD-Qwen3-4B-Mid", 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-Qwen3-4B-Mid with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ModalityDance/OPTD-Qwen3-4B-Mid" # 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-Qwen3-4B-Mid", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ModalityDance/OPTD-Qwen3-4B-Mid
- SGLang
How to use ModalityDance/OPTD-Qwen3-4B-Mid 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-Qwen3-4B-Mid" \ --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-Qwen3-4B-Mid", "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-Qwen3-4B-Mid" \ --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-Qwen3-4B-Mid", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ModalityDance/OPTD-Qwen3-4B-Mid with Docker Model Runner:
docker model run hf.co/ModalityDance/OPTD-Qwen3-4B-Mid
Download checksums.json from ModalityDance/OPTD-Qwen3-4B-Mid: direct link, hf CLI and curl.
- Browser
- Download file 1.62 kB
-
https://huggingface.co/ModalityDance/OPTD-Qwen3-4B-Mid/resolve/main/checksums.json
- Command line
-
hf download hf://ModalityDance/OPTD-Qwen3-4B-Mid/checksums.json
-
curl -L -o checksums.json https://huggingface.co/ModalityDance/OPTD-Qwen3-4B-Mid/resolve/main/checksums.json
1.62 kB
| { | |
| "generation_config.json": { | |
| "sha256": "64d86df2173901c58389974bde21f7d2ab9eb7d79f35a337753329d39cf265c0", | |
| "bytes": 214 | |
| }, | |
| "config.json": { | |
| "sha256": "853cff73e10aa7476fe748affa533c2fbda10fafef0adc73c945f7be2494a6fa", | |
| "bytes": 1582 | |
| }, | |
| "chat_template.jinja": { | |
| "sha256": "a55ee1b1660128b7098723e0abcd92caa0788061051c62d51cbe87d9cf1974d8", | |
| "bytes": 4168 | |
| }, | |
| "tokenizer_config.json": { | |
| "sha256": "443bfa629eb16387a12edbf92a76f6a6f10b2af3b53d87ba1550adfcf45f7fa0", | |
| "bytes": 5404 | |
| }, | |
| "special_tokens_map.json": { | |
| "sha256": "76862e765266b85aa9459767e33cbaf13970f327a0e88d1c65846c2ddd3a1ecd", | |
| "bytes": 613 | |
| }, | |
| "added_tokens.json": { | |
| "sha256": "c0284b582e14987fbd3d5a2cb2bd139084371ed9acbae488829a1c900833c680", | |
| "bytes": 707 | |
| }, | |
| "vocab.json": { | |
| "sha256": "ca10d7e9fb3ed18575dd1e277a2579c16d108e32f27439684afa0e10b1440910", | |
| "bytes": 2776833 | |
| }, | |
| "merges.txt": { | |
| "sha256": "8831e4f1a044471340f7c0a83d7bd71306a5b867e95fd870f74d0c5308a904d5", | |
| "bytes": 1671853 | |
| }, | |
| "tokenizer.json": { | |
| "sha256": "aeb13307a71acd8fe81861d94ad54ab689df773318809eed3cbe794b4492dae4", | |
| "bytes": 11422654 | |
| }, | |
| "model-00001-of-00002.safetensors": { | |
| "sha256": "aa8a08708d77f343f3059737249a09e85309a07919dafc15b0cea820e1a3fb20", | |
| "bytes": 4967215360 | |
| }, | |
| "model-00002-of-00002.safetensors": { | |
| "sha256": "ef13204d93d6a85cf65526bb02c280bc88d3e0695989edbf2189bae7bb1221ca", | |
| "bytes": 3855679144 | |
| }, | |
| "model.safetensors.index.json": { | |
| "sha256": "c32d2016736271264833397e76b6e06baaa57d5756bc4621123d79e84c13af54", | |
| "bytes": 32913 | |
| } | |
| } | |