🚀 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}
}