Skip to content

About

[Technical Report] Locate, Segment, and Reason.

Resources

Stars

87 stars

Watchers

0 watching

Forks

Repository files navigation

Xiaomi-Lens-0

Pixel-level grounding and visual reasoning in a compact 4B multimodal model.

Project Page arXiv Hugging Face Model GitHub LensBench dataset Citation

News · What it does · Method · Showcases · Results · Quick Start · Citation

English | 简体中文

Xiaomi-Lens-0 is a 4B multimodal large language model that learns from pixel-level supervision through a shared visual backbone. Starting from Qwen3.5-4B, it decodes each generated <|mask|> token into a mask with a lightweight decoder, so the same model that answers in text can point at the regions it refers to, in a final answer or in the middle of its reasoning. It improves referring comprehension over Qwen3.5-4B by 5.6 points on average across eight RefCOCO-family splits and improves scores on all eight fine-grained perception benchmarks.

overview_gh.mp4

98-second overview. Also available on the project page (full-resolution MP4).

Xiaomi-Lens-0 recorded outputs across six task domains

Recorded outputs across the six capability domains: Referring Expression Comprehension, Referring Expression Segmentation, Multi-Instance Grounding, Reasoning Segmentation, Embodied Referring, and Fine-Grained Perception.

📰 News

✨ What it does

  1. Referring Expression Comprehension: finds the object a phrase describes and returns its bounding box. First on seven of eight RefCOCO, RefCOCO+, and RefCOCOg splits, 5.6 points above its Qwen3.5-4B backbone on average.
  2. Referring Expression Segmentation: returns a pixel mask for the referred object. 81.4% mean cIoU across the eight splits, leading the compared models on every split.
  3. Multi-Instance Grounding: lists every instance of a category, each with its own box and mask. 63.9 mean F1 on COCO 2017, highest among the compared models and 0.9 points above GroundingPI.
  4. Reasoning Segmentation: resolves functional and implicit requests after a short reasoning trace. Best on all four ReasonSeg scores.
  5. Embodied Referring: picks the object a person asks to be handed in cluttered scenes. Best on all four RoboRefIt scores.
  6. Fine-Grained Perception: thinks with visual latents, grounding each region it refers to while counting or answering high-resolution questions. Improves over its Qwen3.5-4B backbone on all eight perception benchmarks, including +6.8 points on CountQA.

We also release LensBench, a segmentation benchmark with 4,800 instruction-level samples from 1,200 paired evaluation units, covering General, Aerial, Driving, and Panoramic images. Each domain contains 300 units, each with four instructions crossing Single/Multiple targets with Explicit/Implicit wording.

🧠 Method

Each generated <|mask|> token has a contextual state, or visual latent, that represents a target region given the image, instruction, and preceding response. A lightweight decoder combines this state with a single feature grid from the vision encoder before spatial merging to predict a mask. The model needs no separate segmentation encoder or multi-scale feature fusion. Joint language and mask training supervises the shared representation used for both spatial predictions and textual answers.

The same decoder supports thinking with visual latents: <|mask|> tokens placed inside the reasoning trace decode to masks for the regions the trace discusses, such as each instance being counted. Grounded reasoning traces supervise these intermediate regions. Mask decoding is an output branch, so no crops or region features are fed back to the language model.

Xiaomi-Lens-0 architecture

Training runs in two stages: Stage 1 pretrains the mask decoder, and Stage 2 performs full-parameter supervised fine-tuning. The project page shows the training data mix and the referring expression segmentation, VQA, and LensBench data pipelines.

🎬 Showcases

Referring Expression Segmentation
Referring Expression Segmentation: “second wedge grapefruit from left to right”
Multi-Instance Grounding
Multi-Instance Grounding: “all oranges”
Reasoning Segmentation
Reasoning Segmentation: “What can be squeezed onto seafood as a tangy flavor enhancer?”
Fine-Grained Perception
Fine-Grained Perception: “How many climbing stones are there?” → 5

All 24 recorded cases, four per domain, can be replayed on the project page.

📊 Results

All scores are percentages; higher is better. Bold marks the best score and underline the second best.

