File size: 4,163 Bytes
f9a19c4
 
 
 
 
7f2982b
82542e4
f669183
82542e4
 
c8ccf34
82542e4
 
 
 
 
c8ccf34
82542e4
 
c8ccf34
82542e4
 
 
 
 
 
 
 
 
d4e53d8
 
82542e4
 
 
 
 
 
 
 
 
 
 
 
 
 
32dc991
82542e4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
04537ac
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
---
license: apache-2.0
base_model:
- Qwen/Qwen2.5-VL-3B-Instruct
pipeline_tag: image-text-to-text
---

<a href="https://arxiv.org/pdf/2510.08531" target="_blank">
    <img alt="arXiv" src="https://img.shields.io/badge/arXiv-SpatialLadder-red?logo=arxiv" height="20" />
</a>
<a href="https://zju-real.github.io/SpatialLadder/" target="_blank">
    <img alt="Website" src="https://img.shields.io/badge/🌎_Website-SpaitalLadder-blue.svg" height="20" />
</a>
<a href="https://github.com/ZJU-REAL/SpatialLadder" target="_blank">
    <img alt="Code" src="https://img.shields.io/badge/Code-SpaitalLadder-white?logo=github" height="20" />
</a>
<a href="https://huggingface.co/datasets/hongxingli/SpatialLadder-26k" target="_blank">
    <img alt="Data" src="https://img.shields.io/badge/%F0%9F%A4%97%20_Data-SpatialLadder--26k-ffc107?color=ffc107&logoColor=white" height="20" />
</a>
<a href="https://huggingface.co/datasets/hongxingli/SPBench" target="_blank">
    <img alt="Bench" src="https://img.shields.io/badge/%F0%9F%A4%97%20_Bench-SPBench-ffc107?color=ffc107&logoColor=white" height="20" />
</a>

# SpatialLadder-3B

This repository contains the SpatialLadder-3B, introduced in [SpatialLadder: Progressive Training for Spatial Reasoning in Vision-Language Models]().

## Model Description

SpatialLadder-3B is a 3B-parameter multimodal model for spatial reasoning, built on top of Qwen-2.5-VL-3B. It is trained with a progressive three-stage approach: object localization for perceptual grounding, multi-dimensional spatial tasks for spatial understanding, and policy-optimized complex reasoning for advanced spatial intelligence. SpatialLadder-3B achieves strong performance and generalization across multiple spatial benchmarks, demonstrating robust hierarchical spatial reasoning capabilities.

## Usage

First, install the required dependencies:

```python
pip install transformers==4.49.0 qwen-vl-utils 
```

```
from transformers import Qwen2_5_VLForConditionalGeneration, AutoProcessor
from qwen_vl_utils import process_vision_info

# We recommend enabling flash_attention_2 for better acceleration and memory saving, especially in multi-image and video scenarios.
model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
     "hongxingli/SpatialLadder-3B",
     torch_dtype=torch.bfloat16,
     attn_implementation="flash_attention_2",
     device_map="auto")
     
processor = AutoProcessor.from_pretrained("hongxingli/SpatialLadder-3B")
image_path = ''
instruction = ''

messages = [
    {
        "role": "user",
        "content": [
            {
                "type": "image",
                "image": "image_path",
            },
            {"type": "text", "text": instruction},
        ],
    }
]

# Preparation for inference
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(model.device)

# Inference: Generation of the output
generated_ids = model.generate(**inputs, max_new_tokens=128)
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(output_text)
```

## Training

The training code and usage guidelines are available in our [GitHub repository](https://github.com/ZJU-REAL/SpatialLadder). For comprehensive details, please refer to our paper and the repository documentation.

## Citation
```bibtext
@misc{li2025spatialladderprogressivetrainingspatial,
      title={SpatialLadder: Progressive Training for Spatial Reasoning in Vision-Language Models}, 
      author={Hongxing Li and Dingming Li and Zixuan Wang and Yuchen Yan and Hang Wu and Wenqi Zhang and Yongliang Shen and Weiming Lu and Jun Xiao and Yueting Zhuang},
      year={2025},
      eprint={2510.08531},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2510.08531}, 
}
```