This repository contains the official PyTorch implementation for the paper:
Shengli Zhou, Minghang Zheng, Feng Zheng, and Yang Liu. 2026. Scalable Object Relation Encoding for Better 3D Spatial Reasoning in Large Language Models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2026.
Spatial reasoning focuses on locating target objects based on spatial relations in 3D scenes, which plays a crucial role in developing intelligent embodied agents. Due to the limited availability of 3D scene-language paired data, it is challenging to train models with strong reasoning ability from scratch. Previous approaches have attempted to inject 3D scene representations into the input space of Large Language Models (LLMs) and leverage the pretrained comprehension and reasoning abilities for spatial reasoning. However, models encoding absolute positions struggle to extract spatial relations from prematurely fused features, while methods explicitly encoding all spatial relations (which is quadratic in the number of objects) as input tokens suffer from poor scalability. To address these limitations, we propose QuatRoPE, a novel positional embedding method with an input length that is linear to the number of objects, and explicitly calculates pairwise spatial relations through the dot product in attention layers. QuatRoPE's holistic vector encoding of 3D coordinates guarantees a high degree of spatial consistency, maintaining fidelity to the scene’s geometric integrity. Additionally, we introduce the Isolated Gated RoPE Extension (IGRE), which effectively limits QuatRoPE's influence to object-related tokens, thereby minimizing interference with the LLM’s existing positional embeddings and maintaining the LLM’s original capabilities. Extensive experiments demonstrate the effectiveness of our approaches.
- Prepare the environment:
conda create -n quatrope python=3.9.17
conda activate quatrope
pip install torch==2.7.1 torchvision==0.22.1 torchaudio==2.7.1 --index-url https://download.pytorch.org/whl/cu128
pip install -r requirements.txt
conda install -c conda-forge openjdk- Download and install flash attention, we use v2.8.3 in our environment.
- Download LLM backbone from Hugging Face, and modify
llama_model_pathin the bash scripts in thescripts/directory. - Download annotations from Hugging Face AND Yandex Disk and place them in the
annotations/directory. Generateobj_align_gt_train.jsonusingpython preprocess/prepare_objalign_annos.py --segmentor gt. More details for data preparation can be found here. - Replace
(env_base_path)/lib/python3.9/site-packages/transformers/generation/utils.pywithgeneration/utils.py.(env_base_path)can be found by runningconda env listin the terminal (use the path corresponding to thequatropeenvironment).
The data for the ASR benchmark are in ASR/asr_gt_val.json, move it under the annotations/ directory.
- Modify
calc_scanrefer_scoretocalc_scanrefer_score_asrin theevaluatefunction oftasks/train.py. - Run the following script:
sh scripts/run_gt_eval_asr.sh- Pretrain on ground-truth (GT) segmentation:
sh scripts/run_gt_pretrain.sh- Finetune on Mask3D segmentation:
sh scripts/run_mask3d_finetune.sh- Evaluation:
sh scripts/run_mask3d_eval.sh| ScanRefer | Multi3DRefer | SQA3D | ||||
|---|---|---|---|---|---|---|
| Model | Weights | Acc.@0.25 | Acc.@0.5 | F1@0.25 | F1@0.5 | EM@1 |
| Chat-Scene + QuatRoPE | Hugging Face / Model Scope | 57.8 | 52.2 | 59.5 | 54.8 | 54.7 |
| 3DGraphLLM + QuatRoPE | Hugging Face / Model Scope | 58.2 | 52.5 | 60.6 | 56.0 | 55.2 |
Note: The checkpoints are based on Vicuna-7B-v1.5, trained by GT segmentation, and fine-tuned using the Mask3D segmentation.
We would like to thank the open-source code base of 3DGraphLLM and the anonymous reviewers for their constructive feedback.
If you find this project useful in your research, please consider citing:
@misc{zhou2026scalableobjectrelationencoding,
title={Scalable Object Relation Encoding for Better 3D Spatial Reasoning in Large Language Models},
author={Shengli Zhou and Minghang Zheng and Feng Zheng and Yang Liu},
year={2026},
eprint={2603.24721},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2603.24721},
}