Exploring the Design Space of Visual Context Representation in Video MLLMs

## Abstract

Abstract Video Multimodal Large Language Models (MLLMs) have shown remarkable capability of understanding the video semantics on various downstream tasks. Despite the advancements, there is still a lack of systematic research on visual context representation, which refers to the scheme to select frames from a video and further select the tokens from a frame. In this paper, we explore the design space for visual context representation, and aim to improve the performance of video MLLMs by finding more effective representation schemes. Firstly, we formulate the task of visual context representation as a constrained optimization problem, and model the language modeling loss as a function of the number of frames and the number of embeddings (or tokens) per frame, given the maximum visual context window size. Then, we explore the scaling effects in frame selection and token selection respectively, and fit the corresponding function curve by conducting extensive empirical experiments. We examine the effectiveness of typical selection strategies and present empirical findings to determine the two factors. Furthermore, we study the joint effect of frame selection and token selection, and derive the optimal formula for determining the two factors. We demonstrate that the derived optimal settings show alignment with the best-performed results of empirical experiments. Our code and model are available at: https://github.com/RUCAIBox/Opt-Visor .

## 1 Introduction

Recent advancements in video Multimodal Large Language Models (*video MLLMs*) have shown the great potential in extending LLMs to process video data (Lin et al., ).
Typically, a video MLLM is developed based on a pre-trained LLM, and an image encoder will be attached to the LLM via a modality projector, which links the textual and visual semantic spaces. In this way, we can prompt the video MLLM with textual instruction and visual embeddings, to generate the natural language response for fulfilling the video-based task, *e.g.,* video question answering (Xu et al., ) and video captioning (Caba Heilbron et al., ).
Despite the success, it is still challenging for existing video MLLMs to handle complex or long videos, due to the limited model capacities.

To develop effective video MLLMs, previous research work mainly focuses on two aspects, either improving the model architecture (Wang et al., ) or enhancing the model training (Zhang et al., ; Liu et al., ). However, another important aspect has been missing in the related literature, *i.e.,* visual context representation. In this work, *visual context* refers to the visual embeddings in the prompt of video MLLMs. Unlike text and images, it is not very straightforward to represent a video. In existing approaches, a widely used way is to sample a number of frames from a video (*frame selection*) and then further sample or generate a number of embeddings for each selected frame (*embedding selection*). However, it is unclear how each factor affects the performance of video MLLMs, and how both factors jointly contribute to the performance improvement within the limited context length of the underlying LLM.

Considering this issue, in this paper, we take the initiative to explore the design space for visual context representation, and derive more effective representation schemes to improve the performance of video MLLMs.
Specifically, we firstly formulate the studied task as a constrained optimization problem: given the maximum visual context window size, we model the language modeling loss as a function of the number of frames and the number of embeddings (or tokens) per frame.
Such a formulation is useful to help understand the competitive relationships between frame selection and embedding selection.
Subsequently, we conduct extensive empirical experiments to explore the scaling effects in frame and embedding selection respectively, and fit the corresponding function to describe the performance trend.
Our findings show that: (1) overall increasing the number of visual embeddings (either tokens or frames) would enhance the performance, while scaling the frames can lead to consistently improved performance; (2)
the compression-based method can effectively preserve more semantic information with fewer visual embeddings.
Furthermore, we study the joint effect of the two factors and propose the method to find the optimal allocation given the limited context length, which is further supported by empirical experiments.

The major contributions of our work are as follows:

- •
To the best of our knowledge, this is the first work to systematically study the design of visual context, which is an important yet under-explored problem for developing capable video MLLMs. We provide both theoretical formulations and empirical findings to approach this problem. We also release a model under the Optimal Visual Context representation scheme, Opt-Visor, which can process videos up to 162 frames.
- •
We study the scaling effects of model performance *w.r.t.* the number of selected frames and the number of selected embeddings per frame respectively. We fit the corresponding function curve, and compare different strategies (*i.e.,* sampling- and compression-based methods) for both factors.
- •
We explore the trade-off relationships for frame and embedding selection, and suggest the optimal formula for determining the two factors. We demonstrate that the derived optimal settings show alignment with the best-performed results of empirical experiments.

## 2 Preliminary

In this section, we introduce the background for building the base model in our work.

##### Model Architecture.

Following existing works (Liu et al., ; Zhang et al., ), we adopt the LLaVA-like model architecture, consists of a visual encoder, an LLM, and a projector that maps the visual embeddings to the semantic space of the LLM. Formally, given a video with $T$ frames $\{I_{t}\}_{t=1}^{T}$, each frame is encoded by the image encoder $f_{\phi}$ to obtain $M$ visual embeddings $\{\textbf{v}^{t}_{i}\}_{i=1}^{M}$,
where $\textbf{v}^{t}_{i}\in\mathbb{R}^{d_{v}}$ denotes the $i$-th visual embedding in the $t$-th frame, and $d_{v}$ is the dimensionality of the visual embedding. Then the projector $f_{\psi}$ projects these visual embeddings into the semantic space of the LLM, producing $\textbf{h}_{i}^{t}\in\mathbb{R}^{d}$.
These visual embeddings are concatenated with the embeddings of a textual prompt $\{\textbf{e}_{j}\}_{j=1}^{N}$, where $\textbf{e}_{j}\in\mathbb{R}^{d}$ is the embedding of the $j$-th token in the prompt. The concatenated sequence is fed as input to the LLM $f_{\theta}$ to generate the output:

$$ $y_{1}\cdots y_{K}=f_{\theta}([\textbf{h}_{1}^{1},...,\textbf{h}_{M}^{1},..., \textbf{h}_{1}^{T},...,\textbf{h}_{M}^{T},\textbf{e}_{1},...,\textbf{e}_{N}])$ (1) $$