Radar comparison

1. Referring Expression Comprehension (Prec@0.5)

Method RefCOCO
Val
RefCOCO
TestA
RefCOCO
TestB
RefCOCO+
Val
RefCOCO+
TestA
RefCOCO+
TestB
RefCOCOg
Val
RefCOCOg
Test
Grounding-DINO-L 90.6 93.2 88.2 82.8 89.0 75.9 86.1 87.0
Florence-2 93.4 95.3 92.0 88.3 92.9 83.6 91.2 91.7
LISALLaVA-7B 85.4 88.8 82.6 74.2 79.5 68.4 79.3 80.4
GSVAVicuna-7B 86.3 89.2 83.8 72.8 78.8 68.0 81.6 81.8
PixelLMLLaVA-7B 89.8 92.2 86.4 83.2 87.0 78.9 84.6 86.0
VisionLLM v2Vicuna-7B 87.9 91.2 84.3 77.6 83.8 70.2 82.9 84.1
Text4SegInternVL2-8B 90.3 93.4 87.5 85.2 89.9 79.5 85.4 85.4
UFOInternVL2-8B 91.4 93.8 88.2 85.7 90.7 79.7 86.8 87.4
MLLMSegInternVL2.5-4B 91.6 93.3 87.6 86.0 90.0 79.8 88.3 88.6
InternVL-3.54B 92.5 94.3 88.2 87.6 92.3 81.6 89.6 89.3
Qwen2.5-VL3B 89.1 91.7 84.0 82.4 88.0 74.1 85.2 85.7
Qwen3-VL4B 90.7 92.2 86.7 82.9 89.4 75.6 87.3 87.7
Qwen3-VL-Seg4B 92.7 94.6 89.8 87.8 92.1 82.2 89.1 89.0
Qwen3.54B 90.4 92.3 87.1 84.8 88.9 79.1 88.0 88.2
Youtu-VL4B 93.6 95.2 90.8 90.1 93.9 85.4 92.2 92.9
Xiaomi-Lens-04B 94.6 96.2 92.3 92.1 94.9 88.5 92.5 92.4

2. Referring Expression Segmentation (cIoU)

Method RefCOCO
Val
RefCOCO
TestA
RefCOCO
TestB
RefCOCO+
Val
RefCOCO+
TestA
RefCOCO+
TestB
RefCOCOg
Val
RefCOCOg
Test
LISALLaVA-7B 74.9 79.1 72.3 65.1 70.8 58.1 67.9 70.6
GSVAVicuna-7B 77.2 78.9 73.5 65.9 69.6 59.8 72.7 73.3
PixelLMLLaVA-7B 73.0 76.5 68.2 66.3 71.7 58.3 69.3 70.5
VisionLLM v2Vicuna-7B 76.6 79.3 74.3 64.5 69.8 61.5 70.7 71.2
Text4SegInternVL2-8B 79.2 81.7 75.6 72.8 77.9 66.5 74.0 75.3
UFOInternVL2-8B 78.0 79.7 75.6 72.3 76.8 66.6 73.7 74.3
MLLMSegInternVL2.5-4B 79.5 81.4 77.7 75.4 78.7 70.8 78.1 78.4
SAM 3 75.5 77.6 71.0 67.3 71.1 63.4 73.4 74.0
UniPixelQwen2.5-VL-3B 80.5 82.6 76.9 74.3 78.9 68.4 76.3 77.0
Youtu-VL4B 80.7 82.0 78.4 76.2 79.6 71.4 76.5 76.6
Qwen3-VL-Seg4B 82.3 83.7 79.1 76.2 80.2 70.8 78.2 78.1
Xiaomi-Lens-04B 83.4 84.6 81.2 79.9 83.3 76.3 81.1 81.2

3. Multi-Instance Grounding (COCO 2017)

Recall, precision, and F1 at IoU 0.50 and 0.95; the mIoU group averages each metric over IoU thresholds from 0.50 to 0.95.

