Views
No views yet
| Models | VideoMME (w/o sub) | VideoMME (w sub) | ActivityNet-QA (test) | LongVideoBench (val) | PerceptionTest (val) | NExT-QA (mc) | VNBench (val) |
|---|---|---|---|---|---|---|---|
| LongVILA-7B | 60.1 | 65.1 | 59.5 | 57.1 | 58.1 | 80.7 | 63.0 |
| LongVILA-R1-7B | 65.0 | 70.7 | 64.8 | 58.0 | 68.9 | 81.5 | 75.5 |
| Models | Temporal | Goal | Plot | Spatial | Overall |
|---|---|---|---|---|---|
| LongVILA-R1-7B | 68.1 | 85.7 | 70.6 | 53.3 | 72.0 |
1from transformers import AutoModel
2
3model_path = "Efficient-Large-Model/LongVILA-R1-7B"
4model = AutoModel.from_pretrained(model_path, trust_remote_code=True, device_map="auto")
5
6# You can adjust the FPS value as needed.
7# To disable FPS control, set it to 0 and manually specify the number of processed video frames via `num_video_frames`.
8# Example:
9# model.config.fps = 8.0
10# model.config.num_video_frames, model.config.fps = 512, 0
11
12use_thinking = True # Switching between thinking and non-thinking modes
13system_prompt_thinking = "You are a helpful assistant. The user asks a question, and then you solves it.\n\nPlease first think deeply about the question based on the given video, and then provide the final answer. The reasoning process and answer are enclosed within <think> </think> and <answer> </answer> tags, respectively, i.e., <think> reasoning process here </think> <answer> answer here </answer>.\n\n Question: {question}"
14
15prompt = "What is the main purpose of the video?"
16video_path = "video.mp4"
17
18if use_thinking:
19 prompt = system_prompt_thinking.format(question=prompt)
20
21response = model.generate_content([prompt, {"path": video_path}])
22print("Response: ", response)vllm==0.9.1. We need to get the remote code first.1mkdir remote_code
2cp path_to/Efficient-Large-Model/LongVILA-R1-7B/*.py remote_code1import os
2from transformers import AutoModel
3from vllm import LLM, SamplingParams
4from remote_code.media import extract_media
5from remote_code.mm_utils import process_images
6from remote_code.tokenizer_utils import tokenize_conversation
7
8model_path = "path_to/Efficient-Large-Model/LongVILA-R1-7B"
9
10model_encoder = AutoModel.from_pretrained(model_path, trust_remote_code=True, device_map="auto", llm_only_need_embed=True)
11# you can change gpu_memory_utilization according to GPU memory
12llm = LLM(model=os.path.join(model_path, "llm"), enable_prompt_embeds=True, gpu_memory_utilization=0.5)
13
14use_thinking = True # Switching between thinking and non-thinking modes
15system_prompt_thinking = "You are a helpful assistant. The user asks a question, and then you solves it.\n\nPlease first think deeply about the question based on the given video, and then provide the final answer. The reasoning process and answer are enclosed within <think> </think> and <answer> </answer> tags, respectively, i.e., <think> reasoning process here </think> <answer> answer here </answer>.\n\n Question: {question}"
16
17prompt = "What is the main purpose of the video?"
18video_path = "video.mp4"
19
20if use_thinking:
21 prompt = system_prompt_thinking.format(question=prompt)
22
23conversation = [{"from": "human", "value": [prompt, {"path": video_path}]}]
24media = extract_media(conversation, model_encoder.config)
25input_ids = tokenize_conversation(conversation, model_encoder.tokenizer, add_generation_prompt=True).unsqueeze(0).cuda()
26media["video"] = [
27 process_images(images, model_encoder.vision_tower.image_processor, model_encoder.config).half()
28 for images in media["video"]
29]
30
31inputs_embeds, _, _ = model_encoder._embed(input_ids, media, {"video": {}}, None, None)
32
33completions = llm.generate(prompts=[{"prompt_embeds": inputs_embeds.squeeze(0)}], sampling_params=SamplingParams(max_tokens=1024))
34response = completions[0].outputs[0].text
35print("Response: ", response)1@misc{long-rl,
2 title = {Long-RL: Scaling RL to Long Sequences},
3 author = {Yukang Chen, Wei Huang, Shuai Yang, Qinghao Hu, Baifeng Shi, Hanrong Ye, Ligeng Zhu, Zhijian Liu, Pavlo Molchanov, Jan Kautz, Xiaojuan Qi, Sifei Liu,Hongxu Yin, Yao Lu, Song Han},
4 year = {2025},
5 publisher = {GitHub},
6 journal = {GitHub repository},
7 howpublished = {\url{https://github.com/NVlabs/Long-RL}},
8}1@article{chen2025longvila-r1,
2 title={Scaling RL to Long Videos},
3 author={Yukang Chen and Wei Huang and Baifeng Shi and Qinghao Hu and Hanrong Ye and Ligeng Zhu and Zhijian Liu and Pavlo Molchanov and Jan Kautz and Xiaojuan Qi and Sifei Liu and Hongxu Yin and Yao Lu and Song Han},
4 year={2025},
5 eprint={2507.07966},
6 archivePrefix={arXiv},
7 primaryClass={cs.CV}
8}1@inproceedings{chen2024longvila,
2 title={LongVILA: Scaling Long-Context Visual Language Models for Long Videos},
3 author={Yukang Chen and Fuzhao Xue and Dacheng Li and Qinghao Hu and Ligeng Zhu and Xiuyu Li and Yunhao Fang and Haotian Tang and Shang Yang and Zhijian Liu and Ethan He and Hongxu Yin and Pavlo Molchanov and Jan Kautz and Linxi Fan and Yuke Zhu and Yao Lu and Song Han},
4 booktitle={The International Conference on Learning Representations (ICLR)},
5 year={2025},
6}