Instructions to use internlm/Spatial-SSRL-Qwen3VL-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use internlm/Spatial-SSRL-Qwen3VL-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="internlm/Spatial-SSRL-Qwen3VL-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)# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("internlm/Spatial-SSRL-Qwen3VL-4B") model = AutoModelForImageTextToText.from_pretrained("internlm/Spatial-SSRL-Qwen3VL-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?"} ] }, ] 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=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use internlm/Spatial-SSRL-Qwen3VL-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "internlm/Spatial-SSRL-Qwen3VL-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": "internlm/Spatial-SSRL-Qwen3VL-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/internlm/Spatial-SSRL-Qwen3VL-4B
- SGLang
How to use internlm/Spatial-SSRL-Qwen3VL-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 "internlm/Spatial-SSRL-Qwen3VL-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": "internlm/Spatial-SSRL-Qwen3VL-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 "internlm/Spatial-SSRL-Qwen3VL-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": "internlm/Spatial-SSRL-Qwen3VL-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 internlm/Spatial-SSRL-Qwen3VL-4B with Docker Model Runner:
docker model run hf.co/internlm/Spatial-SSRL-Qwen3VL-4B
# Load model directly
from transformers import AutoProcessor, AutoModelForImageTextToText
processor = AutoProcessor.from_pretrained("internlm/Spatial-SSRL-Qwen3VL-4B")
model = AutoModelForImageTextToText.from_pretrained("internlm/Spatial-SSRL-Qwen3VL-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?"}
]
},
]
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=40)
print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:]))Spatial-SSRL-Qwen3VL-4B
📖Paper| 🏠Github |🤗Spatial-SSRL-7B Model | 🤗Spatial-SSRL-3B Model | 🤗Spatial-SSRL-Qwen3VL-4B Model | 🤗Spatial-SSRL-81k Dataset | 📰Daily Paper
Spatial-SSRL-Qwen3VL-4B is a large vision-language model targeting spatial understanding, built on the base of Qwen3-VL-4B-Instruct. It's optimized by applying Spatial-SSRL, a lightweight self-supervised reinforcement learning paradigm which can scale RLVR efficiently. The model demonstrates strong spatial intelligence while preserving the original general visual capabilities of the base model.
📢 News
- 🚀 [2026/04/05] We have released the training code of Spatial-SSRL.
- 🚀 [2026/02/25] We have released the 🤗Spatial-SSRL-3B Model, initialized from Qwen2.5-VL-3B-Instruct.
- 🚀 [2026/02/21] Our work has been accepted by CVPR 2026.
- 🚀 [2025/11/24] We have released the 🤗Spatial-SSRL-Qwen3VL-4B Model, initialized from Qwen3-VL-4B-Instruct.
- 🚀 [2025/11/03] Now you can try out Spatial-SSRL-7B on 🤗Spatial-SSRL Space.
- 🚀 [2025/11/03] We have released the 🤗Spatial-SSRL-7B Model, and 🤗Spatial-SSRL-81k Dataset.
- 🚀 [2025/11/02] We have released the 🏠Spatial-SSRL Repository.
🌈 Overview
We are thrilled to introduce Spatial-SSRL, a novel self-supervised RL paradigm aimed at enhancing LVLM spatial understanding. By optimizing Qwen2.5-VL-7B with Spatial-SSRL, the model exhibits stronger spatial intelligence across seven spatial understanding benchmarks in both image and video settings.
💡 Highlights
- 🔥 Highly Scalable: Spatial-SSRL uses ordinary raw RGB and RGB-D images instead of richly-annotated public datasets or manual labels for data curation, making it highly scalable.
- 🔥 Cost-effective: Avoiding the need for human labels or API calls for general LVLMs throughout the entire pipeline endows Spatial-SSRL with cost-effectiveness.
- 🔥 Lightweight: Prior approaches for spatial understanding heavily rely on annotation of external tools, incurring inherent errors in training data and additional cost. In constrast, Spatial-SSRL is completely tool-free and can easily be extended to more self-supervised tasks.
- 🔥 Naturally Verifiable: Intrinsic supervisory signals determined by pretext objectives are naturally verifiable, aligning Spatial-SSRL well with the RLVR paradigm.
📊 Results
We train Qwen3-VL-4B-Instruct with our Spatial-SSRL paradigm and the average experimental results on spatial understanding and general VQA benchmarks are shown below.
🛠️ Usage
Here we provide a code snippet for you to start a simple trial of Spatial-SSRL-Qwen3VL-4B on your own device. You can download the model from 🤗Spatial-SSRL-Qwen3VL-4B Model before your trial!
from transformers import AutoProcessor, AutoModelForImageTextToText #transformers==4.57.1
from qwen_vl_utils import process_vision_info #0.0.14
import torch
model_path = "internlm/Spatial-SSRL-Qwen3VL-4B" #You can change it to your own local path if deployed already
#Change the path of the input image
img_path = "assets/eg1.jpg"
#Change your question here
question = "Question: Consider the real-world 3D locations and orientations of the objects. If I stand at the man's position facing where it is facing, is the menu on the left or right of me?\nOptions:\nA. on the left\nB. on the right\n"
question += "Please select the correct answer from the options above. \n"
#We recommend using the format prompt to make the inference consistent with training
format_prompt = "You FIRST think about the reasoning process as an internal monologue and then provide the final answer. The reasoning process MUST BE enclosed within <think> </think> tags. The final answer MUST BE put in \\boxed{}."
model = AutoModelForImageTextToText.from_pretrained(
model_path, torch_dtype=torch.float16, device_map='auto', attn_implementation='flash_attention_2'
)
processor = AutoProcessor.from_pretrained(model_path)
messages = [
{
"role": "user",
"content": [
{
"type": "image",
"image": img_path,
},
{"type": "text", "text": question + format_prompt},
],
}
]
text = processor.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True
)
image_inputs, video_inputs = process_vision_info(messages)
inputs = processor(
text=[text],
images=image_inputs,
videos=video_inputs,
padding=True,
return_tensors="pt",
)
inputs = inputs.to("cuda")
generated_ids = model.generate(**inputs, max_new_tokens=4096, do_sample=False)
generated_ids_trimmed = [
out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
)
print("Model Response:", output_text[0])
Cases
✒️Citation
If you find our model useful, please kindly cite:
@article{liu2025spatial,
title={Spatial-SSRL: Enhancing Spatial Understanding via Self-Supervised Reinforcement Learning},
author={Liu, Yuhong and Zhang, Beichen and Zang, Yuhang and Cao, Yuhang and Xing, Long and Dong, Xiaoyi and Duan, Haodong and Lin, Dahua and Wang, Jiaqi},
journal={arXiv preprint arXiv:2510.27606},
year={2025}
}
📄 License
Usage and License Notices: The data and code are intended and licensed for research use only.
- Downloads last month
- 85
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="internlm/Spatial-SSRL-Qwen3VL-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)