Improve model card: Add pipeline tag, library name, full content, and sample usage

#1
by nielsr HF Staff - opened
Files changed (1) hide show
  1. README.md +220 -6
README.md CHANGED
@@ -1,13 +1,227 @@
1
  ---
2
- license: apache-2.0
 
 
3
  datasets:
4
  - QiWang98/VideoRFT-Data
5
  language:
6
  - en
 
7
  metrics:
8
  - accuracy
9
- base_model:
10
- - QiWang98/VideoRFT-SFT-3B
11
- - Qwen/Qwen2.5-VL-3B-Instruct
12
- pipeline_tag: visual-question-answering
13
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ base_model:
3
+ - QiWang98/VideoRFT-SFT-3B
4
+ - Qwen/Qwen2.5-VL-3B-Instruct
5
  datasets:
6
  - QiWang98/VideoRFT-Data
7
  language:
8
  - en
9
+ license: apache-2.0
10
  metrics:
11
  - accuracy
12
+ pipeline_tag: video-text-to-text
13
+ library_name: transformers
14
+ ---
15
+
16
+ # 🎥 $\text{VideoRFT}$: Incentivizing Video Reasoning Capability in MLLMs via Reinforced Fine-Tuning
17
+
18
+ This repository contains the **VideoRFT** model, presented in the paper [VideoRFT: Incentivizing Video Reasoning Capability in MLLMs via Reinforced Fine-Tuning](https://huggingface.co/papers/2505.12434).
19
+
20
+ <p align="center">
21
+ </a>&nbsp;&nbsp;📖 <a href="https://huggingface.co/papers/2505.12434">Paper</a>
22
+ </a>&nbsp;&nbsp; │ &nbsp;&nbsp;💻 <a href="https://github.com/QiWang98/VideoRFT">Code</a>
23
+ </a>&nbsp;&nbsp; │ &nbsp;&nbsp;📀 <a href="https://huggingface.co/datasets/QiWang98/VideoRFT-Data">CoT Dataset</a>
24
+ </a>&nbsp;&nbsp; │ &nbsp;&nbsp;📀 <a href="https://huggingface.co/datasets/QiWang98/VideoRFT-Data">RL Dataset</a>
25
+ </a>&nbsp;&nbsp; │ &nbsp;&nbsp;🤗 <a href="https://huggingface.co/QiWang98/VideoRFT">Models</a>
26
+ </p>
27
+
28
+ ## 📰 News
29
+ - [2025/09/19] Our paper has been **accepted to NeurIPS 2025** 🎉!
30
+ - [2025/06/01] We released our 3B Models ([🤗VideoRFT-SFT-3B](https://huggingface.co/QiWang98/VideoRFT-SFT-3B) and [🤗VideoRFT-3B](https://huggingface.co/QiWang98/VideoRFT-3B)) to huggingface.
31
+ - [2025/05/25] We released our 7B Models ([🤗VideoRFT-SFT-7B](https://huggingface.co/QiWang98/VideoRFT-SFT) and [🤗VideoRFT-7B](https://huggingface.co/QiWang98/VideoRFT)) to huggingface.
32
+ - [2025/05/20] We released our Datasets ([📀CoT Dataset](https://huggingface.co/datasets/QiWang98/VideoRFT-Data) and [📀RL Dataset](https://huggingface.co/datasets/QiWang98/VideoRFT-Data)) to huggingface.
33
+ - [2025/05/18] Our paper is released on [ArXiv](https://arxiv.org/abs/2505.12434), and we have open-sourced our code on [GitHub](https://github.com/QiWang98/VideoRFT)!
34
+
35
+ ## Abstract
36
+ Reinforcement fine-tuning (RFT) has shown great promise in achieving humanlevel reasoning capabilities of Large Language Models (LLMs), and has recently been extended to MLLMs. Nevertheless, reasoning about videos, which is a fundamental aspect of human intelligence, remains a persistent challenge due to the complex logic, temporal and causal structures inherent in video data. To fill this gap, we propose VideoRFT, a novel approach that extends the RFT paradigm to cultivate human-like video reasoning capabilities in MLLMs. VideoRFT follows the standard two-stage scheme in RFT: supervised fine-tuning (SFT) with chain-of-thought (CoT) annotations, followed by reinforcement learning (RL) to improve generalization. A central challenge to achieve this in the video domain lies in the scarcity of large-scale, high-quality video CoT datasets. We address this by building a multi-expert-driven, cognition-inspired CoT curation pipeline. First, we devise a cognition-inspired prompting strategy to elicit a reasoning LLM to generate preliminary CoTs based solely on rich, structured, and literal representations of video content. Subsequently, these CoTs are revised by a MLLM conditioned on the actual video, ensuring visual consistency and reducing visual hallucinations. This pipeline results in two new datasets, VideoRFT-CoT-102K for SFT and VideoRFT-RL-310K for RL. To further strengthen the RL phase, we introduce a novel semantic-consistency reward that explicitly promotes the alignment between textual reasoning and visual evidence. This reward encourages the model to produce coherent, context-aware reasoning outputs grounded in visual input. Extensive experiments show that VideoRFT achieves state-of-the-art performance on six video reasoning benchmarks.
37
+
38
+ ## 🔎 Overview
39
+
40
+ Reinforcement fine-tuning (RFT) has shown great promise in achieving humanlevel reasoning capabilities of Large Language Models (LLMs), and has recently been extended to MLLMs. Nevertheless, reasoning about videos, which is a fundamental aspect of human intelligence, remains a persistent challenge due to the complex logic, temporal and causal structures inherent in video data. To fill this gap, we propose $\textbf{VideoRFT}$, a novel approach that extends the RFT paradigm to cultivate human-like video reasoning capabilities in MLLMs. $\textbf{VideoRFT}$ follows the standard two-stage scheme in RFT: supervised fine-tuning (SFT) with chain-of-thought (CoT) annotations, followed by reinforcement learning (RL) to improve generalization. A central challenge to achieve this in the video domain lies in the scarcity of large-scale, high-quality video CoT datasets. We address this by building a fully automatic CoT curation pipeline. First, we devise a cognitioninspired prompting strategy to elicit a reasoning LLM to generate preliminary CoTs based solely on rich, structured, and literal representations of video content. Subsequently, these CoTs are revised by a visual-language model conditioned on the actual video, ensuring visual consistency and reducing visual hallucinations. This pipeline results in two new datasets $-$ VideoRFT-CoT-102K for SFT and VideoRFT-RL-310K for RL. To further strength the RL phase, we introduce a novel semantic-consistency reward that explicitly promotes the alignment between textual reasoning with visual evidence. This reward encourages the model to produce coherent, context-aware reasoning outputs grounded in visual input. Extensive experiments show that $\textbf{VideoRFT}$ achieves state-of-the-art performance on six video reasoning benchmarks.
41
+
42
+ <div align="center">
43
+ <img src="https://raw.githubusercontent.com/QiWang98/VideoRFT/main/images/overview.png" />
44
+ </div>
45
+
46
+ ## ✨ Methodology
47
+
48
+ To overcome the scarcity of video CoTs, we develop a scalable, cognitively inspired pipeline for high-quality video CoT dataset construction.
49
+
50
+ <div align="center">
51
+ <img src="https://raw.githubusercontent.com/QiWang98/VideoRFT/main/images/pipeline.png" width="95%" />
52
+ </div>
53
+
54
+ To further strength the RL phase, we introduce a novel semantic-consistency reward that explicitly promotes the alignment between textual reasoning with visual evidence.
55
+
56
+ <div align="center">
57
+ <img src="https://raw.githubusercontent.com/QiWang98/VideoRFT/main/images/grpo.png" width="95%" />
58
+ </div>
59
+
60
+ ## 📀 Datasets
61
+
62
+ Based on above pipeline, we construct two large-scale datasets, i.e., [📀VideoRFT-CoT-102K](https://huggingface.co/datasets/QiWang98/VideoRFT-Data) and [📀VideoRFT-RL-310K](https://huggingface.co/datasets/QiWang98/VideoRFT-Data).
63
+ <div align="center">
64
+ <img src="https://raw.githubusercontent.com/QiWang98/VideoRFT/main/images/dataset.png" width="50%" />
65
+ </div>
66
+
67
+ ## 🛠️ Set up
68
+
69
+ ### Requirements
70
+ * `Python >= 3.11`
71
+ * `Pytorch >= 2.5.1`
72
+ * `transformers == 4.51.3`
73
+ * `vLLM == 0.7.3`
74
+ * `trl == 0.16.0`
75
+
76
+ ### Installation
77
+ ```bash
78
+ git clone https://github.com/QiWang98/VideoRFT
79
+ cd VideoRFT
80
+
81
+ # Create and activate environment
82
+ conda create -n VideoRFT python=3.11
83
+ conda activate VideoRFT
84
+ bash setup.sh
85
+
86
+ # Install decord for improved video processing
87
+ cd src/qwen-vl-utils
88
+ pip install -e .[decord]
89
+ ```
90
+
91
+ ## 🚀 Training
92
+
93
+ ### Supervised Fine-Tuning (SFT)
94
+ We begin with supervised fine-tuning on the VideoRFT-CoT dataset for one epoch:
95
+
96
+ ```bash
97
+ bash ./src/scripts/run_sft_video.sh
98
+ ```
99
+
100
+ This step can be skipped by directly using our pretrained SFT models, available at [🤗VideoRFT-SFT-7B](https://huggingface.co/QiWang98/VideoRFT-SFT) or [🤗VideoRFT-SFT-3B](https://huggingface.co/QiWang98/VideoRFT-SFT-3B).
101
+
102
+ ### Reinforcement Learning (RL)
103
+
104
+ Next, perform reinforcement learning using the VideoRFT-RL dataset:
105
+
106
+ ```bash
107
+ bash ./src/scripts/run_grpo_video.sh
108
+ ```
109
+
110
+ To enable faster training via vLLM acceleration:
111
+
112
+ ```bash
113
+ bash ./src/scripts/run_grpo_vllm_qwen25vl.sh
114
+ ```
115
+
116
+ > **Note:** During training, we adopt the following settings for efficiency:
117
+
118
+ * **VIDEO PIXELS**: 128 × 28 × 28
119
+ * **FPS FRAMES**: 16
120
+
121
+ All frame-related configurations can be adjusted in `src/qwen-vl-utils`.
122
+
123
+ ## 📈 Inference & Evaluation
124
+
125
+ > During inference, we increase the maximum frame resolution and length to boost performance:
126
+
127
+ * **VIDEO PIXELS**: 256 × 28 × 28
128
+ * **FPS FRAMES**: 32
129
+
130
+ You can configure these parameters in `src/qwen-vl-utils`.
131
+
132
+ > We evaluate all models under a unified decoding configuration following the official Qwen2.5-VL demo:
133
+
134
+ * `top_p = 0.001`
135
+ * `temperature = 0.01`
136
+
137
+ ### Evaluation Procedure
138
+
139
+ 1. Download preprocessed evaluation JSONs from: [[🤗 eval](https://huggingface.co/datasets/Video-R1/Video-R1-eval)]
140
+
141
+ 2. Download the video data from the official sites of each benchmark and organize them as specified in the JSON files.
142
+
143
+ 3. Run the evaluation across all benchmarks:
144
+
145
+ ```bash
146
+ bash ./src/eval_bench.sh
147
+ ```
148
+
149
+ ## Quick Inference Code
150
+
151
+ ```python
152
+ import numpy as np
153
+ import torch
154
+ from longvu.builder import load_pretrained_model
155
+ from longvu.constants import (
156
+ DEFAULT_IMAGE_TOKEN,
157
+ IMAGE_TOKEN_INDEX,
158
+ )
159
+ from longvu.conversation import conv_templates, SeparatorStyle
160
+ from longvu.mm_datautils import (
161
+ KeywordsStoppingCriteria,
162
+ process_images,
163
+ tokenizer_image_token,
164
+ )
165
+ from decord import cpu, VideoReader
166
+
167
+ tokenizer, model, image_processor, context_len = load_pretrained_model(
168
+ "./checkpoints/longvu_qwen", None, "cambrian_qwen",
169
+ )
170
+
171
+ model.eval()
172
+ video_path = "./examples/video1.mp4"
173
+ qs = "Describe this video in detail"
174
+
175
+ vr = VideoReader(video_path, ctx=cpu(0), num_threads=1)
176
+ fps = float(vr.get_avg_fps())
177
+ frame_indices = np.array([i for i in range(0, len(vr), round(fps),)])
178
+ video = []
179
+ for frame_index in frame_indices:
180
+ img = vr[frame_index].asnumpy()
181
+ video.append(img)
182
+ video = np.stack(video)
183
+ image_sizes = [video[0].shape[:2]]
184
+ video = process_images(video, image_processor, model.config)
185
+ video = [item.unsqueeze(0) for item in video]
186
+
187
+ qs = DEFAULT_IMAGE_TOKEN + "
188
+ " + qs
189
+ conv = conv_templates["qwen"].copy()
190
+ conv.append_message(conv.roles[0], qs)
191
+ conv.append_message(conv.roles[1], None)
192
+ prompt = conv.get_prompt()
193
+
194
+ input_ids = tokenizer_image_token(prompt, tokenizer, IMAGE_TOKEN_INDEX, return_tensors="pt").unsqueeze(0).to(model.device)
195
+ stop_str = conv.sep if conv.sep_style != SeparatorStyle.TWO else conv.sep2
196
+ keywords = [stop_str]
197
+ stopping_criteria = KeywordsStoppingCriteria(keywords, tokenizer, input_ids)
198
+ with torch.inference_mode():
199
+ output_ids = model.generate(
200
+ input_ids,
201
+ images=video,
202
+ image_sizes=image_sizes,
203
+ do_sample=False,
204
+ temperature=0.2,
205
+ max_new_tokens=128,
206
+ use_cache=True,
207
+ stopping_criteria=[stopping_criteria],
208
+ )
209
+ pred = tokenizer.batch_decode(output_ids, skip_special_tokens=True)[0].strip()
210
+ ```
211
+
212
+ ## 🙏 Acknowledgements
213
+
214
+ We gratefully acknowledge the contributions of the open-source community, particularly [DeepSeek-R1](https://github.com/deepseek-ai/DeepSeek-R1), [Open-R1](https://github.com/huggingface/open-r1), and [R1-V](https://github.com/Deep-Agent/R1-V).
215
+
216
+ ## 📚 Citations
217
+
218
+ If you find this work helpful, please consider citing:
219
+
220
+ ```
221
+ @article{VideoRFT,
222
+ title={VideoRFT: Incentivizing Video Reasoning Capability in MLLMs via Reinforced Fine-Tuning},
223
+ author={Wang, Qi and Yu, Yanrui and Yuan, Ye and Mao, Rui and Zhou, Tianfei},
224
+ journal={arXiv preprint arXiv:2505.12434},
225
+ year={2025}
226
+ }
227
+ ```