🚀 Qwen2.5-VL-3B-Instruct-Geo
Qwen2.5-VL-3B-Instruct-Geo是Qwen家族的最新成员,是一款功能强大的视觉语言模型。它在视觉理解、动态决策、视频处理、视觉定位和结构化输出等方面表现出色,为金融、商业等领域的应用提供了有力支持。
🚀 快速开始
Qwen2.5-VL的代码已集成在最新的Hugging face transformers中,建议使用以下命令从源代码进行构建:
pip install git+https://github.com/huggingface/transformers accelerate
否则可能会遇到以下错误:
KeyError: 'qwen2_5_vl'
同时,我们提供了一个工具包,方便你更便捷地处理各种类型的视觉输入,就像使用API一样。该工具包支持base64、URL以及交错的图像和视频。你可以使用以下命令进行安装:
pip install qwen-vl-utils[decord]==0.0.8
如果你不使用Linux系统,可能无法从PyPI安装decord
。在这种情况下,你可以使用pip install qwen-vl-utils
,它将回退到使用torchvision进行视频处理。不过,你仍然可以从源代码安装decord,以便在加载视频时使用decord。
使用🤗 Transformers进行对话
这是一个经过监督微调的模型,你可以按照以下方式使用:
from transformers import AutoTokenizer, AutoProcessor, AutoModelForImageTextToText
from qwen_vl_utils import process_vision_info
from peft import PeftModel
model = AutoModelForImageTextToText.from_pretrained(
"kxxinDave/Qwen2.5-VL-instruct-3B-Geo",
device_map='auto',
torch_dtype=torch.bfloat16
)
processor = AutoProcessor.from_pretrained("kxxinDave/Qwen2.5-VL-instruct-3B-Geo")
messages = [
{
"role": "user",
"content": [
{
"type": "image",
"image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg",
},
{"type": "text", "text": "Describe this image."},
],
}
]
text = processor.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True
)
image_inputs, video_inputs = process_vision_info(messages)
inputs = processor(
text=[text],
images=image_inputs,
videos=video_inputs,
padding=True,
return_tensors="pt",
)
inputs = inputs.to("cuda")
generated_ids = model.generate(**inputs, max_new_tokens=128)
generated_ids_trimmed = [
out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
)
print(output_text)
✨ 主要特性
关键增强功能
- 视觉理解能力:Qwen2.5-VL不仅擅长识别常见物体,如花鸟鱼虫,还能对图像中的文本、图表、图标、图形和布局进行深入分析。
- 自主决策能力:Qwen2.5-VL可直接作为视觉代理,进行推理并动态调用工具,具备计算机和手机使用能力。
- 长视频理解与事件捕捉:Qwen2.5-VL能够理解超过1小时的视频,并具备通过定位相关视频片段来捕捉事件的新能力。
- 多格式视觉定位:Qwen2.5-VL可以通过生成边界框或点来准确地定位图像中的物体,并为坐标和属性提供稳定的JSON输出。
- 结构化输出生成:对于发票、表单、表格等扫描数据,Qwen2.5-VL支持生成其内容的结构化输出,有助于金融、商业等领域的应用。
模型架构更新
- 用于视频理解的动态分辨率和帧率训练:通过采用动态FPS采样,将动态分辨率扩展到时间维度,使模型能够理解不同采样率的视频。相应地,在时间维度上使用ID和绝对时间对齐更新mRoPE,使模型能够学习时间序列和速度,最终获得定位特定时刻的能力。

- 精简高效的视觉编码器:通过在ViT中策略性地实现窗口注意力,提高了训练和推理速度。同时,使用SwiGLU和RMSNorm进一步优化ViT架构,使其与Qwen2.5 LLM的结构保持一致。
我们有三个分别具有30亿、70亿和720亿参数的模型。本仓库包含经过指令微调的30亿参数的Qwen2.5-VL模型。更多信息,请访问我们的博客和GitHub。
📄 许可证
本项目采用Apache 2.0许可证。
📚 引用
如果您觉得我们的工作有帮助,请引用我们的成果:
@misc{qwen2.5-VL,
title = {Qwen2.5-VL},
url = {https://qwenlm.github.io/blog/qwen2.5-vl/},
author = {Qwen Team},
month = {January},
year = {2025}
}
@article{Qwen2VL,
title={Qwen2-VL: Enhancing Vision-Language Model's Perception of the World at Any Resolution},
author={Wang, Peng and Bai, Shuai and Tan, Sinan and Wang, Shijie and Fan, Zhihao and Bai, Jinze and Chen, Keqin and Liu, Xuejing and Wang, Jialin and Ge, Wenbin and Fan, Yang and Dang, Kai and Du, Mengfei and Ren, Xuancheng and Men, Rui and Liu, Dayiheng and Zhou, Chang and Zhou, Jingren and Lin, Junyang},
journal={arXiv preprint arXiv:2409.12191},
year={2024}
}
@article{Qwen-VL,
title={Qwen-VL: A Versatile Vision-Language Model for Understanding, Localization, Text Reading, and Beyond},
author={Bai, Jinze and Bai, Shuai and Yang, Shusheng and Wang, Shijie and Tan, Sinan and Wang, Peng and Lin, Junyang and Zhou, Chang and Zhou, Jingren},
journal={arXiv preprint arXiv:2308.12966},
year={2023}
}