During training, we optimize the parameters $\{\phi,\psi,\theta\}$ by minimizing the next-token prediction loss.

Figure: Figure 1: Overview of the LLaVA-like architecture for video-MLLM, and our used frame-level and embedding-level operations for adjusting the visual context window size.
Refer to caption: x1.png

##### Training Data.

Based on existing instruction datasets, we mix several widely used image instruction and video instruction sets to construct a new instruction dataset. For the image instruction set, we adopt Cauldron (Laurençon et al., ), which is a large image instruction set based on 50 vision-language datasets. For the video instruction set, we collect the instructions from VideoChatGPT-100K (Muhammad Maaz & Khan, ), ShareGPT4Video (Chen et al., ), ShareGPTVideo (Zhang et al., ), VIM (Du et al., ), as well as some instruction data from VideoChat2 (Li et al., ). The statistics of each instruction set are listed in Table 7.

##### Implementation Details.

We adopt SigLIP (Zhai et al., ) as the image encoder, Qwen2-7B (Yang et al., ) as the base LLM, and a two-layer MLP as the projector. We train all the models with the training data listed in Table 7 for 1 epoch. We have tried to include a pre-training stage before the visual instruction tuning, using the 558K pre-training data and only updated the parameters in the MLP following LLaVA (Liu et al., ), but found no obvious difference. All the experiments are conducted on 32 Nvidia H800, with the detailed hyperparameters listed in Table 8.

##### Evaluation Setup

To quantitatively assess the scaling effect of visual context in video MLLMs, we consider the following two metrics for evaluation:

$\bullet$ *Language Modeling Loss.* It is a continuous measure that reflects model performance in predicting the next token, which can be used to estimate the parameters of the scaling law function.
To align with the setting in Chinchilla (Hoffmann et al., ), each model will be trained for 1 epoch, to ensure that training samples have not been seen when we calculate the loss for evaluation.

$\bullet$ *Zero-shot Accuracy.* The zero-shot accuracy can reflect the performance of the model in the real-world application.
We select several long video understanding benchmarks for evaluation, including Event-Bench (Du et al., ) (only with the challenging episodic reasoning task), NBench (Zhao et al., ), MLVU (Zhou et al., ), and VideoMME (Fu et al., ). All the questions in these benchmarks are multiple-choice, and we use accuracy as the evaluation metric.

## 3 Scaling law of visual context

### 3.1 Problem Formulation

As introduced in Section 2, existing video LLMs typically follow the vision-language model architecture (Liu et al., ; Zhang et al., ), which represents a video into multiple representative frames.
Further, each frame will be encoded into a number of visual tokens or embeddings. The aggregation of the visual embeddings from all selected frames is referred to as *visual context* in this work.
To set the visual context, it is essential to determine two aspects when the base architecture is fixed:
(1) how to select the frames from a video (*frame selection*), and (2) how to select the visual embeddings from an input frame (*embedding selection*).
Since the base architecture is developed on an existing LLM, the length of visual context is naturally limited by its context length, *i.e.,* the maximum length of input tokens. The two aspects would be competitive in input length allocation: the more the selected frames, the fewer the visual embeddings per selected frame, and vice versa.

In this work, we study the optimal allocation relationship of the visual context for a given video. Formally, we model the language modeling loss $\mathcal{L}(T,M)$ as a function of the number of frames $T$ and the number of embeddings (or tokens) per frame $M$. Given the maximum visual context window size $L$, the number of frames $T$ and visual embeddings per frame $M$ should satisfy the constraint: $T\times M<L$, we aim to find the optimal solution in minimizing $\mathcal{L}(T,M)$ under this constraint:

$$ $T_{\text{opt}}(L),M_{\text{opt}}(L)=\underset{T,M\text{ s.t. }T\times M<L}{ \operatorname{argmin}}\mathcal{L}(T,M),$ (2) $$

where $T_{\text{opt}}(L)$ and $M_{\text{opt}}(L)$ represent the optimal allocation strategy for the frame and visual embedding, respectively, with the input limit $L$.
To approach it, in the following, we will explore the scaling effect of the number of frames and embeddings in Section 3.2 and Section 3.3 respectively.

### 3.2 Scaling Effect of the Visual Embeddings

We first analyze the scaling effect of visual embeddings in a frame for a fixed number of frames. Specifically, we utilize two methods to select (or generate) the visual embeddings in a frame: the sampling- and compression-based method.

#### 3.2.1 Sampling-based Method

##### Experimental Setup.

In this part, each image is first converted to $27\times 27$ embeddings by the image encoder, then we vary the number of sampled visual embeddings. Specifically, we uniformly sample $\{1^{2},2^{2},3^{2},4^{2},5^{2},6^{2},7^{2},9^{2},14^{2}\}$ embeddings from the $27\times 27$ embeddings, as illustrated in Figure 1. Other sampling methods like block sampling (Li et al., ) will be explored in future work. We set $T=32$ as the constant, and uniformly sample frames from each video and keep all other factors the same to train 9 video MLLMs with this setup of visual embeddings.

##### Fitting Function.

We propose the following function to fit the scaling law of visual embeddings:

$$ $\mathcal{L}(M)=L_{M}+\left(\frac{M_{0}}{M}\right)^{\alpha_{M}}$ (3) $$

We fit the language modeling loss with respect to the number of visual embeddings $M$ using the scipy curvefit function, obtaining $L_{M}=0.48,M_{0}=1.16\times 10^{-5},\alpha_{M}=0.1$, with $R^{2}=0.927$ indicating a good fit. The fit curve in Figure 2(a) shows that $\mathcal{L}(M)$ decreases with increasing $M$, following a power-law like trend. We calculate the mean squared error between the actual loss and predicted loss, obtaining a value of 0.0001, which indicates a very low fitting error.

Figure: (a) The scaling curve of visual embeddings.
Refer to caption: x2.png

