需先安装并配置好 LLaVA 运行环境,否则导入 llava 相关模块会失败;示例默认加载 liuhaotian/llava-v1.5-7b,需联网下载模型权重;dominant 与 contextual 的取值需按模型自行调整,示例为 54 和 10
VisionZip
JIA-Lab-researchApache-2.0长期未更新VisionZip 是 CVPR 2025 提出的视觉语言模型加速方案,通过压缩视觉 token 减少冗余计算,在保持多模态任务精度的同时显著提升推理效率。
Official repository for VisionZip (CVPR 2025)
pip install visionzipREADME 未说明具体显存与 GPU 型号要求,仅说明需先搭好 LLaVA 环境
免训练压缩视觉 token 的 VLM 加速插件,只保留约 10% token 仍保住近 95% 性能
VisionZip 是 CVPR 2025 提出的视觉语言模型加速方案,通过压缩视觉 token 减少冗余计算,在保持多模态任务精度的同时显著提升推理效率。
核心能力
- 按 dominant 与 contextual 两类筛选保留视觉 token
- 以一行 visionzip(model, ...) 包装已有 LLaVA 模型
- 免训练即可用于推理,也可用于微调与训练阶段
- 文本无关的 token 裁剪,可叠加任意 LLM 加速算法
- 减少预填充与总推理时间,支持更多视频帧输入
容易踩的坑
- v0.1.3最新正式版2024-12-09 · 2024-12-09 13:54 UTC
VisionZip package
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
VisionZip: Longer is Better but Not Necessary in Vision Language Models
TABLE OF CONTENTS
- News
- Highlights
- Video
- Demo
- Installation
- Quick Start
- Evaluation
- Examples
- Citation
- Acknowledgement
- License
News
- [2025.07.20] Released VisionThink — an exploration of Efficient Reasoning VLM, maintaining strong OCR performance via RL-driven token reduction.
- [2025.05.26] VisionZip for Qwen2.5VL is now released! See details here.
- [2025.02.27] VisionZip has been accepted by CVPR 2025. :rocket:
- [2024.12.28] With support from Hugging Face, we add our demo on the Hugging Face Space, allowing for easy comparison of output results across different model sizes.
- [2024.12.16] Due to positive feedback on our demo, we have released the VisionZip Demo-Chat code in a new branch, 'demo-chat'.
- [2024.12.05] We add an Usage-Video, providing a step-by-step guide on how to use the demo.
- [2024.12.05] We add a new Demo-Chat, where users can manually select visual tokens to send to the LLM and observe how different visual tokens affect the final response. We believe this will further enhance the analysis of VLM interpretability.
- [2024.11.30] We release Paper and this GitHub repo, including code for LLaVA.
VisionZip: Longer is Better but Not Necessary in Vision Language Models [Paper] Senqiao Yang, Yukang Chen, Zhuotao Tian, Chengyao Wang, Jingyao Li, Bei Yu, Jiaya Jia
Highlights
- Our VisionZip achieves state-of-the-art performance among efficient VLM methods. By retaining only 10% of visual tokens, it achieves nearly 95% of the performance in training-free mode.
- VisionZip can be applied during the inference stage (without incurring any additional training cost), the efficient tuning stage (to achieve better results), and the training stage (almost no performance degradation,saving 2× memory and 2× training time).
- VisionZip significantly reduces the prefilling time and the total inference time (with KV cache enabled).
- Why does this simple, text-agnostic method outperform text-relevant methods? We conduct an in-depth analysis in the paper and provide a demo to visualize these findings.
- Since VisionZip is a text-agnostic method that reduces visual tokens before input into the LLM, it can adapt to any existing LLM acceleration algorithms and is applicable to any task that a vanilla VLM can perform, such as multi-turn conversations.
Video
Demo
Speed Improvement
The input video is about the Titanic, and the question is, "What’s the video talking about?"
It is important to note that the left side shows the vanilla model, which encodes only 16 frames, while the right side shows our VisionZip, which, despite encoding 32 frames, is still twice as fast as the vanilla model.
Visualize Redundancy and Misalignment
Explore the visual redundancy and feature misalignment in the above Demo. To run it locally, use the following command:
python gradio_demo.py
Observe How Different Visual Tokens Impact the Final Response
This Demo-Chat lets users to manually select which visual tokens to send to the LLM and observe how different visual tokens affect the final response.
Installation
Our code is easy to use.
-
Install the LLaVA environment.
-
For formal usage, you can install the package from PyPI by running the following command:
pip install visionzip
For development, you can install the package by cloning the repository and running the following command:
git clone https://github.com/dvlab-research/VisionZip
cd VisionZip
pip install -e .
Quick Start
from llava.model.builder import load_pretrained_model
from llava.mm_utils import get_model_name_from_path
from llava.eval.run_llava import eval_model
from visionzip import visionzip
model_path = "liuhaotian/llava-v1.5-7b"
tokenizer, model, image_processor, context_len = load_pretrained_model(
model_path=model_path,
model_base=None,
model_name=get_model_name_from_path(model_path)
)
## VisoinZip retains 54 dominant tokens and 10 contextual tokens
model = visionzip(model, dominant=54, contextual=10)
Evaluation
The evaluation code follows the structure of LLaVA or Lmms-Eval. After loading the model, simply add two lines as shown below:
## Load LLaVA Model (code from llava.eval.model_vqa_loader)
tokenizer, model, image_processor, context_len = load_pretrained_model(model_path, args.model_base, model_name)
## add VisionZip
from visionzip import visionzip
model = visionzip(model, dominant=54, contextual=10)
Examples
Multi-turn Conversations
VisionZip, which extracts text-agnostic tokens, is better suited for multi-turn dialogue.
Longer Videos with More Frames
VisionZip reduces the number of visual tokens per frame, allowing more frames to be processed. This improves the model's ability to understand longer videos.
Citation
If you find this project useful in your research, please consider citing:
Note: VisionThink is our new exploration of Efficient Reasoning VLMs, designed to maintain strong OCR capabilities via RL-driven token reduction. Check it out here.
@article{yang2024visionzip,
title={VisionZip: Longer is Better but Not Necessary in Vision Language Models},
author={Yang, Senqiao and Chen, Yukang and Tian, Zhuotao and Wang, Chengyao and Li, Jingyao and Yu, Bei and Jia, Jiaya},
journal={arXiv preprint arXiv:2412.04467},
year={2024}
}
@article{yang2025visionthink,
title={VisionThink: Smart and Efficient Vision Language Model via Reinforcement Learning},
author={Yang, Senqiao and Li, Junyi and Lai, Xin and Yu, Bei and Zhao, Hengshuang and Jia, Jiaya},
journal={arXiv preprint arXiv:2507.13348},
year={2025}
}
Acknowledgement
-
This work is built upon LLaVA, mini-Gemini, Lmms-Eval, and Video-LLaVA. We thank them for their excellent open-source contributions.
-
We also thank StreamingLLM, FastV, SparseVLM, and others for their contributions, which have provided valuable insights.
License
- VisionZip is licensed under the Apache License 2.0.