Method IoU 0.50
Recall
IoU 0.50
Precision
IoU 0.50
F1
IoU 0.95
Recall
IoU 0.95
Precision
IoU 0.95
F1
mIoU
Recall
mIoU
Precision
mIoU
F1
GroundingDINO 79.6 83.2 81.4 24.7 28.1 26.3 61.1 63.7 60.6
Rex-Omni 69.9 81.0 75.0 17.9 21.7 19.7 53.9 59.4 56.3
LocateAnything Fast 66.2 73.3 69.6 24.7 26.9 25.8 50.9 59.3 53.1
LocateAnything Hybrid 74.7 80.8 77.6 26.6 28.7 27.6 52.4 65.2 59.1
LocateAnything Slow NTP 75.0 81.9 78.3 25.0 27.2 26.0 54.7 65.1 59.4
Qwen2.5-VL7B 57.2 62.9 59.9 12.2 13.2 12.7 44.7 49.1 46.3
Qwen3-VL2B 63.5 67.1 65.3 21.8 22.6 22.2 42.6 44.9 42.5
Qwen3-VL4B 66.1 70.6 68.3 23.7 24.9 24.3 44.9 47.8 46.5
Qwen3-VL8B 65.7 69.5 67.5 23.9 25.1 24.5 44.8 47.3 46.3
RynnBrain1.1 36.5 60.5 45.5 11.6 16.5 13.6 28.7 45.3 35.2
SenseNova-Vision 79.1 80.5 79.8 27.2 30.2 28.6 63.1 55.4 57.5
GroundingPI 81.4 80.9 81.2 22.9 22.8 22.8 63.2 62.8 63.0
MiMo-VL-SFT7B 65.5 72.2 68.7 10.0 11.1 10.5 45.7 50.5 48.0
MiMo-VL-RL7B 65.6 74.5 69.8 9.2 10.3 9.7 44.5 50.2 47.2
BAGEL 65.6 75.2 70.1 11.0 13.0 11.9 46.3 47.2 46.0
RynnBrain 21.3 49.9 29.8 4.9 10.9 6.7 15.5 35.4 21.5
Xiaomi-Lens-04B 79.6 81.1 80.4 27.2 27.7 27.4 63.4 64.5 63.9

4. Reasoning Segmentation (ReasonSeg, gIoU / cIoU)

Method ReasonSeg
Val
gIoU
ReasonSeg
Val
cIoU
ReasonSeg
Test
gIoU
ReasonSeg
Test
cIoU
LISALLaVA-7B 52.9 54.0 47.3 48.4
LISA++LLaVA-7B 64.2 68.1 57.0 59.5
PixelLMLLaVA-7B 44.7 37.4 44.0 39.7
Sa2VAInternVL2-2B 59.2 60.0 56.9 55.8
Sa2VAInternVL2-8B 65.2 61.1 59.5 57.8
X-SAMPhi-3-3.8B 56.6 32.9 57.8 41.0
InstructSAMQwen3-VL-2B 62.5 65.0 61.1 61.0
Xiaomi-Lens-04B 71.2 68.5 68.0 62.5

5. Embodied Referring (RoboRefIt, gIoU / cIoU)

Method RoboRefIt
TestA
gIoU
RoboRefIt
TestA
cIoU
RoboRefIt
TestB
gIoU
RoboRefIt
TestB
cIoU
LISALLaVA-7B 36.1 29.9 28.7 22.7
LISA++LLaVA-7B 58.7 51.5 53.5 47.8
PixelLMLLaVA-7B 45.2 38.4 38.2 31.4
Sa2VAInternVL2-2B 56.8 29.0 34.0 10.2
Sa2VAInternVL2-8B 58.7 27.9 36.1 9.0
X-SAMPhi-3-3.8B 41.2 10.3 25.1 4.0
InstructSAMQwen3-VL-2B 82.5 58.4 74.4 55.5
Xiaomi-Lens-04B 87.0 88.4 81.5 81.2

6. Fine-Grained Perception (accuracy)