##### Benchmark Performance Analysis

Table 1 shows the results of scaling visual embeddings on the evaluation benchmarks. Overall, the model performance improves as the number of visual embeddings increases, especially when it varies from 1 to 4. The improvement becomes more marginal with increasingly more visual embeddings.
However, when it exceeds some threshold, the performance starts to decrease. For example, using 196 tokens is worse than using 49 tokens. An interesting finding is that the language modeling loss with 196 embeddings is significantly smaller than that of the model trained with 49 embeddings, as shown in Figure 2(a), which indicates that model loss might not directly reflect the performance on downstream tasks.

**Table 1: Results of sampling-based method under different number of visual embeddings per frame.**
| # Frames | # Embed./<br>Frames | Event-<br>Bench | VNBench | MLVU | LongVideo-<br>Bench | VideoMME<br>wo/w-subs | Avg. |
| --- | --- | --- | --- | --- | --- | --- | --- |
| 32 | 1 | 21.67 | 14.96 | 48.67 | 40.56 | 42.48/52.04 | 36.73 |
| 32 | 4 | 23.33 | 21.11 | 50.72 | 44.88 | 45.44/54.81 | 40.05 |
| 32 | 9 | 25.33 | 24.15 | 52.42 | 43.82 | 45.85/54.67 | 41.04 |
| 32 | 16 | 23.00 | 27.85 | 52.29 | 46.70 | 49.22/57.11 | 42.20 |
| 32 | 25 | 22.33 | 26.22 | 55.18 | 47.08 | 50.44/58.26 | 43.25 |
| 32 | 36 | 20.33 | 29.48 | 56.05 | 47.76 | 50.07/58.04 | 43.62 |
| 32 | 49 | 23.33 | 28.52 | 55.41 | 48.90 | 51.30/59.74 | 44.53 |
| 32 | 81 | 24.00 | 29.41 | 55.12 | 48.90 | 50.04/57.30 | 44.13 |
| 32 | 196 | 26.00 | 27.78 | 56.53 | 47.69 | 48.63/55.59 | 43.70 |

#### 3.2.2 Compression-based Method

##### Experimental Setup.

We utilize the MeanPooling (Yao et al., ) strategy for compressing the visual embeddings, which has been widely used in visual information processing. Another advantage is that it does not introduce extra parameters, avoiding the influence of new factors in the experiments.
We apply MeanPooling with different kernel sizes on the feature map produced by the image encoder and obtain the condensed representation of the image. Specifically, each image is encoded into $27\times 27$ visual embeddings, on which we apply $p\times p$ mean pooling with stride $p$ ($p=\{2,3,4,5,6,7,9,14,27\}$), obtaining $\{1^{2},2^{2},3^{2},4^{2},5^{2},6^{2},7^{2},9^{2},14^{2}\}$ condensed embeddings per image. All the other factors are kept the same for fair comparison.

**Table 2: Model performance under different numbers of visual embeddings per frame, with the compression-based method.**
| # Frames | # Embed./<br>Frames | Event-<br>Bench | VNBench | MLVU | LongVideo-<br>Bench | VideoMME<br>wo/w-subs | Avg. |
| --- | --- | --- | --- | --- | --- | --- | --- |
| 32 | 1 | 18.67 | 18.44 | 49.45 | 39.88 | 41.33/49.15 | 36.15 |
| 32 | 4 | 24.33 | 27.04 | 52.77 | 43.44 | 46.11/55.93 | 41.60 |
| 32 | 9 | 22.33 | 27.41 | 53.83 | 45.11 | 47.78/55.41 | 41.98 |
| 32 | 16 | 20.33 | 28.96 | 55.04 | 46.32 | 49.85/58.15 | 43.11 |
| 32 | 25 | 23.00 | 28.67 | 54.21 | 46.02 | 49.85/58.11 | 43.31 |
| 32 | 36 | 27.33 | 30.00 | 53.73 | 48.45 | 50.33/58.74 | 44.76 |
| 32 | 49 | 21.33 | 29.93 | 54.84 | 47.16 | 49.96/58.37 | 43.60 |
| 32 | 81 | 23.33 | 27.33 | 57.59 | 48.60 | 52.00/59.37 | 44.70 |
| 32 | 196 | 29.00 | 31.56 | 56.81 | 52.24 | 53.56/59.48 | 47.11 |

##### Fitting Function.

We use Equation 3 to fit the scaling law and obtain $L_{M}=0.57,M_{0}=0.01,\alpha_{M}=0.39$, with $R^{2}=0.987$. We also calculate the mean square error of the predicted loss and the actual loss, a value of $5.32\times 10^{-5}$ indicates a good fit. Compared to the parameters of sampling-based method in Section 3.2.1, where $\alpha_{M}=0.1$, the $\alpha_{M}$ of the compression-based method is significantly larger, implying that increasing the number of embeddings using the compression-based method will result in faster loss decrease, as shown in Figure 2(a). Additionally, the compression-based method consistently yields a lower loss than the sampling-based method for the same number of visual embeddings. Unlike sampling-based methods, compression-based method does directly discard visual embeddings but instead aggregates information from them, which is useful to accelerate the optimization process.

##### Benchmark Performance Analysis

For the benchmark evaluation in Table 2, the overall accuracy consistently increases as the number of visual embeddings increases. This finding is significantly different from that in Table 1.
This result highlights the advantage of the compression-based method, which can preserve more information than the sampling-based method. The conclusion drawn from the benchmark evaluation aligns with that concluded from the language modeling loss.

### 3.3 Scaling Effect of the Selected Frames

Next, we continue to explore the scaling effect of the selected frames by varying its number $T$ while fixing the number of embeddings per frame $M$.
We also consider utilizing sampling-based and compression-based methods.

#### 3.3.1 Sampling-based Method

