Text Generation
Transformers
Safetensors
a2d-qwen3
fill-mask
opdlm
block-diffusion
diffusion-language-model
math
qwen3
conversational
Instructions to use divelab/OPDLM-MATH-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use divelab/OPDLM-MATH-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="divelab/OPDLM-MATH-4B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelWithLMHead model = AutoModelWithLMHead.from_pretrained("divelab/OPDLM-MATH-4B", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use divelab/OPDLM-MATH-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "divelab/OPDLM-MATH-4B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "divelab/OPDLM-MATH-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/divelab/OPDLM-MATH-4B
- SGLang
How to use divelab/OPDLM-MATH-4B 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 "divelab/OPDLM-MATH-4B" \ --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": "divelab/OPDLM-MATH-4B", "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 "divelab/OPDLM-MATH-4B" \ --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": "divelab/OPDLM-MATH-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use divelab/OPDLM-MATH-4B with Docker Model Runner:
docker model run hf.co/divelab/OPDLM-MATH-4B
| license: apache-2.0 | |
| library_name: transformers | |
| pipeline_tag: text-generation | |
| tags: | |
| - opdlm | |
| - block-diffusion | |
| - diffusion-language-model | |
| - math | |
| - qwen3 | |
| base_model: Qwen/Qwen3-4B | |
| # OPDLM-MATH-4B | |
| **OPDLM-MATH-4B** is an On-Policy Distillation Language Model (OPDLM) — a block-diffusion language model (block size 4, 4 denoising steps per block) post-trained for mathematical reasoning. It is built on a block-diffusion adaptation of **Qwen/Qwen3-4B** (architecture `a2d-qwen3`). | |
| This is the **base (non-thinking)** variant: short-context (2k) math post-training, no explicit chain-of-thought thinking block. ArXiv report: arxiv.org/abs/2606.06712 | |
| arXiv report: arxiv.org/abs/2606.06712 | |
| ## Usage | |
| This model uses custom modeling code; load with `trust_remote_code=True`. Generation is block-diffusion (non–left-to-right), so use the project's inference utilities (block_size=4, denoising_steps_per_block=4) rather than vanilla `model.generate`. | |
| ```python | |
| from transformers import AutoModel, AutoTokenizer | |
| tok = AutoTokenizer.from_pretrained("divelab/OPDLM-MATH-4B", trust_remote_code=True) | |
| model = AutoModel.from_pretrained("divelab/OPDLM-MATH-4B", trust_remote_code=True) | |
| ``` | |