Videomind 2B
VideoMind是一個多模態智能體框架,通過模擬人類思維的處理流程(如任務拆解、時刻定位與驗證和答案合成)來增強視頻推理能力。
下載量 207
發布時間 : 3/21/2025
模型概述
VideoMind是一個多模態大語言模型,專注於視頻文本到文本的任務,通過模擬人類思維的處理流程來增強視頻推理能力。
模型特點
多模態智能體框架
通過模擬人類思維的處理流程(如任務拆解、時刻定位與驗證和答案合成)來增強視頻推理能力。
角色分工
模型包含規劃器、定位器、驗證器和應答器四個角色,分別負責不同的推理任務。
高效推理
通過LoRA適配器技術實現不同角色的快速切換和高效推理。
模型能力
視頻理解
視頻時刻定位
視頻問答
多模態推理
使用案例
視頻分析
視頻問答
對視頻內容進行提問並獲取準確的回答。
能夠準確定位視頻中的關鍵時刻並生成相關答案。
視頻時刻定位
在長視頻中定位特定事件發生的時刻。
能夠精確識別並返回事件發生的時間段。
🚀 VideoMind-2B
VideoMind是一個多模態智能體框架,它通過模擬“類人”過程來增強視頻推理能力,例如“分解任務”、“定位和驗證時刻”以及“合成答案”。
🚀 快速開始
安裝環境
- 從GitHub克隆倉庫。
git clone git@github.com:yeliudev/VideoMind.git
cd VideoMind
- 初始化conda環境。
conda create -n videomind python=3.11 -y
conda activate videomind
- 安裝依賴項。
pip install -r requirements.txt
對於NPU用戶,請修改requirements.txt
的第18 - 25行。
快速推理演示
以下腳本展示瞭如何使用VideoMind的不同角色進行推理。有關此模型的更多詳細信息,請參考我們的GitHub倉庫。
import torch
from videomind.constants import GROUNDER_PROMPT, PLANNER_PROMPT, VERIFIER_PROMPT
from videomind.dataset.utils import process_vision_info
from videomind.model.builder import build_model
from videomind.utils.io import get_duration
from videomind.utils.parser import parse_span
MODEL_PATH = 'yeliudev/VideoMind-2B'
video_path = '<path-to-video>'
question = '<question>'
# initialize role *grounder*
model, processor = build_model(MODEL_PATH)
device = next(model.parameters()).device
# initialize role *planner*
model.load_adapter(f'{MODEL_PATH}/planner', adapter_name='planner')
# initialize role *verifier*
model.load_adapter(f'{MODEL_PATH}/verifier', adapter_name='verifier')
# ==================== Planner ====================
messages = [{
'role':
'user',
'content': [{
'type': 'video',
'video': video_path,
'min_pixels': 36 * 28 * 28,
'max_pixels': 64 * 28 * 28,
'max_frames': 100,
'fps': 1.0
}, {
'type': 'text',
'text': PLANNER_PROMPT.format(question)
}]
}]
# preprocess inputs
text = processor.apply_chat_template(messages, add_generation_prompt=True)
images, videos = process_vision_info(messages)
data = processor(text=[text], images=images, videos=videos, return_tensors='pt').to(device)
# switch adapter to *planner*
model.base_model.disable_adapter_layers()
model.base_model.enable_adapter_layers()
model.set_adapter('planner')
# run inference
output_ids = model.generate(**data, do_sample=False, temperature=None, top_p=None, top_k=None, max_new_tokens=256)
# decode output ids
output_ids = output_ids[0, data.input_ids.size(1):-1]
response = processor.decode(output_ids, clean_up_tokenization_spaces=False)
print(f'Planner Response: {response}')
# ==================== Grounder ====================
messages = [{
'role':
'user',
'content': [{
'type': 'video',
'video': video_path,
'min_pixels': 36 * 28 * 28,
'max_pixels': 64 * 28 * 28,
'max_frames': 150,
'fps': 1.0
}, {
'type': 'text',
'text': GROUNDER_PROMPT.format(question)
}]
}]
# preprocess inputs
text = processor.apply_chat_template(messages, add_generation_prompt=True)
images, videos = process_vision_info(messages)
data = processor(text=[text], images=images, videos=videos, return_tensors='pt').to(device)
# switch adapter to *grounder*
model.base_model.disable_adapter_layers()
model.base_model.enable_adapter_layers()
model.set_adapter('grounder')
# run inference
output_ids = model.generate(**data, do_sample=False, temperature=None, top_p=None, top_k=None, max_new_tokens=256)
# decode output ids
output_ids = output_ids[0, data.input_ids.size(1):-1]
response = processor.decode(output_ids, clean_up_tokenization_spaces=False)
print(f'Grounder Response: {response}')
duration = get_duration(video_path)
# 1. extract timestamps and confidences
blob = model.reg[0].cpu().float()
pred, conf = blob[:, :2] * duration, blob[:, -1].tolist()
# 2. clamp timestamps
pred = pred.clamp(min=0, max=duration)
# 3. sort timestamps
inds = (pred[:, 1] - pred[:, 0] < 0).nonzero()[:, 0]
pred[inds] = pred[inds].roll(1)
# 4. convert timestamps to list
pred = pred.tolist()
print(f'Grounder Regressed Timestamps: {pred}')
# ==================== Verifier ====================
# using top-5 predictions
probs = []
for cand in pred[:5]:
s0, e0 = parse_span(cand, duration, 2)
offset = (e0 - s0) / 2
s1, e1 = parse_span([s0 - offset, e0 + offset], duration)
# percentage of s0, e0 within s1, e1
s = (s0 - s1) / (e1 - s1)
e = (e0 - s1) / (e1 - s1)
messages = [{
'role':
'user',
'content': [{
'type': 'video',
'video': video_path,
'video_start': s1,
'video_end': e1,
'min_pixels': 36 * 28 * 28,
'max_pixels': 64 * 28 * 28,
'max_frames': 64,
'fps': 2.0
}, {
'type': 'text',
'text': VERIFIER_PROMPT.format(question)
}]
}]
text = processor.apply_chat_template(messages, add_generation_prompt=True)
images, videos = process_vision_info(messages)
data = processor(text=[text], images=images, videos=videos, return_tensors='pt')
# ===== insert segment start/end tokens =====
video_grid_thw = data['video_grid_thw'][0]
num_frames, window = int(video_grid_thw[0]), int(video_grid_thw[1] * video_grid_thw[2] / 4)
assert num_frames * window * 4 == data['pixel_values_videos'].size(0)
pos_s, pos_e = round(s * num_frames), round(e * num_frames)
pos_s, pos_e = min(max(0, pos_s), num_frames), min(max(0, pos_e), num_frames)
assert pos_s <= pos_e, (num_frames, s, e)
base_idx = torch.nonzero(data['input_ids'][0] == model.config.vision_start_token_id).item()
pos_s, pos_e = pos_s * window + base_idx + 1, pos_e * window + base_idx + 2
input_ids = data['input_ids'][0].tolist()
input_ids.insert(pos_s, model.config.seg_s_token_id)
input_ids.insert(pos_e, model.config.seg_e_token_id)
data['input_ids'] = torch.LongTensor([input_ids])
data['attention_mask'] = torch.ones_like(data['input_ids'])
# ===========================================
data = data.to(device)
# switch adapter to *verifier*
model.base_model.disable_adapter_layers()
model.base_model.enable_adapter_layers()
model.set_adapter('verifier')
# run inference
with torch.inference_mode():
logits = model(**data).logits[0, -1].softmax(dim=-1)
# NOTE: magic numbers here
# In Qwen2-VL vocab: 9454 -> Yes, 2753 -> No
score = (logits[9454] - logits[2753]).sigmoid().item()
probs.append(score)
# sort predictions by verifier's confidence
ranks = torch.Tensor(probs).argsort(descending=True).tolist()
pred = [pred[idx] for idx in ranks]
conf = [conf[idx] for idx in ranks]
print(f'Verifier Re-ranked Timestamps: {pred}')
# ==================== Answerer ====================
# select the best candidate moment
s, e = parse_span(pred[0], duration, 32)
messages = [{
'role':
'user',
'content': [{
'type': 'video',
'video': video_path,
'video_start': s,
'video_end': e,
'min_pixels': 128 * 28 * 28,
'max_pixels': 256 * 28 * 28,
'max_frames': 32,
'fps': 2.0
}, {
'type': 'text',
'text': question
}]
}]
text = processor.apply_chat_template(messages, add_generation_prompt=True)
images, videos = process_vision_info(messages)
data = processor(text=[text], images=images, videos=videos, return_tensors='pt').to(device)
# remove all adapters as *answerer* is the base model itself
with model.disable_adapter():
output_ids = model.generate(**data, do_sample=False, temperature=None, top_p=None, top_k=None, max_new_tokens=256)
# decode output ids
output_ids = output_ids[0, data.input_ids.size(1):-1]
response = processor.decode(output_ids, clean_up_tokenization_spaces=False)
print(f'Answerer Response: {response}')
🔖 模型詳情
屬性 | 詳情 |
---|---|
模型類型 | 多模態大語言模型 |
語言 | 英語 |
許可證 | BSD-3-Clause |
📖 引用
如果您覺得這個項目有用,請引用我們的論文。
@article{liu2025videomind,
title={VideoMind: A Chain-of-LoRA Agent for Long Video Reasoning},
author={Liu, Ye and Lin, Kevin Qinghong and Chen, Chang Wen and Shou, Mike Zheng},
journal={arXiv preprint arXiv:2503.13444},
year={2025}
}
📄 許可證
本項目採用BSD-3-Clause許可證。您可以點擊下面的鏈接查看更多信息:
Llava Video 7B Qwen2
Apache-2.0
LLaVA-視頻模型是基於Qwen2語言模型的7B參數多模態模型,專注於視頻理解任務,支持64幀視頻輸入。
視頻生成文本
Transformers 英語