**Table 3: Experimental results under different number of frames, with the sampling-based method.**
| # Frames | # Embed./<br>Frames | Event-<br>Bench | VNBench | MLVU | LongVideo<br>Bench | VideoMME<br>wo/w-subs | Avg. |
| --- | --- | --- | --- | --- | --- | --- | --- |
| 8 | 49 | 21.67 | 15.70 | 46.30 | 44.73 | 44.85/52.74 | 37.67 |
| 16 | 49 | 22.67 | 23.33 | 52.53 | 46.78 | 49.74/57.59 | 42.11 |
| 32 | 49 | 21.33 | 29.93 | 54.84 | 47.16 | 49.96/58.37 | 43.60 |
| 48 | 49 | 22.67 | 34.15 | 56.22 | 48.75 | 52.81/59.11 | 45.62 |
| 64 | 49 | 25.33 | 32.59 | 57.23 | 47.08 | 52.59/58.93 | 45.63 |
| 96 | 49 | 26.67 | 37.26 | 60.97 | 48.60 | 53.26/60.85 | 47.94 |
| 128 | 49 | 25.67 | 39.70 | 61.44 | 51.40 | 56.11/61.63 | 49.33 |

##### Experimental Setup.

In existing works, it has become a widely used practice to sample frames uniformly from the original video to accommodate for the context length of LLM. Based on this method, we sample different numbers of frames from the video to explore the scaling effect, by varying $T$ in $\{1,8,16,32,48,64,96,128\}$.
In Section 4, we further increase $T$ to 162 to explore the limit of scaling frames. The maximum context length allowed by the computation memory is 8K, corresponding to 128 frames and 49 visual embeddings per frame. As a result, we adopt $4\times 4$ MeanPooling to keep 49 embeddings per frame and train 8 video MLLMs by varying the number of frames from 1 to 128.

##### Fitting Function.

Similarly, we use the following function to fit the scaling law of frames:

$$ $\mathcal{L}(T)=L_{T}+\left(\frac{T_{0}}{T}\right)^{a_{T}}$ (4) $$

We fit the losses with the number of frames $T$ and obtain $L_{T}=0.14,T_{0}=5.37\times 10^{-7},\alpha_{T}=0.04$, with $R^{2}=0.892$. The fitted curve in Figure 2(a) shows that $\mathcal{L}(T)$ decreases with increasing $T$, following a power-law like trend. We calculate the mean squared error between the actual loss and predicted loss, obtaining a value of 0.0001, which indicates a very low fitting error.

Figure: (a) The scaling curve of frames.
Refer to caption: x4.png

##### Benchmark Performance Analysis

The results in Table 3 and Figure 3(b) show that as the number of frames increases, the model consistently improves on all benchmarks, with no clear saturation point, even at 128 frames, which exceeds the maxinum frame count of most video MLLMs. Among all the benchmarks, VNBench shows that the most pronounced improvements (from 15.70 to 39.70), suggesting that the Needle-In-the-Haystack-Search (NIAH) task benefits most from extended temporal context. However, the Event-Bench shows no significant improvement beyond 64 frames, and a detailed inspection reveals that all questions in Event-Bench focus on episodic reasoning, a task that cannot be effectively learned by video MLLMs simply by increasing the number of frames (Li et al., ). Overall, compared to scaling the visual embeddings per frame (Figure 2(b)), increasing the frames is more beneficial for improving the model performance.

##### Performance Compensating for Compressing Visual Embeddings.

Another interesting finding is that the performance degradation caused by compressing visual embeddings can be compensated by increasing the number of frames. Specifically, Table 2 shows that reducing the number of visual embeddings per frame from 196 to 49 leads to a performance drop across all benchmarks. However, if we simultaneously increase the number of frames to 128, the accuracy returns, even surpassing the model with 196 embeddings (comparing the last rows of Table 2 and Table 3, both setups use a total of 6272 visual embeddings, but one utilizes 32 frames with 196 embeddings per frame, while the other employs 128 frames with 49 embeddings per frame). These results suggest that when constrained by the visual context length, we can increase the number of frames while decreasing the embeddings per frame to achieve better performance, as will be further demonstrated in Section 4.

**Table 4: Model performance with the compression-based method under different numbers of frames. For the model trained with 128 frames, since $T_{\text{max}}=T=128$ in this setting, the temporal pooling kernel size is $l=\lceil\frac{128}{128}\rceil=1$, resulting in the same outcome as the sampling-based method.**
| # Frames | # Embed./<br>Frames | Event-<br>Bench | VNBench | MLVU | LongVideo<br>Bench | VideoMME<br>wo/w-subs | Avg. |
| --- | --- | --- | --- | --- | --- | --- | --- |
| 8 | 49 | 25.67 | 20.89 | 53.04 | 46.32 | 50.48/57.41 | 42.30 |
| 16 | 49 | 27.00 | 27.04 | 55.77 | 48.07 | 50.44/58.30 | 44.44 |
| 32 | 49 | 25.33 | 29.78 | 59.37 | 48.52 | 53.81/60.93 | 46.29 |
| 48 | 49 | 24.33 | 37.41 | 59.31 | 47.61 | 52.07/59.81 | 46.76 |
| 64 | 49 | 29.00 | 36.30 | 61.03 | 47.61 | 53.70/60.56 | 48.03 |
| 128^∗ | 49 | 25.67 | 39.70 | 61.44 | 51.40 | 56.11/61.63 | 49.33 |

#### 3.3.2 Compression-based Method

##### Experimental Setup.

