Image-Text-to-Text
Transformers
Safetensors
English
qwen3_5
zwz2
vision-language
visual-reasoning
reinforcement-learning
grpo
conversational
Instructions to use inclusionAI/ZwZ2-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use inclusionAI/ZwZ2-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="inclusionAI/ZwZ2-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)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("inclusionAI/ZwZ2-4B") model = AutoModelForMultimodalLM.from_pretrained("inclusionAI/ZwZ2-4B", device_map="auto") 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=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use inclusionAI/ZwZ2-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "inclusionAI/ZwZ2-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": "inclusionAI/ZwZ2-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/inclusionAI/ZwZ2-4B
- SGLang
How to use inclusionAI/ZwZ2-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 "inclusionAI/ZwZ2-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": "inclusionAI/ZwZ2-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 "inclusionAI/ZwZ2-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": "inclusionAI/ZwZ2-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 inclusionAI/ZwZ2-4B with Docker Model Runner:
docker model run hf.co/inclusionAI/ZwZ2-4B
Update README.md
Browse files
README.md
CHANGED
|
@@ -16,190 +16,118 @@ tags:
|
|
| 16 |
|
| 17 |
# ZwZ2-4B
|
| 18 |
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
|
| 22 |
|
| 23 |
-
**
|
| 24 |
|
| 25 |
-
|
| 26 |
|
| 27 |
-
|
| 28 |
|
| 29 |
-
|
| 30 |
|
| 31 |
-
|
|
|
|
|
|
|
| 32 |
|
| 33 |
-
|
| 34 |
|
| 35 |
-
##
|
| 36 |
|
| 37 |
-

|
| 42 |
-
|
| 43 |
-
<!-- RESULTS_IMAGE_START -->
|
| 44 |
-
### Benchmark Results
|
| 45 |
|
| 46 |

