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)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelWithLMHead model = AutoModelWithLMHead.from_pretrained("divelab/OPDLM-MATH-4B", device_map="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
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
library_name: transformers
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
tags:
|
| 6 |
+
- opdlm
|
| 7 |
+
- block-diffusion
|
| 8 |
+
- diffusion-language-model
|
| 9 |
+
- math
|
| 10 |
+
- qwen3
|
| 11 |
+
base_model: Qwen/Qwen3-4B
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# OPDLM-MATH-4B
|
| 15 |
+
|
| 16 |
+
**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`).
|
| 17 |
+
|
| 18 |
+
This is the **base (non-thinking)** variant: short-context (2k) math post-training, no explicit chain-of-thought thinking block.
|
| 19 |
+
|
| 20 |
+
## Evaluation (greedy decoding)
|
| 21 |
+
|
| 22 |
+
| Benchmark | Accuracy |
|
| 23 |
+
|---|---|
|
| 24 |
+
| AIME2024 (32-seed mean) | 0.1292 (±0.037) |
|
| 25 |
+
|
| 26 |
+
AIME2024 numbers are the mean over 32 random seeds (greedy is deterministic in principle, but the vLLM/JetEngine inference stack is not bit-for-bit reproducible).
|
| 27 |
+
|
| 28 |
+
## Usage
|
| 29 |
+
|
| 30 |
+
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`.
|
| 31 |
+
|
| 32 |
+
```python
|
| 33 |
+
from transformers import AutoModel, AutoTokenizer
|
| 34 |
+
tok = AutoTokenizer.from_pretrained("divelab/OPDLM-MATH-4B", trust_remote_code=True)
|
| 35 |
+
model = AutoModel.from_pretrained("divelab/OPDLM-MATH-4B", trust_remote_code=True)
|
| 36 |
+
```
|