Compressing frames along the temporal dimension has been widely discussed in the field of video representation learning but remains underexplored in video MLLMs (Cheng et al., ). Similar to the compression strategy used in Section 3.2, we utilize MeanPooling here to reduce the number of frames input to the LLM. Specifically, we uniformly sample $T_{\text{max}}$ frames(^1^11If the original video duration $T^{\prime}\leq T_{\text{max}}$, we uniformly sample $T^{\prime}$ frames from it; otherwise, we uniformly sample $T_{\text{max}}$ frames, which is a common practice for video MLLMs.) from the video and encode them with the image encoder. Then, we apply MeanPooling along the temporal dimension to compress the video into $T$ frames, where the temporal pooling kernel size $l$ is determined by $T_{\text{max}}$ and $T$: $l=\lceil\frac{T_{\text{max}}}{T}\rceil$. Due to the limitation of computational memory, we set $T_{\text{max}}=128$ and $T=\{8,16,32,48,64,128\}$ to explore the scaling law, which is significantly larger than existing state-of-the-art video MLLMs that mostly use 32 or 64 frames as input (Li et al., ; Cheng et al., ). To ensure a fair comparison with the sampling-based method, we also reduce the number of visual embeddings per frame to 49. In practice, we utilize three-dimensional MeanPooling, instead of first performing spatial MeanPooling followed by temporal MeanPooling, to avoid over-smoothing of the feature maps.

##### Fitting Function.

Different from the previous experiments, a power-law like function can’t fit the data points in this part.
Instead, we find that a simple linear function can well describe the function relationship, which is defined as follows:

$$ $\mathcal{L}(T)=a\times T+b$ (5) $$

We fit the losses with the number of frames $T$ and obtain $a=-0.0002,b=0.651$, with $R^{2}=0.807$. The fit curve is shown in Figure 3(a). We calculate the mean squared error between the actual loss and predicted loss is $1.753\times 10^{-5}$, which indicates a very low fitting error.

##### Benchmark Performance Analysis

Comparing the curve of the sampling-based method and the compression-based method, the latter always results in lower loss than the former. This phenomenon reveals the temporal redundancy in video data, showing that temporal information can still be effectively preserved even when compressed into fewer frames. The evaluation results on the benchmarks are shown in Table 4. Overall, increasing the number of frames always leads to improved model performance. Additionally, compared with the sampling-based method, the compression-based method consistently achieves higher accuracy with the same number of frames. This aligns with the phenomenon that the compression-based method generally gives lower training loss as depicted in Figure 3(a).

## 4 Trade-off between Visual Embeddings and Frames

Section 3.2 and Section 3.3 have discussed the scaling effect of visual embeddings and frames separately.
In this section, we explore the joint effect of the two factors, and study the problem: *how to jointly determine the numbers of visual embeddings and frames under the constraint of maximum input length of LLM or deployment resource?* Based on the theoretical and empirical analysis, we present a video MLLM under the Optimal Visual Context representation scheme, Opt-Visor, which can process videos up to 162 frames.

##### Fitting Function of the Two Factors.

Following Hoffmann et al. (), we fit the losses by considering the numbers of embeddings $M$ and frames $T$ as follows:

$$ $\mathcal{L}(M,T)=C_{M}\times M^{-\alpha}+C_{T}\times T^{-\beta}+L_{0}$ (6) $$

Specifically, we set the number of visual embeddings as $\{25,81\}$, and set the number of frames as $\{48,64,80,96\}$, train $2\times 4=8$ models in total. To extend the data points, we also include the 17 models trained in Section 3, and finally obtain 25 models in total.
We obtain $C_{M}=0.25,\alpha=0.26,C_{T}=0.13,\beta=0.21,L_{0}=0.50$, with $R^{2}=0.884$. The fit curve along the axes of $T$ and $M$ is shown in Figure 4.
With the decreasing of both $T$ and $M$, the loss $\mathcal{L}(M,T)$ will consistently increase, reaching the highest loss at the data point $T=32,M=4$ in our experiment.
In contrast, as the $M$ and $T$ increase, the loss gradually decreases, and $T=128,m=49$ reaches the lowest loss.
The computed gradient via the fitting function can help determine whether to increase $M$ or $T$ to achieve a lower loss. For example, the derivatives at $T=32,M=4$ are $\frac{\partial\mathcal{L}}{\partial M}=-0.01,\frac{\partial\mathcal{L}}{
\partial T}=-0.004$, indicating that $\mathcal{L}$ descends faster along the $M$ direction. Therefore, increasing the number of embeddings is more promising to obtain lower loss, which aligns with our experiments.

Figure: Figure 4: The scaling law of the visual embeddings and frames. We also display the maximum point and the minimum point in our experiments.
Refer to caption: x6.png

##### Finding Optimal Setting.

In practice, we are interested in the question that “given the visual context window $L$, what is the best choice of $M$ and $T$ that achieves the lowest loss $\mathcal{L}(M,T)$”? To answer this question, we utilize the Lagrange multiplier method to obtain the minimum point of Equation 6 under the constraint $M\times T<L$:

$$ $T_{\text{opt}}=\left(\frac{L}{\left(\frac{\beta C_{T}}{\alpha C_{M}}\right)^{ \frac{1}{1-\alpha}}}\right)^{\frac{1-\alpha}{2-\beta-\alpha}},\text{~{}~{}~{}~ {}~{}~{}~{}}M_{\text{opt}}=\left(\frac{\beta C_{T}}{\alpha C_{M}}\right)^{ \frac{1}{1-\alpha}}T^{\frac{1-\beta}{1-\alpha}}$ (7) $$

