モデル概要
モデル特徴
モデル能力
使用事例
🚀 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を使用していない場合は、PyPIからdecord
をインストールできない可能性があります。その場合は、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."},
],
}
]
パフォーマンス向上のための画像解像度
モデルは広範囲の解像度入力をサポートしています。デフォルトでは、ネイティブ解像度を入力として使用しますが、より高い解像度を使用すると、計算量が増える代わりにパフォーマンスが向上します。ユーザーは、最小および最大ピクセル数を設定して、速度とメモリ使用量をバランスさせる最適な構成を実現できます。例えば、トークン数の範囲を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
)
さらに、モデルに入力する画像サイズを細かく制御するための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の数学的および問題解決能力をさらに強化しました。これにより、モデルの主観的なユーザー体験も大幅に向上し、応答スタイルが人間の好みにより合うように調整されました。特に、数学、論理的推論、知識ベースの質問応答などの客観的なクエリに対して、応答の詳細度とフォーマットの明瞭さが著しく向上しています。
概要
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をIDと絶対時間のアライメントで更新し、モデルが時間的なシーケンスと速度を学習し、最終的に特定の瞬間を特定する能力を獲得できるようにしました。
- 簡素化された効率的なビジョンエンコーダー ViTにウィンドウアテンションを戦略的に実装することで、トレーニングと推論の速度を両方とも向上させました。ViTアーキテクチャは、SwiGLUとRMSNormでさらに最適化され、Qwen2.5 LLMの構造と一致するようになりました。
私たちは、30億、70億、720億のパラメータを持つ3つのモデルを用意しています。このリポジトリには、命令調整された32BのQwen2.5-VLモデルが含まれています。詳細については、ブログ と GitHub をご覧ください。
📦 インストール
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を使用していない場合は、PyPIからdecord
をインストールできない可能性があります。その場合は、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 |
📄 ライセンス
このプロジェクトは、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}
}