Method General Perception
MME-RW-en
General Perception
MME-RW-cn
General Perception
CV-B
High-Resolution Perception
V*
High-Resolution Perception
HR-4K
High-Resolution Perception
HR-8K
Counting and Color
CountQA
Counting and Color
ColorB
Qwen2.5-VL7B 60.8 58.3 75.3 78.5 71.6 67.9 18.9 76.4
MiMo-VL-RL7B 63.4 59.8 84.3 81.2 74.4 72.9 28.3 82.8
Qwen3-VL4B 63.5 63.6 85.0 80.1 78.3 72.9 28.1 81.6
Qwen3-VL8B 66.0 66.7 85.4 86.4 78.9 74.6 29.0 82.8
MiniCPM-V-4.59B 58.2 56.2 80.2 70.2 69.9 63.6 23.4 79.8
Qwen3.54B 66.5 60.3 85.4 82.2 81.5 75.6 43.8 82.7
Xiaomi-Lens-04B 69.7 67.5 88.1 87.4 82.5 80.6 50.6 84.4

Box-grounding F1 on the RefCOCO family is on the project page.

7. LensBench

LensBench contains 1,200 human-reviewed paired units and 4,800 instructions across general, aerial, driving, and panoramic imagery (300 units per domain). Each unit combines single/multiple targets with explicit/implicit wording. The two wordings share the same target mask; multiple targets use the union mask and its enclosing box. Targets and masks are fixed before instruction synthesis, followed by automated consistency checks and human review of each complete unit.

GPT-6-Astra leads cIoU on explicit and implicit instructions and in aerial, driving, and panoramic imagery. Qwen3.8-Max leads cIoU in general imagery (74.2). Xiaomi-Lens-0 ranks second on both explicit-instruction metrics and on cIoU in aerial, driving, and panoramic imagery, and leads aerial Prec@0.5 (79.6). Implicit instructions remain challenging: cIoU drops from 71.4 to 54.7, while Prec@0.5 drops from 85.0 to 70.0. The gap is largest for multiple targets in panoramic scenes, where cIoU falls from 71.8 to 48.9 and Prec@0.5 from 81.3 to 48.7.

Marginal results pool single and multiple targets. Each cell reports cIoU / Prec@0.5 (%, higher is better).

Method Explicit Implicit General Aerial Driving Panoramic
GPT-6-Astra 72.6 / 86.3 71.0 / 84.0 74.1 / 86.2 61.7 / 76.9 77.6 / 89.0 68.9 / 88.3
GPT-5.6-Sol 63.8 / 73.2 61.2 / 70.0 68.4 / 67.9 42.2 / 58.5 68.4 / 81.8 57.1 / 78.3
Gemini-3.6-Flash 61.4 / 74.5 61.0 / 70.3 63.6 / 65.8 50.1 / 62.5 66.8 / 81.0 60.8 / 80.3
MiMo-V2.5 51.4 / 52.2 47.4 / 46.8 54.2 / 45.2 32.6 / 38.6 50.5 / 52.8 45.4 / 61.4
Seed-2.1-Pro 62.1 / 70.2 55.9 / 64.5 60.6 / 56.7 50.1 / 58.5 66.8 / 77.4 59.9 / 76.7
Qwen3.8-Max 67.6 / 69.2 64.5 / 63.8 74.2 / 79.7 33.5 / 62.5 58.0 / 57.7 60.8 / 66.2
Kimi-K3 29.4 / 39.1 28.3 / 33.0 38.5 / 26.1 13.8 / 44.9 47.2 / 31.1 13.4 / 42.1
GLM-5.3-Flash 44.3 / 37.5 43.5 / 33.3 48.9 / 26.3 28.0 / 33.4 51.6 / 47.5 30.6 / 34.4
DeepSeek-V4-Flash-Vision-Exp 41.8 / 30.7 41.1 / 27.3 46.1 / 28.1 25.9 / 28.9 43.9 / 27.9 32.8 / 31.0
SAM 3 17.3 / 38.1 15.4 / 19.5 23.8 / 24.8 4.3 / 27.3 27.7 / 35.1 11.1 / 27.9
Xiaomi-Lens-04B 71.4 / 85.0 54.7 / 70.0 63.9 / 79.1 57.1 / 79.6 68.6 / 79.4 62.3 / 72.1

