--- library_name: transformers pipeline_tag: text-generation base_model: Qwen/Qwen3-4B base_model_relation: finetune language: - en tags: - optd - on-policy-distillation - transition-distillation - reasoning - text-generation-inference --- # OPTD-Qwen3-4B-Mid [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 [Qwen/Qwen3-4B](https://huggingface.co/Qwen/Qwen3-4B) with specialists in **mathematics and coding**. 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*. **Mid** identifies the placement of transition supervision during training. Mid and Late use different sets of layers; these names do not denote release versions or a quality ranking. Use **non-thinking mode** (`enable_thinking=False`) for this Qwen3-4B model, as in the paper. ## 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-Qwen3-4B-Mid" 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, enable_thinking=False ) 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-Qwen3-4B-Mid --local-dir models/optd-qwen3-4b-mid ``` Install `huggingface_hub` to use the `hf` command. To load a downloaded copy, replace `model_id` with its local directory. ## Training and release details
Configuration and file contents - Student initialization: `Qwen/Qwen3-4B`. - Training updates: 50. - Intermediate layers (zero-based): 7 / 13 / 19. - Training domains: mathematics and coding. - 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.
## 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.