To verify the effectiveness of this principle, we set $L$ as 6K and obtain $T_{\text{opt}}\approx 118$ and $M_{\text{opt}}\approx 51$ according to Equation 7. For the experiment, we vary the number of visual embeddings and frames simultaneously under a fixed visual context length, yielding five $\langle T,M\rangle$ configurations: $\langle 8,729\rangle,\langle 30,196\rangle,\langle 72,81\rangle,\langle 120,49
\rangle,\langle 162,36\rangle$. For each configuration, we train a video MLLM and calculate the language modeling loss. We also evaluate these models on the long video understanding benchmarks. The results in Table 5 show that the minimum loss is achieved with 120 frames and 49 visual embeddings per frame, which is quite near to $T_{\text{opt}}\approx 118$ and $M_{\text{opt}}\approx 51$. As for the benchmark evaluation, scaling the number of frames consistently improves overall performance without saturation, even with 162 frames and 36 visual embeddings. This phenomenon occurs because there remains a gap between the next-token-prediction loss and final performance on downstream tasks, but the theoretical minimum point can serve as a strong starting point for subsequent optimization.

**Table 5: Model performance under the same number of total visual embeddings.**
| # Frames | # Embed./<br>Frames | # Total<br>Embed. | Loss $\downarrow$ | Event-<br>Bench | VNBench | MLVU | LongVideo<br>Bench | VideoMME<br>wo/w-subs | Avg. |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 8 | 729 | 5832 | 0.642 | 18.33 | 16.30 | 50.98 | 43.44 | 46.22/53.67 | 38.16 |
| 30 | 196 | 5880 | 0.648 | 28.67 | 31.11 | 54.97 | 48.90 | 53.19/60.19 | 46.17 |
| 72 | 81 | 5832 | 0.648 | 24.33 | 37.56 | 58.37 | 50.34 | 53.04/61.11 | 47.46 |
| 120 | 49 | 5880 | 0.639 | 29.67 | 38.44 | 59.06 | 49.81 | 55.15/61.67 | 48.97 |
| 162 | 36 | 5832 | 0.653 | 33.00 | 40.67 | 62.83 | 50.04 | 55.19/62.00 | 50.62 |

**Table 6: Experiment results on representative long video understanding benchmarks.**
| Models | Training<br>Data | Event-<br>Bench | VNBench | VideoMME<br>wo/w-subs | MLVU | LongVideoBench |
| --- | --- | --- | --- | --- | --- | --- |
| Proprietary MLLMs |  |  |  |  |  |  |
| GPT-4o | Unknown | 37.33 | 64.4 | 71.9/77.2 | 64.6 | 66.7 |
| Gemini-1.5-Pro | Unknown | 38.67 | 66.7 | 75.0/81.3 | - | 64.0 |
| GPT-4V | Unknown | 27.00 | 48.9 | 59.9/63.3 | 49.2 | 59.1 |
| Qwen-VL-Max | Unknown | - | - | 51.3/51.2 | 42.2 | - |
| Open-source MLLMs |  |  |  |  |  |  |
| Video-CCAM-14B | 4.4M | - | - | 53.2/57.4 | 63.1 | - |
| Video-LLaVA-7B | 2M | 5.87 | 12.4 | 39.9/41.6 | 47.3 | - |
| LLaMA-VID-long-7B | 1.6M | 0.00 | 10.8 | - | 33.2 | - |
| MovieChat-7B | Unknown | 20.33 | - | - | 25.8 | - |
| VideoChat2-7B | 29M | 14.67 | 12.4 | 39.5/43.8 | - | - |
| ST-LLM-7B | Unknown | 16.67 | 22.7 | 37.9/42.3 | - | - |
| VideoLLaMA2-7B | 13.4M | - | - | 46.6/- | 48.5 | - |
| LongVA-7B | 1.3M | - | - | 52.6/- | 56.3 | - |
| LongViLA-8B | Unknown | - | - | 50.5/- | - | - |
| Opt-Visor-7B (Ours) | 2.6M | 32.00 | 45.41 | 54.9/62.0 | 63.6 | 51.63 |

##### Comparison with Existing MLLMs.

We compare our model with a series of representative MLLMs, including four proprietary MLLMs: GPT-4o (OpenAI, ), Gemini-1.5-Pro (Reid et al., ), GPT-4V (OpenAI, ), Qwen-VL-Max (Bai et al., ), as well as nine open-source MLLMs: Video-CCAM (Fei et al., ), Video-LLaVA (Lin et al., ), LLaMA-VID-long (Li et al., ), MovieChat (Song et al., ), VideoChat2 (Li et al., ), ST-LLM (Liu et al., ), VideoLLaMA2 (Cheng et al., ), LongVA (Zhang et al., ), and LongViLA (Xue et al., ). To improve the performance of our model, we apply several techniques during training. Specifically, we represent each image in the image instruction with the AnyRes encoding scheme (Zhang et al., ), where each image is divided into multiple tiles to simulate a short video. Additionally, to equip the model with the temporal understanding ability, we introduce a temporal prompt before each frame, resulting in the video representation *“1 <frame 1> 2 <frame 2> … n <frame n>”*, where *<frame i>* represent the visual embeddings of the $i$-th frame. Besides, we increase the global batch size from 64 to 128 and train the model for 2 epochs. Under this configuration, we re-train the model with $\langle T,M\rangle=\langle 120,49\rangle$ and name it Opt-Visor. We evaluate Opt-Visor and the baseline models on the long video understanding benchmarks. The results in Table 6 show that Opt-Visor achieves the best performance among all the open-source models, with only 2.6M training samples. Notably, our model even outperforms GPT-4V on certain benchmarks, such as Event-Bench and MLVU, demonstrating the effectiveness of our optimal visual context representation scheme.

## 5 Related Work

##### Scaling Law.

In the field of LLMs, many existing works have demonstrated that scaling the size of model parameters and training data can consistently improve the model capacity (Radford et al., ; Brown, ; Touvron et al., ). As a result, it is necessary to build a quantitative relationship between these scaling factors and the final performance, which is called the scaling law. Two representative scaling laws for LLM are proposed by Kaplan et al. () and Hoffmann et al. (), where the former one models the relationship between the loss and model size, dataset size, and the amount of computation budget independently, and the follower one models the relationship between loss and model size, dataset size simultaneously. Inspired by these works, several studies show that the scaling law also holds for different model architectures (Clark et al., ), training strategies (Gao et al., ), and can be transferred to other domains like information retrieval (Fang et al., ; Ardalani et al., ), computer vision (Zhai et al., ; Dehghani et al., ), and multi-modal (Radford et al., ; Alayrac et al., ).