LensBench design and construction pipeline

LensBench qualitative comparisons

LensBench predictions across four domains, compared with ground-truth masks

🚀 Quick Start

Installation

git clone https://github.com/SeerRay-Lab/Xiaomi-Lens-0.git
cd Xiaomi-Lens-0
pip install -r requirements.txt   # torch, transformers 5.4, flash-attn
pip install -e .

Inference needs a CUDA GPU (bf16, FlashAttention-2). The commands below load the weights from Hugging Face as SeerRay-Lab/Xiaomi-Lens-0; pass a local directory to use a downloaded copy.

Inference with Transformers

python infer.py \
  --checkpoint SeerRay-Lab/Xiaomi-Lens-0 \
  --image /path/to/image.jpg \
  --text 'Locate all instances in the image that match the description "the cat on the left". Report bbox coordinates and masks.' \
  --output result.jpg --draw-bbox

The script prints the generated text and saves the masks (and, with --draw-bbox, the boxes) overlaid on the image. Useful options:

  • --per-mask-output: save one image per predicted mask instead of a single composite.
  • --mask-threshold: sigmoid threshold for binarizing masks (default 0.5; 0 draws a soft heatmap).
  • --temperature, --top-p: sample instead of decoding greedily.

Each grounded instance in the answer is written as <bbox>[x1, y1, x2, y2]</bbox><mask><|mask|></mask>, with box coordinates normalized to 0–1000. Every <|mask|> token is decoded into a pixel mask at the resolution the vision encoder sees. Masks emitted inside <think> ground the reasoning and are not part of the final answer.

Python API
import torch
from PIL import Image
from infer import (
    build_inputs, generate_completion, load_model_and_processor,
    run_forward, split_answer_content, parse_answer_bboxes,
)

device = torch.device("cuda")
model, processor, mask_token_id = load_model_and_processor("SeerRay-Lab/Xiaomi-Lens-0", device)

image = Image.open("/path/to/image.jpg").convert("RGB")
text = ('Locate all instances in the image that match the description '
        '"the cat on the left". Report bbox coordinates and masks.')
inputs, _ = build_inputs(processor, image, text, device)

# Phase 1: generate text with <bbox> and <|mask|> tokens.
completion_ids, completion, num_masks = generate_completion(
    model, processor, inputs, max_new_tokens=2048, mask_token_id=mask_token_id)
print(completion)

# Phase 2: decode each <|mask|> into a mask; keep only those in the final answer.
if num_masks > 0:
    _, num_thought_masks = split_answer_content(completion)
    mask_logits = run_forward(model, inputs, completion_ids, mask_token_id, device)
    masks = mask_logits[:, num_thought_masks:].sigmoid() > 0.5   # (1, K, H, W)
    boxes = parse_answer_bboxes(completion)                       # [[x1, y1, x2, y2], ...] in 0–1000

The masks are aligned with the image resized to the vision encoder's input canvas; visualize_pixel_mask in infer shows how to overlay them on the original image.

Serving with vLLM

Serving uses two vLLM processes on the same checkpoint: one generates text, and one runs the mask decoder through vLLM's pooling API. Install the vLLM extra in a separate environment (tested with vLLM 0.19.1):

pip install -e ".[vllm]"

# Terminal 1: text generation on :8000
bash src/xiaomi_lens/integrations/vllm/run_vllm.sh SeerRay-Lab/Xiaomi-Lens-0

# Terminal 2: mask decoding on :8001
bash src/xiaomi_lens/integrations/vllm/run_vllm_mask.sh SeerRay-Lab/Xiaomi-Lens-0

# Terminal 3: query both and save the overlay
python -m xiaomi_lens.integrations.vllm.client \
  --image /path/to/image.jpg --query "the cat on the left" --output result.png

The client sends the image path to the mask server, so it must run on the same machine as the servers. Ports and the served model name can be changed with PORT and SERVED_NAME; if you override MAX_PIXELS, set the same value for both servers.

LensBench

LensBench is available on Hugging Face Datasets. Download it with:

hf download SeerRay-Lab/LensBench --repo-type dataset --local-dir LensBench