L
lmms-lab
34.28k
91
Llava NeXT Video 7B DPO Hf
LLaVA-NeXT-Video是一個開源多模態聊天機器人,通過視頻和圖像數據混合訓練優化,具備優秀的視頻理解能力。
視頻生成文本
Transformers 英語

L
llava-hf
12.61k
9
Internvideo2 5 Chat 8B
Apache-2.0
InternVideo2.5是一款基於長且豐富上下文(LRC)建模增強的視頻多模態大語言模型,構建於InternVL2.5之上,通過提升感知細粒度細節和捕捉長時序結構的能力,顯著改進了現有MLLM模型。
視頻生成文本
Transformers 英語

I
OpenGVLab
8,265
60
Cogvlm2 Llama3 Caption
其他
CogVLM2-Caption是一個視頻描述生成模型,用於為CogVideoX模型生成訓練數據。
視頻生成文本
Transformers 英語

C
THUDM
7,493
95
Spacetimegpt
時空GPT是一個能夠進行空間和時間推理的視頻描述生成模型,能夠分析視頻幀並生成描述視頻事件的句子。
視頻生成文本
Transformers 英語

S
Neleac
2,877
33
Video R1 7B
Apache-2.0
Video-R1-7B是基於Qwen2.5-VL-7B-Instruct優化的多模態大語言模型,專注於視頻推理任務,能夠理解視頻內容並回答相關問題。
視頻生成文本
Transformers 英語

V
Video-R1
2,129
9
Internvl 2 5 HiCo R16
Apache-2.0
InternVideo2.5 是一個基於 InternVL2.5 構建的視頻多模態大語言模型(MLLM),通過長且豐富的上下文(LRC)建模進行了增強,能夠感知細粒度細節並捕捉長時態結構。
視頻生成文本
Transformers 英語

I
OpenGVLab
1,914
3
Videollm Online 8b V1plus
MIT
VideoLLM-online是一個基於Llama-3-8B-Instruct的多模態大語言模型,專注於在線視頻理解和視頻-文本生成任務。
視頻生成文本
Safetensors 英語
V
chenjoya
1,688
23
Videochat R1 7B
Apache-2.0
VideoChat-R1_7B 是一個基於 Qwen2.5-VL-7B-Instruct 的多模態視頻理解模型,能夠處理視頻和文本輸入,生成文本輸出。
視頻生成文本
Transformers 英語

V
OpenGVLab
1,686
7
Qwen2.5 Vl 7b Cam Motion Preview
其他
基於Qwen2.5-VL-7B-Instruct微調的攝像機運動分析模型,專注於視頻中的攝像機運動分類和視頻-文本檢索任務
視頻生成文本
Transformers

Q
chancharikm
1,456
10
精選推薦AI模型
Llama 3 Typhoon V1.5x 8b Instruct
專為泰語設計的80億參數指令模型,性能媲美GPT-3.5-turbo,優化了應用場景、檢索增強生成、受限生成和推理任務
大型語言模型
Transformers 支持多種語言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一個基於SODA數據集訓練的超小型對話模型,專為邊緣設備推理設計,體積僅為Cosmo-3B模型的2%左右。
對話系統
Transformers 英語

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基於RoBERTa架構的中文抽取式問答模型,適用於從給定文本中提取答案的任務。
問答系統 中文
R
uer
2,694
98