モデル概要
モデル特徴
モデル能力
使用事例
🚀 Qwen2.5-VL-32B-Instruct
Qwen2.5-VL-32B-Instructは、画像や動画などの視覚情報を理解し、質問に回答することができるマルチモーダルモデルです。数学や問題解決能力が強化され、応答の詳細度と形式の明瞭さが向上しています。
🚀 クイックスタート
Qwen2.5-VLのコードは最新のHugging Face Transformersに含まれています。ソースからビルドすることをおすすめします。
pip install git+https://github.com/huggingface/transformers accelerate
以下のエラーが発生する場合があります。
KeyError: 'qwen2_5_vl'
また、様々なタイプの視覚入力をより便利に扱うためのツールキットも提供しています。
# 動画の読み込みを高速化するには、`[decord]`機能を使用することを強くおすすめします。
pip install qwen-vl-utils[decord]==0.0.8
Linuxを使用していない場合は、decord
をPyPIからインストールできない場合があります。その場合は、pip install qwen-vl-utils
を使用して、torchvisionを使用した動画処理にフォールバックすることができます。ただし、ソースからdecordをインストールすることで、動画の読み込み時にdecordを使用することができます。
🤗 Transformersを使用したチャット
以下は、transformers
とqwen_vl_utils
を使用してチャットモデルを使用するコード例です。
from transformers import Qwen2_5_VLForConditionalGeneration, AutoTokenizer, AutoProcessor
from qwen_vl_utils import process_vision_info
# デフォルト: 利用可能なデバイスにモデルをロード
model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
"Qwen/Qwen2.5-VL-32B-Instruct", torch_dtype="auto", device_map="auto"
)
# より高速な処理とメモリ節約のために、flash_attention_2を有効にすることをおすすめします。特に、複数の画像や動画のシナリオで有効です。
# model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
# "Qwen/Qwen2.5-VL-32B-Instruct",
# torch_dtype=torch.bfloat16,
# attn_implementation="flash_attention_2",
# device_map="auto",
# )
# デフォルトのプロセッサー
processor = AutoProcessor.from_pretrained("Qwen/Qwen2.5-VL-32B-Instruct")
# モデルでの画像ごとの視覚トークンのデフォルト範囲は4-16384です。
# パフォーマンスとコストをバランスさせるために、min_pixelsとmax_pixelsを必要に応じて設定することができます。例えば、トークン範囲を256-1280に設定することができます。
# min_pixels = 256*28*28
# max_pixels = 1280*28*28
# processor = AutoProcessor.from_pretrained("Qwen/Qwen2.5-VL-32B-Instruct", min_pixels=min_pixels, max_pixels=max_pixels)
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)
複数画像の推論
# 複数の画像とテキストクエリを含むメッセージ
messages = [
{
"role": "user",
"content": [
{"type": "image", "image": "file:///path/to/image1.jpg"},
{"type": "image", "image": "file:///path/to/image2.jpg"},
{"type": "text", "text": "Identify the similarities between these images."},
],
}
]
# 推論の準備
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)
動画の推論
# 動画としての画像リストとテキストクエリを含むメッセージ
messages = [
{
"role": "user",
"content": [
{
"type": "video",
"video": [
"file:///path/to/frame1.jpg",
"file:///path/to/frame2.jpg",
"file:///path/to/frame3.jpg",
"file:///path/to/frame4.jpg",
],
},
{"type": "text", "text": "Describe this video."},
],
}
]
# ローカル動画パスとテキストクエリを含むメッセージ
messages = [
{
"role": "user",
"content": [
{
"type": "video",
"video": "file:///path/to/video1.mp4",
"max_pixels": 360 * 420,
"fps": 1.0,
},
{"type": "text", "text": "Describe this video."},
],
}
]
# 動画URLとテキストクエリを含むメッセージ
messages = [
{
"role": "user",
"content": [
{
"type": "video",
"video": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen2-VL/space_woaudio.mp4",
},
{"type": "text", "text": "Describe this video."},
],
}
]
# Qwen 2.5 VLでは、フレームレート情報もモデルに入力され、絶対時間とのアライメントが行われます。
# 推論の準備
text = processor.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True
)
image_inputs, video_inputs, video_kwargs = process_vision_info(messages, return_video_kwargs=True)
inputs = processor(
text=[text],
images=image_inputs,
videos=video_inputs,
fps=fps,
padding=True,
return_tensors="pt",
**video_kwargs,
)
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)
動画URLの互換性は、主にサードパーティライブラリのバージョンに依存します。詳細は以下の表を参照してください。デフォルトのバックエンドを使用しない場合は、FORCE_QWENVL_VIDEO_READER=torchvision
またはFORCE_QWENVL_VIDEO_READER=decord
でバックエンドを変更できます。
バックエンド | HTTP | HTTPS |
---|---|---|
torchvision >= 0.19.0 | ✅ | ✅ |
torchvision < 0.19.0 | ❌ | ❌ |
decord | ✅ | ❌ |
バッチ推論
# バッチ推論のサンプルメッセージ
messages1 = [
{
"role": "user",
"content": [
{"type": "image", "image": "file:///path/to/image1.jpg"},
{"type": "image", "image": "file:///path/to/image2.jpg"},
{"type": "text", "text": "What are the common elements in these pictures?"},
],
}
]
messages2 = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who are you?"},
]
# バッチ処理のためにメッセージを結合
messages = [messages1, messages2]
# バッチ推論の準備
texts = [
processor.apply_chat_template(msg, tokenize=False, add_generation_prompt=True)
for msg in messages
]
image_inputs, video_inputs = process_vision_info(messages)
inputs = processor(
text=texts,
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_texts = processor.batch_decode(
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
)
print(output_texts)
🤖 ModelScope
特に中国本土のユーザーには、ModelScopeの使用を強くおすすめします。snapshot_download
を使用することで、チェックポイントのダウンロードに関する問題を解決することができます。
その他の使用方法
入力画像には、ローカルファイル、base64、URLをサポートしています。動画には、現在ローカルファイルのみをサポートしています。
# テキスト内の任意の位置に、ローカルファイルパス、URL、またはbase64エンコードされた画像を直接挿入することができます。
## ローカルファイルパス
messages = [
{
"role": "user",
"content": [
{"type": "image", "image": "file:///path/to/your/image.jpg"},
{"type": "text", "text": "Describe this image."},
],
}
]
## 画像URL
messages = [
{
"role": "user",
"content": [
{"type": "image", "image": "http://path/to/your/image.jpg"},
{"type": "text", "text": "Describe this image."},
],
}
]
## Base64エンコードされた画像
messages = [
{
"role": "user",
"content": [
{"type": "image", "image": "data:image;base64,/9j/..."},
{"type": "text", "text": "Describe this image."},
],
}
]
パフォーマンス向上のための画像解像度
モデルは広範囲の解像度入力をサポートしています。デフォルトでは、入力にネイティブ解像度を使用しますが、より高い解像度は計算量を増やす代わりにパフォーマンスを向上させることができます。ユーザーは、最小および最大ピクセル数を設定することで、速度とメモリ使用量をバランスさせる最適な設定を実現することができます。
min_pixels = 256 * 28 * 28
max_pixels = 1280 * 28 * 28
processor = AutoProcessor.from_pretrained(
"Qwen/Qwen2.5-VL-32B-Instruct", min_pixels=min_pixels, max_pixels=max_pixels
)
さらに、モデルに入力する画像サイズを細かく制御するための2つの方法を提供しています。
- min_pixelsとmax_pixelsを定義する: 画像は、min_pixelsとmax_pixelsの範囲内でアスペクト比を維持したままリサイズされます。
- 正確な寸法を指定する:
resized_height
とresized_width
を直接設定します。これらの値は、最も近い28の倍数に丸められます。
# min_pixelsとmax_pixels
messages = [
{
"role": "user",
"content": [
{
"type": "image",
"image": "file:///path/to/your/image.jpg",
"resized_height": 280,
"resized_width": 420,
},
{"type": "text", "text": "Describe this image."},
],
}
]
# resized_heightとresized_width
messages = [
{
"role": "user",
"content": [
{
"type": "image",
"image": "file:///path/to/your/image.jpg",
"min_pixels": 50176,
"max_pixels": 50176,
},
{"type": "text", "text": "Describe this image."},
],
}
]
長文の処理
現在のconfig.json
は、最大32,768トークンのコンテキスト長に設定されています。32,768トークンを超える大量の入力を処理するために、YaRNというモデルの長さ外挿を強化する手法を利用しています。これにより、長文でも最適なパフォーマンスを発揮することができます。
サポートされているフレームワークでは、config.json
に以下を追加してYaRNを有効にすることができます。
{
...,
"type": "yarn",
"mrope_section": [
16,
24,
24
],
"factor": 4,
"original_max_position_embeddings": 32768
}
ただし、この方法は時間的および空間的なローカライズタスクのパフォーマンスに大きな影響を与えるため、使用をお勧めしません。
同時に、長い動画入力の場合、MRoPE自体がidsをより節約的であるため、max_position_embeddingsを直接64kなどのより大きな値に変更することができます。
✨ 主な機能
最新のアップデート
元の機能に加えて、強化学習によりQwen2.5-VL-32Bの数学的および問題解決能力をさらに強化しました。これにより、モデルの主観的なユーザー体験も大幅に向上し、応答スタイルが人間の好みにより合うように調整されました。特に、数学、論理推論、知識ベースのQ&Aなどの客観的なクエリに対して、応答の詳細度と形式の明瞭さが著しく向上しています。
概要
Qwen2-VLがリリースされてから過去5か月間、多くの開発者がQwen2-VLのビジョン言語モデルを基に新しいモデルを構築し、貴重なフィードバックを提供してくれました。この間、私たちはより有用なビジョン言語モデルの構築に注力してきました。今日、私たちはQwenファミリーの最新メンバーであるQwen2.5-VLを紹介することを嬉しく思います。
主要な機能強化
- 視覚的な理解能力: Qwen2.5-VLは、花、鳥、魚、虫などの一般的な物体の認識に精通しているだけでなく、画像内のテキスト、チャート、アイコン、グラフィック、レイアウトを分析する能力も高いです。
- エージェント機能: Qwen2.5-VLは、推論し、ツールを動的に指示することができる視覚エージェントとして直接機能し、コンピューターや携帯電話の使用が可能です。
- 長い動画の理解とイベントのキャプチャ: Qwen2.5-VLは1時間以上の動画を理解することができ、今回は関連する動画セグメントを特定することでイベントをキャプチャする新機能を備えています。
- さまざまな形式での視覚的な位置特定: Qwen2.5-VLは、バウンディングボックスまたはポイントを生成することで画像内の物体を正確に位置特定することができ、座標と属性の安定したJSON出力を提供することができます。
- 構造化された出力の生成: 請求書、フォーム、テーブルなどのデータに対して、Qwen2.5-VLはその内容の構造化された出力をサポートし、金融、商取引などの用途に役立ちます。
モデルアーキテクチャの更新
- 動的解像度とフレームレートによる動画理解のトレーニング: 動的解像度を時間次元に拡張し、動的FPSサンプリングを採用することで、モデルがさまざまなサンプリングレートで動画を理解できるようにしました。それに応じて、時間次元のmRoPEをIDsと絶対時間のアライメントで更新し、モデルが時間的なシーケンスと速度を学習し、最終的に特定の瞬間を特定する能力を獲得できるようにしました。
* **効率的なビジョンエンコーダー**: ViTにウィンドウアテンションを戦略的に実装することで、トレーニングと推論の速度を向上させました。ViTアーキテクチャは、SwiGLUとRMSNormでさらに最適化され、Qwen2.5 LLMの構造と一致するように調整されています。 30億、70億、720億パラメータの3つのモデルがあります。このリポジトリには、命令調整された32BのQwen2.5-VLモデルが含まれています。詳細については、[ブログ](https://qwenlm.github.io/blog/qwen2.5-vl/)と[GitHub](https://github.com/QwenLM/Qwen2.5-VL)をご覧ください。
📦 インストール
Qwen2.5-VLのコードは最新のHugging Face Transformersに含まれています。ソースからビルドすることをおすすめします。
pip install git+https://github.com/huggingface/transformers accelerate
以下のエラーが発生する場合があります。
KeyError: 'qwen2_5_vl'
また、様々なタイプの視覚入力をより便利に扱うためのツールキットも提供しています。
# 動画の読み込みを高速化するには、`[decord]`機能を使用することを強くおすすめします。
pip install qwen-vl-utils[decord]==0.0.8
Linuxを使用していない場合は、decord
をPyPIからインストールできない場合があります。その場合は、pip install qwen-vl-utils
を使用して、torchvisionを使用した動画処理にフォールバックすることができます。ただし、ソースからdecordをインストールすることで、動画の読み込み時にdecordを使用することができます。
📚 ドキュメント
視覚
データセット | Qwen2.5-VL-72B (🤗🤖) |
Qwen2-VL-72B (🤗🤖) |
Qwen2.5-VL-32B (🤗🤖) |
---|---|---|---|
MMMU | 70.2 | 64.5 | 70 |
MMMU Pro | 51.1 | 46.2 | 49.5 |
MMStar | 70.8 | 68.3 | 69.5 |
MathVista | 74.8 | 70.5 | 74.7 |
MathVision | 38.1 | 25.9 | 40.0 |
OCRBenchV2 | 61.5/63.7 | 47.8/46.1 | 57.2/59.1 |
CC-OCR | 79.8 | 68.7 | 77.1 |
DocVQA | 96.4 | 96.5 | 94.8 |
InfoVQA | 87.3 | 84.5 | 83.4 |
LVBench | 47.3 | - | 49.00 |
CharadesSTA | 50.9 | - | 54.2 |
VideoMME | 73.3/79.1 | 71.2/77.8 | 70.5/77.9 |
MMBench-Video | 2.02 | 1.7 | 1.93 |
AITZ | 83.2 | - | 83.1 |
Android Control | 67.4/93.7 | 66.4/84.4 | 69.6/93.3 |
ScreenSpot | 87.1 | - | 88.5 |
ScreenSpot Pro | 43.6 | - | 39.4 |
AndroidWorld | 35 | - | 22.0 |
OSWorld | 8.83 | - | 5.92 |
テキスト
モデル | MMLU | MMLU-PRO | MATH | GPQA-diamond | MBPP | Human Eval |
---|---|---|---|---|---|---|
Qwen2.5-VL-32B | 78.4 | 68.8 | 82.2 | 46.0 | 84.0 | 91.5 |
Mistral-Small-3.1-24B | 80.6 | 66.8 | 69.3 | 46.0 | 74.7 | 88.4 |
Gemma3-27B-IT | 76.9 | 67.5 | 89 | 42.4 | 74.4 | 87.8 |
GPT-4o-Mini | 82.0 | 61.7 | 70.2 | 39.4 | 84.8 | 87.2 |
Claude-3.5-Haiku | 77.6 | 65.0 | 69.2 | 41.6 | 85.6 | 88.1 |
🔧 技術詳細
ベースモデル
- deepseek-ai/DeepSeek-V3-0324
- sesame/csm-1b
- Qwen/QwQ-32B
- deepseek-ai/DeepSeek-R1
- ds4sd/SmolDocling-256M-preview
- mistralai/Mistral-Small-3.1-24B-Instruct-2503
トレーニングデータセット
- nvidia/Llama-Nemotron-Post-Training-Dataset-v1
- FreedomIntelligence/medical-o1-reasoning-SFT
- facebook/natural_reasoning
- glaiveai/reasoning-v1-20m
評価指標
- accuracy
- bertscore
- code_eval
📄 ライセンス
このプロジェクトはApache-2.0ライセンスの下で提供されています。
引用
もし私たちの研究が役に立った場合、ぜひ引用してください。
@article{Qwen2.5-VL,
title={Qwen2.5-VL Technical Report},
author={Bai, Shuai and Chen, Keqin and Liu, Xuejing and Wang, Jialin and Ge, Wenbin and Song, Sibo and Dang, Kai and Wang, Peng and Wang, Shijie and Tang, Jun and Zhong, Humen and Zhu, Yuanzhi and Yang, Mingkun and Li, Zhaohai and Wan, Jianqiang and Wang, Pengfei and Ding, Wei and Fu, Zheren and Xu, Yiheng and Ye, Jiabo and Zhang, Xi and Xie, Tianbao and Cheng, Zesen and Zhang, Hang and Yang, Zhibo and Xu, Haiyang and Lin, Junyang},
journal={arXiv preprint arXiv:2502.13923},
year={2025}
}








