🚀 Apollo: 大規模マルチモーダルモデルにおけるビデオ理解の探求
Apolloは、ビデオ理解の最先端技術を推進する大規模マルチモーダルモデル(LMMs)のファミリーです。以下のタスクをサポートしています。
- 長時間ビデオの理解
- 時間的推論
- 複雑なビデオ質問応答
- ビデオ内容に基づく複数ターンの会話
Apolloモデルは、戦略的な設計により、1時間に及ぶ長時間ビデオの処理に優れ、速度と精度のバランスを取っています。わずか30億パラメータで、多くの70億パラメータの競合モデルを上回り、300億規模のモデルに匹敵する性能を発揮します。
主要な特長:
- スケーリングの一貫性: 小規模モデルとデータセットで検証された設計決定が、大規模にも効果的に適用でき、計算と実験コストを削減します。
- 効率的なビデオサンプリング: fpsサンプリングと高度なトークン再サンプリング戦略(例: Perceiver)により、強力な時間知覚能力を実現します。
- エンコーダの相乗効果: SigLIP - SO400M(画像)とInternVideo2(ビデオ)を組み合わせることで、強力な表現能力を提供し、時間的タスクで単一エンコーダを上回ります。
- ApolloBench: 真のビデオ理解能力に焦点を当てた、効率的な評価ベンチマーク(41倍高速)です。
🚀 クイックスタート
📦 インストール
pip install -e .
pip install flash-attn --no-build-isolation
💻 使用例
基本的な使用法
import torch
from transformers import AutoModelForCausalLM
from apollo.mm_utils import (
KeywordsStoppingCriteria,
tokenizer_mm_token,
ApolloMMLoader
)
from apollo.conversations import conv_templates, SeparatorStyle
from huggingface_hub import snapshot_download
model_url = "Apollo-LMMs/Apollo-3B-t32"
model_path = snapshot_download(model_url, repo_type="model")
device = "cuda" if torch.cuda.is_available() else "cpu"
model = AutoModelForCausalLM.from_pretrained(
model_path,
trust_remote_code=True,
low_cpu_mem_usage=True
).to(device=device, dtype=torch.bfloat16)
tokenizer = model.tokenizer
vision_processors = model.vision_tower.vision_processor
config = model.config
num_repeat_token = config.mm_connector_cfg['num_output_tokens']
mm_processor = ApolloMMLoader(
vision_processors,
config.clip_duration,
frames_per_clip=4,
clip_sampling_ratio=0.65,
model_max_length=config.model_max_length,
device=device,
num_repeat_token=num_repeat_token
)
video_path = "path/to/video.mp4"
question = "Describe this video in detail"
mm_data, replace_string = mm_processor.load_video(video_path)
conv = conv_templates["qwen_2"].copy()
conv.append_message(conv.roles[0], replace_string + "\n\n" + question)
conv.append_message(conv.roles[1], None)
prompt = conv.get_prompt()
input_ids = tokenizer_mm_token(prompt, tokenizer, return_tensors="pt").unsqueeze(0).to(device)
stop_str = conv.sep if conv.sep_style != SeparatorStyle.TWO else conv.sep2
stopping_criteria = KeywordsStoppingCriteria([stop_str], tokenizer, input_ids)
with torch.inference_mode():
output_ids = model.generate(
input_ids,
vision_input=[mm_data],
data_types=['video'],
do_sample=True,
temperature=0.4,
max_new_tokens=256,
top_p=0.7,
use_cache=True,
num_beams=1,
stopping_criteria=[stopping_criteria]
)
pred = tokenizer.batch_decode(output_ids, skip_special_tokens=True)[0].strip()
print(pred)
📚 詳細ドキュメント
引用
このプロジェクトが役に立った場合は、以下のように引用してください。
@article{zohar2024apollo,
title={Apollo: An Exploration of Video Understanding in Large Multimodal Models},
author={Zohar, Orr and Wang, Xiaohan and Dubois, Yann and Mehta, Nikhil and Xiao, Tong and Hansen-Estruch, Philippe and Yu, Licheng and Wang, Xiaofang and Juefei-Xu, Felix and Zhang, Ning and Yeung-Levy, Serena and Xia, Xide},
journal={arXiv preprint arXiv:2412.10360},
year={2024}
}
詳細については、プロジェクトウェブサイトを訪問するか、論文を参照してください。
📄 ライセンス
このプロジェクトは、Apache-2.0ライセンスの下で公開されています。
関連情報
属性 |
详情 |
モデルタイプ |
ビデオ理解をサポートする大規模マルチモーダルモデル |
訓練データ |
ApolloBench、Video - MME、MLVU、LongVideoBench、NExTQA、PerceptionTest |
推論 |
可能 |
パイプラインタグ |
ビデオテキスト-to-テキスト |
タグ |
video、video-understanding、vision、multimodal、conversational、qwen、custom_code、instruction-tuning |