Text Generation
Transformers
Safetensors
qwen3
math
reasoning
sft
llama-factory
conversational
text-generation-inference
Instructions to use modrill/math-think-s1-qwen3-4b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use modrill/math-think-s1-qwen3-4b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="modrill/math-think-s1-qwen3-4b") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("modrill/math-think-s1-qwen3-4b") model = AutoModelForMultimodalLM.from_pretrained("modrill/math-think-s1-qwen3-4b") 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use modrill/math-think-s1-qwen3-4b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "modrill/math-think-s1-qwen3-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": "modrill/math-think-s1-qwen3-4b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/modrill/math-think-s1-qwen3-4b
- SGLang
How to use modrill/math-think-s1-qwen3-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 "modrill/math-think-s1-qwen3-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": "modrill/math-think-s1-qwen3-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 "modrill/math-think-s1-qwen3-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": "modrill/math-think-s1-qwen3-4b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use modrill/math-think-s1-qwen3-4b with Docker Model Runner:
docker model run hf.co/modrill/math-think-s1-qwen3-4b
math_think_s1
Full-parameter SFT of Qwen3-4B-Base for math reasoning with explicit thinking blocks (qwen3 template + enable_thinking: true).
Base model
Training data
- Dataset:
math_think_s1— 75,905 ShareGPT samples - Source: qihoo360/Light-R1-SFTData (
stage1-76k.json) - Decontamination: MinHash + numeric normalization vs AIME/MATH eval prompts (1 sample removed)
Training recipe
| Item | Value |
|---|---|
| Framework | LLaMA-Factory |
| Method | Full SFT, DeepSpeed ZeRO-3 |
| Template | qwen3 (reasoning / thinking) |
| Cutoff | 32768 |
| Packing | true |
| Epochs | 4 |
| LR | 1e-5 (cosine, warmup 10%) |
| Batch | 1 × 16 grad accum × 4 GPUs = 64 |
| Steps | 944 |
| Train loss | 0.6066 |
| Runtime | ~39.3 h |
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "YOUR_HF_USERNAME/math-think-s1-qwen3-4b" # replace after upload
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype="auto", device_map="auto")
messages = [{"role": "user", "content": "Find the sum of all positive integers n such that n^2 + 12n - 2007 is a perfect square."}]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, enable_thinking=True)
Files
Release tarball includes: model.safetensors, config.json, generation_config.json, tokenizer files, chat_template.jinja, README.md, train_results.json, trainer_log.jsonl, MANIFEST.txt.
- Downloads last month
- 16
Model tree for modrill/math-think-s1-qwen3-4b
Base model
Qwen/Qwen3-4B-Base