##### Video MLLM.

Training an MLLM with long-context video understanding ability is a challenging task and remains underexplored. One line of work focuses on enabling long video training from the perspectives of training systems (Xue et al., ), training strategies (Liu et al., ), and model architectures (Wang et al., ). For example, LongVILA (Xue et al., ) proposes the first Multi-Modal Sequence Parallelism system for long-context training and inference. Kangaroo (Liu et al., ) utilizes a curriculum training pipeline to gradually increase the number of frames during training. LongLLaVA (Wang et al., ) adapts the model architecture to a hybrid of Mamba (Gu & Dao, ) and Transformer (Vaswani et al., ) blocks. Another line of work aims to enable long video understanding during inference (Song et al., ; Zhang et al., ). For example, MovieChat (Song et al., ) proposes a memory mechanism that includes a rapidly updated short-term memory and a compact long-term memory to store representations of long videos. LongVA (Zhang et al., ) extends the context window of an LLM and demonstrates that long video understanding can be directly transferred from an MLLM without any video-specific training.

##### Visual Embedding Compression.

Most existing MLLMs are typically composed of a vision encoder, an LLM, and a visual projector to project the image embeddings into the semantic space of the LLM. Early works like Flamingo (Alayrac et al., ) adopt a resampler, which inserts a cross-attention module into the LLM layer to extract visual features, and this is followed by IDEFICS (Laurençon et al., ) and Otter (Li et al., ). Similar to the resampler, BLIP-2 (Li et al., ) and InstructBLIP (Dai et al., ) utilize a cross-attention module called Q-Former to compress the image embeddings and directly input the resulting visual embeddings into the LLM. Another line of work, represented by LLaVA (Liu et al., ), directly projects the image embeddings into the semantic space of the LLM with an MLP, achieving decent performance and converging quickly. Based on this, several works (Yao et al., ; Cai et al., ) propose adding a pooling module after the MLP to reduce the number of visual embeddings. However, when adapting MLLMs to video tasks, the design of the projector is less explored. LLaVA-NeXT-Video (Zhang et al., ) and LLaVA-OneVision (Li et al., ) use mean pooling or bilinear interpolation to aggregate visual embeddings, while neglecting the temporal dependency of video frames. To model the temporal dependency, VideoLLaMA2 (Cheng et al., ) introduces a downsampling module and a spatial-temporal convolution module.

## 6 Conclusion

In this work, we explored the basic design space of visual context representation in video MLLMs from two major aspects, *i.e.,* determining the number of sampled frames per video (*frame selection*) and visual embeddings per frame (*embedding selection*). We conducted experiments based on widely-used Video-MLLM architecture using different sampling and compression strategies, and varied the number of visual embeddings and frames to collect the data points.
We first formulated the studied task as a constrained optimization problem, and then studied the scaling effects for frame selection and embedding selection.
Then, we fitted the performance function curve *w.r.t.* the two factors, and derived several important empirical findings to determine the two factors.
Finally, we modeled the joint effects of the two factors, derived the optimal setting, and then verified the effectiveness with empirical experiments.
Our work has revealed that visual context representation has an important effect on the model performance of video MLLMs, which is worth more research attention. In future work, we will investigate more strategies for frame and embedding selection, and also consider designing new architectures that can support video context representation.

## Limitation

In this work, we explore the basic design space of visual context modeling by varying the numbers of sampled frames per video and visual embeddings per frame. Although we also consider using different sampling and compressing strategies, there are also other important designs that should be explored in the future, *e.g.,* different backbone LLMs and visual encoders.
Furthermore, we only consider two metrics to study the scaling effect, *i.e.,* language modeling loss and zero-shot accuracy on benchmarks.
Besides, we conduct all the experiments on the classic LLaVA architecture. It is also necessary to test the effectiveness of our conclusion on other architectures.

## Appendix A Appendix

The details of the training data are listed in Table 7.

The training hyperparameters are listed in Table 8.

The estimated optimal visual tokens and frames for various visual context lengths are listed in table 9.

**Table 7: The statistics of our training data, including 1.8M image-text instructions and 0.7M video-text instructions.**
| Modality | Dataset | Samples |
| --- | --- | --- |
| Image-Text | Cauldron | 1.8M |
| Video-Text | VideoChatGPT-100K | 100K |
| ShareGPT4Video | 40K |  |
| ShareGPTVideo | 255K |  |
| VIM | 32K |  |
| NExT-QA | 40K |  |
| SthSthV2 | 40K |  |
| STAR | 40K |  |
| TextVR | 40K |  |
| CLEVRER | 80K |  |
|  | Kinetics-710 | 40K |
| Total | - | 2.5M |

**Table 8: Training hyperparameters.**
| Hyperparameter | Value |
| --- | --- |
| Global batch size | 64 |
| Gradient clipping | 1 |
| Weight decay | 0 |
| Warmup ratio | 0.03 |
| LLM lr | 2e-5 |
| Projector lr | 1e-4 |
| Vision encoder lr | 2e-6 |
| lr schedule | cosine |

**Table 9: Estimated Optimal Visual Tokens and Frames for Various Visual Context Lengths.**
| Visual Context Length | # Visual Tokens | # Frames |
| --- | --- | --- |
| 6,000 | 51 | 118 |
| 14,000 | 78 | 178 |
| 30,000 | 116 | 258 |
| 62,000 | 169 | 367 |
| 126,000 | 243 | 517 |