Evaluate with eval/run.py. By default it loads SeerRay-Lab/Xiaomi-Lens-0 and SeerRay-Lab/LensBench from Hugging Face; --model-path and --dataset-path also accept a local checkpoint directory and a local test.parquet (or its directory).

pip install -e ".[eval]"

# Single GPU
python eval/run.py --output-dir outputs/lensbench

# One shard per GPU, merged at the end
python eval/run.py --devices cuda:0 cuda:1 cuda:2 cuda:3 --output-dir outputs/lensbench

# Local copies
python eval/run.py --model-path /path/to/Xiaomi-Lens-0 --dataset-path LensBench --output-dir outputs/lensbench

# vLLM backend (text and mask engines on two GPUs; requires ".[vllm]")
python eval/run.py --backend vllm --vllm-text-device cuda:0 --vllm-mask-device cuda:1 --output-dir outputs/lensbench_vllm

Results are written to metrics.json (Prec@0.5, cIoU and gIoU, overall and per domain, explicitness and cardinality) and per-sample predictions to predictions.jsonl. Add --resume to continue an interrupted run and --limit N for a quick check.

Training

Training starts from Qwen3.5 in two stages. Stage 1 trains the mask decoder and the <|mask|> embedding with mask loss alone, keeping the rest of the model frozen. Stage 2 fine-tunes all parameters with the LM loss plus the mask loss (dice + BCE). The launchers use DeepSpeed (ZeRO-1 for Stage 1, ZeRO-2 for Stage 2) and expect CUDA GPUs.

pip install -e ".[train]"        # transformers 5.4, deepspeed, accelerate
pip install -e ".[train-fast]"   # optional: liger-kernel and Qwen3.5 linear-attention kernels

# Prepare the base model: rename Qwen's box tokens to <bbox>/</bbox> (IDs and weights unchanged)
hf download Qwen/Qwen3.5-4B --local-dir checkpoints/Qwen3.5-4B
python tools/prepare_base_model.py checkpoints/Qwen3.5-4B --in-place

# Optional: synthetic toy data to check the setup end to end
python examples/train/make_toy_data.py --output examples/train/toy

# Stage 1 → checkpoints/xiaomi-lens-stage1
MODEL_PATH=checkpoints/Qwen3.5-4B DATA_CONFIG=examples/train/stage1.yaml \
  bash scripts/train_stage1.sh

# Stage 2 → checkpoints/xiaomi-lens-stage2 (starts from the Stage 1 output)
DATA_CONFIG=examples/train/stage2.yaml bash scripts/train_stage2.sh

Training data is JSONL listed in a YAML manifest. Each <|mask|> in an assistant turn is paired with one COCO RLE mask; examples/train/README.md describes the format. Arguments appended to a launcher override its defaults (python train.py --help lists them all). For multi-node training, run the launcher on every node with NNODES, NODE_RANK, and MASTER_ADDR set. Both launchers resume from the latest checkpoint-* in OUTPUT_DIR with the same world size and ZeRO stage. The output loads with infer.py, eval/run.py, and the vLLM servers.

📝 Citation

If you find Xiaomi-Lens-0 useful, please cite:

@misc{xiaomilens0,
  title         = {Xiaomi-Lens-0 Technical Report},
  author        = {Pei Fu and Yike Liu and Yue Sun and Hanmo Wang and
                   Xiuwen Xi and Ruoceng Zhang and Shaojie Zhang and Tingwei Huang and
                   Chao Jiang and Hang Li and Bingrui Liu and Zhenbo Luo and
                   Heng Qu and Changjian Xu and Ming Xu and Jian Luan},
  year          = {2026},
  eprint        = {2610.23279},
  archivePrefix = {arXiv},
  primaryClass  = {cs.CV},
  url           = {https://arxiv.org/abs/2610.23279}
}

🙏 Acknowledgements

Xiaomi-Lens-0 is built on Qwen3.5.

We thank InstructSAM for their open-source contributions.

Code is licensed under Apache-2.0.

About

[Technical Report] Locate, Segment, and Reason.

Resources

Stars

87 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages