Instructions to use zhenliuu/K12-Reasoner-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zhenliuu/K12-Reasoner-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="zhenliuu/K12-Reasoner-4B") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("zhenliuu/K12-Reasoner-4B") model = AutoModelForMultimodalLM.from_pretrained("zhenliuu/K12-Reasoner-4B", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use zhenliuu/K12-Reasoner-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "zhenliuu/K12-Reasoner-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": "zhenliuu/K12-Reasoner-4B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/zhenliuu/K12-Reasoner-4B
- SGLang
How to use zhenliuu/K12-Reasoner-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 "zhenliuu/K12-Reasoner-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": "zhenliuu/K12-Reasoner-4B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "zhenliuu/K12-Reasoner-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": "zhenliuu/K12-Reasoner-4B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use zhenliuu/K12-Reasoner-4B with Docker Model Runner:
docker model run hf.co/zhenliuu/K12-Reasoner-4B
K12-Reasoner-4B
K12-Reasoner-4B ๆฏๅบไบ Qwen3.5-4B ่ฟ่ก DAPO ๅ่ฎญ็ป็ๅคๆจกๆๆจกๅ๏ผไฝฟ็จๆฌ้กน็ฎๆด็็ๆฐๅญฆไธ็ฉ็่ฎญ็ป้๏ผ้ขๅๅพๆ้ข็ฎ็่งฃใๅญฆ็งๆจ็ไธ็ญๆก็ๆใ
้กน็ฎไธป้กต ยท ่ฎญ็ปๆฐๆฎ ยท ่ฎญ็ปไปฃ็
ๆจกๅๆฆๅต
| ้กน็ฎ | ้ ็ฝฎ |
|---|---|
| ๅบ็กๆจกๅ | Qwen3.5-4B |
| ๅๆฐ่งๆจก | 4B ็บง |
| ่พๅ ฅ / ่พๅบ | ๆๆฌไธๅพ็ / ๆๆฌ |
| ๅ่ฎญ็ป | DAPO๏ผๅบไบ TRL |
| ่ฎญ็ปๆฐๆฎ | ๆฐๅญฆไธ็ฉ็่ฎญ็ป้๏ผ1,160 ้ข |
| ๆ้ๆ ผๅผ | BF16๏ผSafetensors |
ๅฟซ้ไฝฟ็จ
ๅฎ่ฃ
ๆฏๆๆฌๆจกๅ็ Transformers ไธ PyTorch ็ฏๅข๏ผไธ่ฝฝๆจกๅๅไฝฟ็จ้้็infer.py๏ผ
pip install "torch==2.10.0" "transformers==5.15.0" "accelerate==1.13.0" "Pillow==12.2.0"
hf download zhenliuu/K12-Reasoner-4B --local-dir K12-Reasoner-4B
python K12-Reasoner-4B/infer.py --model ./K12-Reasoner-4B \
--subject ๆฐๅญฆ --question "ๆฑๆน็จ 2x + 3 = 11 ็่งฃใ"
ๅพ็้ข้่ฟ--imageไผ ๅ
ฅๆฌๅฐๅพ็๏ผ้ขๅนฒไธ้้กน้่ฟ--questionไผ ๅ
ฅ๏ผ้ๅค--imageๅฏๆไพๅคๅผ ๅพ็๏ผ
python K12-Reasoner-4B/infer.py --model ./K12-Reasoner-4B \
--subject ็ฉ็ --image question.png --question "ๆ นๆฎๅพ็คบ๏ผๅคๆญ็ฉไฝๆๅๅๅ็ๆนๅใ"
้ป่ฎคไฝฟ็จๅๅผ CUDA GPUใBF16ไธ่ดชๅฟ่งฃ็ ๏ผๅ
ณ้ญthinking๏ผๆๅคง่พๅบ8,192 tokensใ่ๆฌๆฏๆ--device cpuไปฅๅๆฌๅฐๆจกๅ่ทฏๅพใPyTorch็CUDAๆๅปบ้ไธ่ฟ่ก็ฏๅขๅน้
ใๆจกๅไฝฟ็จๅบ็กๆถๆ็processorไธchat template๏ผ่พๅบๅ
ๅซ็ฎๆด่งฃ้ข่ฟ็จๅๆซ่กโๆ็ป็ญๆก๏ผโใ
่ฏๆต็ปๆ
ๆไปฌๅจไปฅไธๅคๆจกๆๆฐๅญฆไธ็ฉ็ๅบๅไธ๏ผๅฐ K12-Reasoner-4B ไธๅบ็กๆจกๅ Qwen3.5-4B ่ฟ่กๅฏนๆฏใๆๆ ไธบๅ็กฎ็๏ผๆๅไปฅ็พๅ็น๏ผpp๏ผ่กจ็คบใ
| ๅบๅ | ๅฏ่ฎกๅ้ขๆฐ / ๆต่ฏ้ขๆฐ | Qwen3.5-4B | K12-Reasoner-4B | ๆๅ๏ผpp๏ผ |
|---|---|---|---|---|
| OlympiadBench | 4,055 / 4,869 | 31.89% | 40.12% | +8.24 |
| MMSciBench | 710 / 1,167 | 63.24% | 69.58% | +6.34 |
| LiveK12Bench | 1,168 / 1,168 | 48.72% | 54.71% | +5.99 |
| MM-MATH | 5,881 / 5,901 | 67.40% | 71.96% | +4.56 |
| PhyX | 6,000 / 6,000 | 43.30% | 47.78% | +4.48 |
| PhysUniBench | 1,247 / 3,304 | 38.89% | 41.94% | +3.05 |
่ฏๆต่ฎพ็ฝฎ๏ผ ไธคๆจกๅไฝฟ็จ็ธๅ่พๅ ฅๆจกๆฟใ่งฃ็ ่ฎพ็ฝฎๅ่ชๅจๅคๅ็จๅบ๏ผๅ ณ้ญ thinking๏ผ้็จ่ดชๅฟ่งฃ็ ๏ผๆๅคง่พๅบ้ฟๅบฆไธบ 8,192 tokensใๅ็กฎ็ๆๅฏ่ฎกๅ้ข็ฎ่ฎก็ฎ๏ผMMSciBenchใPhysUniBench ไฝฟ็จ้ๆฉ้ข๏ผOlympiadBench ไฝฟ็จ้่ฏๆ้ขใ็ปๆๅบไบ้กน็ฎ็ปไธ่ฏๆตๅ่ฎฎใ
ๅฎๆดๆ็คบ่ฏๅ่ฎกๅๅฃๅพ่ง ่ฏๆต่ฏดๆ๏ผ่ฎญ็ป้ ็ฝฎ่ง้กน็ฎ่ฎญ็ปๆๆกฃใ
ไฝฟ็จ่ๅด
ๆจกๅ้ขๅๆ่ฒๅพๆๆจ็็ ็ฉถไธๅบ็จๅผๅใๆถๅ้่ฆๆๅญฆ็ป่ฎบๆถ๏ผๅบ็ปๅๅ่็ญๆกไธไธไธ็ฅ่ฏๅคๆ ธๆจกๅ่พๅบใ
- Downloads last month
- 10