URSA-MATH/MMathCoT-1M
Viewer • Updated • 1.02M • 154 • 10
How to use URSA-MATH/URSA-8B with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("image-text-to-text", model="URSA-MATH/URSA-8B")
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) # Load model directly
from transformers import AutoModelForSeq2SeqLM
model = AutoModelForSeq2SeqLM.from_pretrained("URSA-MATH/URSA-8B", dtype="auto")How to use URSA-MATH/URSA-8B with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "URSA-MATH/URSA-8B"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "URSA-MATH/URSA-8B",
"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 run hf.co/URSA-MATH/URSA-8B
How to use URSA-MATH/URSA-8B with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "URSA-MATH/URSA-8B" \
--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": "URSA-MATH/URSA-8B",
"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 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 "URSA-MATH/URSA-8B" \
--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": "URSA-MATH/URSA-8B",
"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"
}
}
]
}
]
}'How to use URSA-MATH/URSA-8B with Docker Model Runner:
docker model run hf.co/URSA-MATH/URSA-8B
URSA-8B is the first small-sized MLLM specifically focused on Chain-of-thought multimodal mathematical reasoning.
from huggingface_hub import snapshot_download
repo_id = "URSA-MATH/URSA-8B"
local_dir = YOUR_LOCAL_PATH
snapshot_path = snapshot_download(
repo_id=repo_id,
local_dir=local_dir,
revision="main",
cache_dir=None,
)
We have adapted vLLM for URSA-8B. Please refer to the GitHub repository for quick inference implementation.
If you find our paper, model, or data helpful, please give this repo a star 🌟 and cite our article ✏️.
@article{luo2025ursa,
title={URSA: Understanding and Verifying Chain-of-thought Reasoning in Multimodal Mathematics},
author={Luo, Ruilin and Zheng, Zhuofan and Wang, Yifan and Yu, Yiyao and Ni, Xinzhe and Lin, Zicheng and Zeng, Jin and Yang, Yujiu},
journal={arXiv preprint arXiv:2501.04686},
year={2025}
}