Instructions to use mindlab-research/MJev-Spatial-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mindlab-research/MJev-Spatial-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="mindlab-research/MJev-Spatial-4B")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("mindlab-research/MJev-Spatial-4B", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use mindlab-research/MJev-Spatial-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mindlab-research/MJev-Spatial-4B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mindlab-research/MJev-Spatial-4B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/mindlab-research/MJev-Spatial-4B
- SGLang
How to use mindlab-research/MJev-Spatial-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 "mindlab-research/MJev-Spatial-4B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mindlab-research/MJev-Spatial-4B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "mindlab-research/MJev-Spatial-4B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mindlab-research/MJev-Spatial-4B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use mindlab-research/MJev-Spatial-4B with Docker Model Runner:
docker model run hf.co/mindlab-research/MJev-Spatial-4B
File size: 8,218 Bytes
34dd2fd 0657319 34dd2fd | 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 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | ---
license: apache-2.0
library_name: transformers
pipeline_tag: image-text-to-text
---
<div align="center">
# 
[](LICENSE)
[](https://huggingface.co/mindlab-research/MJev-Spatial-4B)
[](https://arxiv.org/abs/2610.22276)
English · [简体中文](README-zh.md)
</div>
MJev-Spatial is a multimodal decision model for spatial understanding. It turns a spatial question into a finite candidate-selection problem, so the model can make a decision directly instead of generating an answer string and parsing it afterward.
The model is built on Qwen3.5-4B and reuses the backbone's pretrained query and key projections to score candidates. The released readout does not add a separate prediction head. Each decision is completed in one forward pass and produces no answer tokens.
The current model checkpoint is available at [mindlab-research/MJev-Spatial-4B](https://huggingface.co/mindlab-research/MJev-Spatial-4B). The paper is [MJev-Spatial: System One Spatial Intelligence via Native Attention Matching](https://arxiv.org/abs/2610.22276).

## WHAT THE MODEL DOES
MJev-Spatial uses one candidate-scoring interface for three output types:
- **Choice:** select one of the options supplied with the request.
- **Numerical prediction:** select a coarse value interval and then a finer interval; decode the selected interval to a value.
- **Pointing:** select a region in a 3×3 grid for three stages, re-encoding the selected crop between stages; decode the final cell center as normalized image coordinates.
The candidate set is part of the task contract. The model scores only legal candidates for the current stage, masks padded candidates, and returns the selected candidate together with its scores and decision path.

## MODEL READOUT
For a decision position and a candidate position, the model reads hidden states from the language backbone and applies the final full-attention block's native projections:
$$
z_i = \frac{1}{H}\sum_{h=1}^{H}
\frac{Q_h(h_{\mathrm{decision}})^\top K_h(h_{\mathrm{candidate}})}{\sqrt{d_h}}.
$$
The released configuration uses the final full-attention layer, native Q/K normalization, grouped-query-key alignment, and multimodal rotary position encoding. Score logits are normalized over the current candidate set.

## INSTALLATION
The public package targets Python 3.10 or newer and a CUDA-capable PyTorch installation.
```bash
git clone https://github.com/Fr0zenCrane/MJev-Spatial.git
cd MJev-Spatial
python -m venv .venv
source .venv/bin/activate
pip install -e '.[inference,train]'
```
Install the PyTorch build that matches your CUDA driver before installing the package if your environment does not already provide it.
## CHECKPOINT LAYOUT
The inference and training commands accept a local checkpoint directory. A released checkpoint contains the model configuration, processor files, and language-model weights in the layout expected by `scripts/predict.py` and `scripts/train.py`.
```bash
export MJEV_CHECKPOINT=/path/to/mjev-spatial-checkpoint
```
Model weights are distributed from [Hugging Face](https://huggingface.co/mindlab-research/MJev-Spatial-4B); this repository contains the source code and examples.
## RUN INFERENCE
Requests are JSON objects. An inference request contains an image, a question, and its candidate contract. The examples directory contains small synthetic requests that can be run without any private dataset.
```bash
python scripts/predict.py \
--checkpoint "$MJEV_CHECKPOINT" \
--input examples/requests.jsonl \
--output predictions.jsonl
```
A prediction contains the decoded answer, the decision path, and the candidate scores for each stage.
### REQUEST EXAMPLES
Choice:
```json
{
"id": "choice-0001",
"input": {
"media": [{"kind": "image", "uri": "examples/images/scene.png"}],
"question": "Where is the red square relative to the blue circle?",
"answer_space": {
"kind": "choice",
"options": [
{"id": "left", "text": "left"},
{"id": "right", "text": "right"}
]
}
}
}
```
Scalar:
```json
{
"id": "scalar-0001",
"input": {
"media": [{"kind": "image", "uri": "examples/images/scene.png"}],
"question": "What is the approximate distance between the two objects?",
"answer_space": {"kind": "scalar", "quantity": "distance", "unit": "m"}
}
}
```
Pointing:
```json
{
"id": "point-0001",
"input": {
"media": [{"kind": "image", "uri": "examples/images/scene.png"}],
"question": "Point to the blue circle.",
"answer_space": {
"kind": "point",
"coordinate_system": "normalized_xy",
"num_points": 1
}
}
}
```
Image paths are resolved relative to the current working directory or according to the path rules documented by the selected command.
## CONTINUE TRAINING ON YOUR DATA
The public training interface consumes already-labeled records in the same typed format. It does not require a particular benchmark or dataset source. Prepare your own images and annotations, write them to JSONL, and keep the task contract and target in the same record.
```json
{
"id": "train-choice-0001",
"input": {
"media": [{"kind": "image", "uri": "my_data/images/example.png"}],
"question": "Is the box to the left of the chair?",
"answer_space": {
"kind": "choice",
"options": [
{"id": "yes", "text": "yes"},
{"id": "no", "text": "no"}
]
}
},
"target": {"option_id": "yes"}
}
```
For numerical records, use `target.value` and the unit declared by `answer_space`. For point records, use normalized `[x, y]` coordinates in `target.points`:
```json
{"target": {"value": 2.4, "unit": "m"}}
```
```json
{"target": {"points": [[0.62, 0.41]]}}
```
Run a small supervised update with the sample records:
```bash
python scripts/train.py \
--checkpoint "$MJEV_CHECKPOINT" \
--data examples/train.jsonl \
--config configs/finetune.json \
--output runs/example-finetune
```
The training command saves a reloadable checkpoint. Use that checkpoint with `scripts/predict.py` and `scripts/evaluate.py`.
The default recipe keeps the vision encoder and vision-language projector frozen and updates the language-side model parameters used by the decision readout. Training settings such as learning rate, batch size, gradient accumulation, precision, and checkpoint frequency are configurable.
## EVALUATE A CHECKPOINT
Evaluation uses the same public record format and reads targets from the evaluation JSONL:
```bash
python scripts/evaluate.py \
--checkpoint runs/example-finetune \
--data examples/eval.jsonl \
--output runs/example-finetune/evaluation.json
```
The basic evaluator reports choice accuracy, scalar error, and point distance/hit metrics according to the task type present in the input records.
## SCOPE OF THIS REPOSITORY
This repository contains the model runtime, the basic training loop, a public evaluator, examples, and tests. The intended workflow is to load the released model, run it on your inputs, or continue training it with your own labeled records.
## CITATION
If you find this work useful, please cite:
```bibtex
@misc{qin2026mjevspatialspatialintelligencenative,
title={MJev-Spatial: System One Spatial Intelligence via Native Attention Matching},
author={Luozheng Qin and Yuhan Zhu and Changhai Zhou and Qian Qiao and Jun Gao and Yuhua Zhou and Harry Zhang and Xiangyu Zeng and Yuxuan Liu and Kaijie Chen and Andrew Chen and Pony Ma},
year={2026},
eprint={2610.22276},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2610.22276},
}
```
## LICENSE
The source code is released under the Apache License 2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE) for third-party attribution. |