|
| 47 |
|
| 48 |
-
[
|
| 49 |
-
|
| 50 |
-
<!-- RESULTS_IMAGE_END -->
|
| 51 |
-
|
| 52 |
-
**Evaluation scope.** **MMLongBench\*** denotes the visual-core aggregate of **25 non-Counting tasks from V-RAG, Image MM-NIAH, and VH-Multi**, not the full benchmark. Starred entries use the subset or aggregate specified in the manuscript.
|
| 53 |
-
|
| 54 |
-
## Key Features
|
| 55 |
-
|
| 56 |
-
- π **From Details to Evidence Connections:** Learn to compare, aggregate, and compose facts across related regions, beyond recognizing individual visual details.
|
| 57 |
-
- π― **Verified Visual Supervision:** Cross-model answer checks and region-ablation tests filter unreliable labels and questions that do not depend sufficiently on their selected evidence.
|
| 58 |
-
- π **Broad Transfer from Single Images:** Improvements extend to long-context multimodal understanding, embodied spatial reasoning, and multimodal agents.
|
| 59 |
-
- β‘ **Full-Image Inference:** The perception models operate on full-image inputs without requiring the privileged zoomed crop layouts used during data synthesis.
|
| 60 |
-
|
| 61 |
-
## How It Works
|
| 62 |
-
|
| 63 |
-
Zooming-without-Zooming-v2 develops the training-time zooming principle of the first-generation ZwZ into **multi-region evidence connection**:
|
| 64 |
|
| 65 |
-
|
| 66 |
-
2. **Synthesize from privileged views.** Use zoomed region layouts to construct questions involving aggregation, comparison, matching, or dependency chains.
|
| 67 |
-
3. **Verify answers and evidence.** Retain reference answers supported by independent VLM families, and use drop-one tests to assess whether the selected regions are needed.
|
| 68 |
-
4. **Build the policy-view task.** Convert each verified question into four-option MCQ form. The training model receives the full image with colored region outlines identifying the referenced regions, rather than the privileged zoomed layouts.
|
| 69 |
-
5. **Train with verifiable rewards.** Apply GRPO directly to the base VLM, rewarding the correct final option letter. Privileged crops are used in data construction, not supplied as additional training-time policy observations.
|
| 70 |
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
### Installation
|
| 74 |
-
|
| 75 |
-
Install a hardware-compatible PyTorch build first, then the inference dependencies:
|
| 76 |
|
| 77 |
```bash
|
| 78 |
pip install "transformers==5.13.1" accelerate pillow
|
|
|
|
|
|
|
| 79 |
```
|
| 80 |
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
Keep the weights, processor, tokenizer, and `chat_template.jinja` in the same downloaded model directory.
|
| 84 |
-
|
| 85 |
-
### Inference
|
| 86 |
-
|
| 87 |
-
Set `MODEL_PATH` to the downloaded model directory and `IMAGE_PATH` to an existing image file:
|
| 88 |
-
|
| 89 |
-
```bash
|
| 90 |
-
export MODEL_PATH="/absolute/path/to/ZwZ2-4B"
|
| 91 |
-
export IMAGE_PATH="/absolute/path/to/image.jpg"
|
| 92 |
-
```
|
| 93 |
|
| 94 |
```python
|
| 95 |
import os
|
| 96 |
-
import re
|
| 97 |
from pathlib import Path
|
| 98 |
import torch
|
| 99 |
-
from transformers import
|
| 100 |
|
| 101 |
model_path = os.environ["MODEL_PATH"]
|
| 102 |
-
assert Path(model_path, "config.json").is_file(), "MODEL_PATH must be a model directory"
|
| 103 |
-
assert Path(os.environ["IMAGE_PATH"]).is_file(), "IMAGE_PATH must be an existing image"
|
| 104 |
processor = AutoProcessor.from_pretrained(model_path)
|
| 105 |
-
|
| 106 |
-
processor.chat_template = Path(model_path, "chat_template.jinja").read_text(encoding="utf-8")
|
| 107 |
model = Qwen3_5ForConditionalGeneration.from_pretrained(
|
| 108 |
-
model_path,
|
| 109 |
-
dtype=torch.bfloat16,
|
| 110 |
-
device_map="auto",
|
| 111 |
).eval()
|
| 112 |
|
| 113 |
-
messages = [{
|
| 114 |
-
"
|
| 115 |
-
"
|
| 116 |
-
|
| 117 |
-
{"type": "text", "text": "Describe the relevant objects and their spatial relationships."},
|
| 118 |
-
],
|
| 119 |
-
}]
|
| 120 |
inputs = processor.apply_chat_template(
|
| 121 |
-
messages,
|
| 122 |
-
|
| 123 |
-
add_generation_prompt=True,
|
| 124 |
-
return_dict=True,
|
| 125 |
-
return_tensors="pt",
|
| 126 |
-
enable_thinking=False,
|
| 127 |
).to(model.device)
|
| 128 |
|
| 129 |
with torch.inference_mode():
|
| 130 |
-
|
| 131 |
-
**inputs,
|
| 132 |
-
max_new_tokens=2048,
|
| 133 |
-
do_sample=False,
|
| 134 |
-
)
|
| 135 |
-
|
| 136 |
-
completion = generated[:, inputs["input_ids"].shape[1]:]
|
| 137 |
response = processor.batch_decode(
|
| 138 |
-
|
| 139 |
)[0]
|
| 140 |
print(response)
|
| 141 |
-
|
| 142 |
-
# Final-answer extraction; this also supports non-MCQ answers.
|
| 143 |
-
matches = re.findall(r"<answer>(.*?)</answer>", response, flags=re.S)
|
| 144 |
-
if matches:
|
| 145 |
-
print("Final answer:", matches[-1].strip())
|
| 146 |
-
else:
|
| 147 |
-
print("No <answer> tag found; inspect the raw response above.")
|
| 148 |
```
|
| 149 |
|
| 150 |
-
Use
|
| 151 |
|
| 152 |
-
|
| 153 |
-
<summary><strong>Multiple-image input and answer extraction</strong></summary>
|
| 154 |
|
| 155 |
-
|
| 156 |
|
| 157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
|
| 159 |
-
|
| 160 |
|
| 161 |
-
|
|
|
|
|
|
|
|
|
|
| 162 |
|
| 163 |
-
|
| 164 |
|
| 165 |
-
|
| 166 |
|
| 167 |
-
The
|
| 168 |
|
| 169 |
-
|
| 170 |
|
| 171 |
-
##
|
| 172 |
|
| 173 |
-
|
|
| 174 |
|---|---|
|
| 175 |
-
| ZwZ2-4B | Qwen3.5-4B |
|
| 176 |
-
| ZwZ2-9B | Qwen3.5-9B |
|
| 177 |
-
| ZwZ2-27B | Qwen3.6-27B |
|
| 178 |
-
|
| 179 |
-
This repository contains **ZwZ2-4B**. The three sizes share the EvidenceConnect research framework; results and runtime requirements should be interpreted for the specific checkpoint.
|
| 180 |
-
|
| 181 |
-
## Related Work
|
| 182 |
-
|
| 183 |
-
The following citation refers to the **first generation**, not the second-generation manuscript:
|
| 184 |
-
|
| 185 |
-
```bibtex
|
| 186 |
-
@article{wei2026zooming,
|
| 187 |
-
title={Zooming without Zooming: Region-to-Image Distillation for Fine-Grained Multimodal Perception},
|
| 188 |
-
author={Wei, Lai and He, Liangbo and Lan, Jun and Dong, Lingzhong and Cai, Yutong and Li, Siyuan and Zhu, Huijia and Wang, Weiqiang and Kong, Linghe and Wang, Yue and Zhang, Zhuosheng and Huang, Weiran},
|
| 189 |
-
journal={arXiv preprint arXiv:2602.11858},
|
| 190 |
-
year={2026}
|
| 191 |
-
}
|
| 192 |
-
```
|
| 193 |
-
|
| 194 |
-
## License
|
| 195 |
-
|
| 196 |
-
Please refer to the license accompanying the released weights and the applicable backbone license for usage terms.
|
| 197 |
|
| 198 |
-
|
| 199 |
-
<summary><strong>Limitations and evaluation notes</strong></summary>
|
| 200 |
|
| 201 |
-
|
| 202 |
|
| 203 |
-
|
| 204 |
|
| 205 |
-
|
|
|
|
| 16 |
|
| 17 |
# ZwZ2-4B
|
| 18 |
|
| 19 |
+
<!-- Replace PAPER_URL, PROJECT_URL, and COLLECTION_URL with the final v2 URLs. -->
|
| 20 |
+
<p align="center">
|
| 21 |
+
π <a href="PAPER_URL">Paper</a> | π <a href="PROJECT_URL">Project</a> | π€ <a href="COLLECTION_URL">Collection</a>
|
| 22 |
+
</p>
|
| 23 |
|
| 24 |
+
## β¨ Model Summary
|
| 25 |
|
| 26 |
+
**ZwZ2-4B** is the **Qwen3.5-4B**-based model in **Zooming-without-Zooming-v2 (ZwZ2)**. It learns to connect visual evidence across regions through comparison, aggregation, matching, and multi-step reasoning. Training uses full images; inference requires no zooming tools.
|
| 27 |
|
| 28 |
+
On **25 benchmarks across six domains**, it improves over its base model on every benchmark, increasing overall accuracy from **49.41 to 54.79 (+5.39 points)**. Gains extend from fine-grained perception to spatial reasoning, long-context understanding, multimodal agents, and general visual reasoning.
|
| 29 |
|
| 30 |
+
## βοΈ Method and Data
|
| 31 |
|
| 32 |
+
**EvidenceConnect** builds verified multi-region questions from SA-1B images:
|
| 33 |
|
| 34 |
+
1. Group 3β7 related regions and generate questions using privileged zoomed views.
|
| 35 |
+
2. Check answers through cross-model agreement and drop-one region tests.
|
| 36 |
+
3. Convert verified questions to four-option tasks and train with **GRPO**, without an additional supervised fine-tuning stage.
|
| 37 |
|
| 38 |
+
All three model sizes use approximately **20K training examples**. The policy sees full images with colored region outlines; privileged crop layouts are used only for data construction. See [ZwZ2-RL-VQA](https://huggingface.co/datasets/inclusionAI/ZwZ2-RL-VQA) for the data schema and synthesis process.
|
| 39 |
|
| 40 |
+
## π Performance
|
| 41 |
|
| 42 |
+

|
| 43 |
|
| 44 |
+
[Editable vector PDF](assets/zwz2_performance_highlights_editable.pdf). The figure shows eight representative benchmarks; the complete results follow.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |

|
| 47 |
|
| 48 |
+
[Full-resolution results](assets/zwz2_4b_results.png). Scores are accuracies (%); domain and overall averages weight the corresponding benchmarks equally. **MMLongBench\*** uses the visual core: V-RAG, Image MM-NIAH, and VH-Multi, comprising **25 non-Counting tasks**. Advanced-model image resolution is constrained by their serving platforms.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
+
## π Getting Started
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
+
Install a hardware-compatible PyTorch build, then:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
```bash
|
| 55 |
pip install "transformers==5.13.1" accelerate pillow
|
| 56 |
+
export MODEL_PATH="/path/to/ZwZ2-4B"
|
| 57 |
+
export IMAGE_PATH="/path/to/image.jpg"
|
| 58 |
```
|
| 59 |
|
| 60 |
+
Keep the weights, processor, tokenizer, and `chat_template.jinja` together. All three sizes use `Qwen3_5ForConditionalGeneration`, including the Qwen3.6-27B-based model.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
```python
|
| 63 |
import os
|
|
|
|
| 64 |
from pathlib import Path
|
| 65 |
import torch
|
| 66 |
+
from transformers import AutoProcessor, Qwen3_5ForConditionalGeneration
|
| 67 |
|
| 68 |
model_path = os.environ["MODEL_PATH"]
|
|
|
|
|
|
|
| 69 |
processor = AutoProcessor.from_pretrained(model_path)
|
| 70 |
+
processor.chat_template = Path(model_path, "chat_template.jinja").read_text()
|
|
|
|
| 71 |
model = Qwen3_5ForConditionalGeneration.from_pretrained(
|
| 72 |
+
model_path, dtype=torch.bfloat16, device_map="auto"
|
|
|
|
|
|
|
| 73 |
).eval()
|
| 74 |
|
| 75 |
+
messages = [{"role": "user", "content": [
|
| 76 |
+
{"type": "image", "url": os.environ["IMAGE_PATH"]},
|
| 77 |
+
{"type": "text", "text": "Describe the objects and their spatial relationships."},
|
| 78 |
+
]}]
|
|
|
|
|
|
|
|
|
|
| 79 |
inputs = processor.apply_chat_template(
|
| 80 |
+
messages, tokenize=True, add_generation_prompt=True,
|
| 81 |
+
return_dict=True, return_tensors="pt", enable_thinking=False,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
).to(model.device)
|
| 83 |
|
| 84 |
with torch.inference_mode():
|
| 85 |
+
output = model.generate(**inputs, max_new_tokens=2048, do_sample=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
response = processor.batch_decode(
|
| 87 |
+
output[:, inputs["input_ids"].shape[1]:], skip_special_tokens=True
|
| 88 |
)[0]
|
| 89 |
print(response)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
```
|
| 91 |
|
| 92 |
+
Use the packaged template with **non-thinking mode**. Its default system instruction requests `<answer>...</answer>`; for MCQs, compare the extracted letter with the bare reference (e.g. `A`). A custom system message replaces that default instruction. For multiple images, add image entries in order and let the processor insert visual tokens. The 2,048-token output budget above is a demonstration setting; benchmark generation settings vary by task.
|
| 93 |
|
| 94 |
+
## π§ͺ Evaluation
|
|
|
|
| 95 |
|
| 96 |
+
From the released code repository, use the same **configure β prepare β evaluate** workflow:
|
| 97 |
|
| 98 |
+
```bash
|
| 99 |
+
cd eval
|
| 100 |
+
python -m pip install -e '.[api,data]'
|
| 101 |
+
python -m zwz_eval init --directory local/my-eval --bench hr4k,hr8k
|
| 102 |
+
```
|
| 103 |
|
| 104 |
+
Edit `local/my-eval/model.json` with your model/judge paths, GPU settings, and output directory, and `datasets.json` with the downloaded benchmark paths. Then run:
|
| 105 |
|
| 106 |
+
```bash
|
| 107 |
+
bash scripts/prepare_benchmarks.sh local/my-eval
|
| 108 |
+
bash scripts/evaluate.sh local/my-eval
|
| 109 |
+
```
|
| 110 |
|
| 111 |
+
See the code repository's `eval/README.md` for all 25 benchmark IDs and data requirements. Match its prompts, task selections, preprocessing, generation limits, and judging settings to reproduce the results.
|
| 112 |
|
| 113 |
+
## π Usage Notes
|
| 114 |
|
| 115 |
+
The Transformers example loads a downloaded model directory. Choose accelerator memory appropriate for the checkpoint; automatic device mapping distributes the weights but does not remove their memory requirements. Use an existing local image path in the example.
|
| 116 |
|
| 117 |
+
For multiple-choice evaluation, preserve the original question, option order, image order, and answer parser. Keep the complete raw response alongside the extracted answer so malformed or truncated responses remain inspectable. Benchmark scores are taken from the latest results table; the quickstart demonstrates inference rather than reproducing every benchmark configuration.
|
| 118 |
|
| 119 |
+
## π€ Models and Data
|
| 120 |
|
| 121 |
+
| Model | Base model |
|
| 122 |
|---|---|
|
| 123 |
+
| [ZwZ2-4B](https://huggingface.co/inclusionAI/ZwZ2-4B) | Qwen3.5-4B |
|
| 124 |
+
| [ZwZ2-9B](https://huggingface.co/inclusionAI/ZwZ2-9B) | Qwen3.5-9B |
|
| 125 |
+
| [ZwZ2-27B](https://huggingface.co/inclusionAI/ZwZ2-27B) | Qwen3.6-27B |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
|
| 127 |
+
[π€ ZwZ2-RL-VQA training dataset](https://huggingface.co/datasets/inclusionAI/ZwZ2-RL-VQA)
|
|
|
|
| 128 |
|
| 129 |
+
## π Limitations and License
|
| 130 |
|
| 131 |
+
The model can hallucinate details, misread text, and make counting or spatial errors. Performance depends on image resolution, context length, and prompt format. Refer to the license accompanying the released weights and the applicable backbone license for usage terms.
|
| 132 |
|
| 133 |
+
**First-generation ZwZ:** [Paper](https://huggingface.co/papers/2602.11858) Β· [Code](https://github.com/inclusionAI/Zooming-without-Zooming).
|