## Peer Reviews

confidence: 4
contribution: 3
initial_rating: 6
presentation: 3
questions: Besides the question in Weakness, how can you determine the function formation of Eqs. 3, 4, 5, and 6? Just observe from figures 2a, 3a, and 4?
soundness: 2
strengths: 1. The motivation and idea of this paper is straightforward.
2. The writing and structure organization of this paper is clear and easy to follow.
3. The experimental results are clearly clarified, and the statistics are persuasive.
summary: This paper mainly discusses the video frame and visual token per frame selection strategies for video MLLMs. Based on LLaVA-like architecture, this paper conducts several experiments, e.g., varying frame number while fixing visual token per frame and altering visual token per frame while fixing total frame number, to fit the loss curves. Finally, it proposes a fitting function of the two factors and draw an optimal combination conclusion.
weaknesses: 1. My main concern about this paper is the generalization of the final conclusion. As we all know, video MLLM is very large and complex. This paper uses only one model structure (SigLip + Qwen2-7B) to conduct experiments on several benchmarks. Is the final best setting ($T_{opt} \approx 118$ and $M_{opt} \approx 51$) generalizable to other models and benchmarks? If not, must we conduct several experiments to fit a new curve to find the best factor combination?
2. Based on the above question, if this paper is just an experiment report, readers cannot obtain enough inspiration from this paper.

---

confidence: 4
contribution: 3
initial_rating: 6
presentation: 3
questions: My major concerns lie in the soundness of the experiments. Please find more details in the 'Weaknesses' section
soundness: 3
strengths: 1. The paper is clearly written and follows a logical structure.  

2. The paper includes extensive experiments and offers a thorough analysis. Notably, the experiments that consider fixed frames, fixed embeddings per frame, and the trade-off between embeddings and frames are particularly useful for following research.
summary: Given a fixed Video-LLM window size, this paper examines the optimal selection of the number of video frames, the number of video tokens, and the compression/sampling methods used for frames and embeddings. The authors include experiments on both loss and benchmark evaluations.
weaknesses: 1. Is the design space for embedding and frame operations too narrow? The findings within this design space may be biased towards different LLM backbones and vision encoders. We suggest that the authors conduct experiments across a variety of LLM backbones and vision encoders to ascertain the generalizability of their findings. Or at least one more different LLM backbone and vision encoders.

2. In the experiments depicted in Figure 2 and Tables 1 & 2, the authors utilize the same T = 32 (L168) for all experiments, which results in video tokens of varying lengths within the same LLM context window size. It is generally assumed that longer tokens within a pretrained LLM context window size lead to better performance. How can it be determined whether longer visual embeddings after the vision encoder or longer visual tokens in the LLM contribute more significantly to performance improvements? 

3. Since this paper aims to study the scaling effect, conducting a sufficient number of experiments with training models is crucial to mitigate the impact of randomness bias. The authors should clarify the number of models trained for each data point presented in experiments.

---

confidence: 3
contribution: 2
initial_rating: 6
presentation: 3
questions: Figure 2b and 3b: In addition to the performance curves on each benchmark, it would be valuable to also plot the average over all of them.

Section 3: At the other end of the scaling spectrum, it would be interesting to also report the performance without any visual token at all (M=0) to see what would be the comparative performance of a "blind" MLLM.

Minor typo:
L325: "increasing the frames"
soundness: 3
strengths: The paper offers a valuable analysis of visual context representation design in video MLLMs. The approach is straightforward, with clearly explained experimental settings and well-presented results, and the conclusions are well-supported by experiments.

It is interesting to see the contribution of mean pooling versus uniform sampling, both for selecting frames and selecting tokens.

The authors promise to release code and data for reproducing their results.
summary: This paper analyses the input design space of Video Multimodal Large Language Models (MLLMs) by scaling two components: the number of frames and the number of tokens per frame.
Given the quadratic computational complexity of the attention mechanism in the number of input tokens, MLLMs are limited in the size of their input. This paper studies the impact of varying the number of frames and the number of tokens per frame, as well as the sampling and compression strategies to obtain the final tokens.
weaknesses: Comparison to SOTA results on the benchmarks.
It is understood that the goal of this paper is not to obtain SOTA results on the evaluated benchmarks, but rather to perform an analysis on the design space of visual context representation in video MLLMs. Nevertheless, it would be informative to the reader to have the information of how far the experimental recipes presented in this paper are from the SOTA.

Meta-review: In this paper, the authors presented a study about the design space of visual context representation in video multimodal large language models (MLLMs). Specifically, two components were considered for the analysis: the number of frames and the number of embeddings/tokens per frame. By exploring the scaling effects within these aspects, empirical findings were presented with an optimal formula for determining the two components. The main strengths of this paper are:
- The paper is well motivated and the idea is interesting, offering a valuable perspective for visual context representation design in video MLLMs. The idea is simple and straightforward, with a clear presentation.
-  Extensive experimental analysis was presented, showing several interesting and useful findings, e.g. the trade-off between embeddings and frames, the contribution of mean pooling vs. uniform sampling, etc. The analysis presented in this paper could be useful for follow-up research in the community.
- The paper is well-written, well-organised, and easy to follow.

The main weaknesses of the paper were mainly around the generalisation ability, the impact of the corresponding derived conclusions, unclear analysis of the contributions from different components, and comparison with state-of-the-art.

After the authors' rebuttal, followed by a few rounds of discussions, the above major concerns were addressed, and the reviewers were satisfied with the supplemented evidence. Two reviewers decided to raise their ratings, and the paper ended up with 1 Accept and 2 borderline Accept. Considering the consistent positive ratings and the potential contributions this paper could bring to the community, the AC is happy to recommend an Accept.
But the authors are strongly recommended to incorporate the additional experiments and discussions into their final version.

Decision: Accept (Poster)