---
title: 'QTSplus: Query-Aware Visual Token Selector'
url: https://www.emergentmind.com/topics/qtsplus
type: topic
---

# QTSplus: Query-Aware Visual Token Selector

QTSplus (Query-Aware Token Selector with Adaptive Budget) is a visual token selection architecture designed to address the scalability and efficiency bottlenecks in long-video multimodal language models (MLLMs). Integrated into the Qwen2.5-VL family, QTSplus dynamically selects a minimal, query-relevant subset of visual tokens between the vision encoder and language model, dramatically reducing vision token load and computational resources while maintaining or improving accuracy on temporally demanding video reasoning tasks [2511.11910].

## 1. Motivation and Context

Conventional MLLMs process every vision token extracted from long-form video, incurring computational, memory, and latency costs scaling linearly with video length and quadratically with the number of tokens during transformer attention. For video inputs reaching hundreds of frames and high spatial resolution, the resulting vision token count $M$ can easily surpass $10^5$, overwhelming the LLM’s cache and attention mechanisms.

QTSplus operates as an information gate: given a text query and the full set of video tokens $\mathcal X$, it adaptively routes only the most relevant $n \ll M$ to the LLM, with $n$ determined per instance and informed by the query and token statistics. This design aims to preserve video understanding accuracy while scaling MLLMs to longer and higher-frame-rate sequences.

## 2. Integration within Qwen2.5-VL Pipeline

In the Qwen2.5-VL stack, video input comprising $T$ frames is encoded by a frozen Vision Transformer (ViT), producing a flattened token sequence:
\[
\mathcal V = \{\mathbf f_t\}_{t=1}^T \rightarrow \mathcal X = [x_1, ..., x_M]^\top \in \mathbb{R}^{M \times d}
\]
where $M = (T/\Delta t)(HW/P^2)$. Normally, $\mathcal X$ would be directly provided to the LLM. QTSplus is inserted between the ViT and the LLM, replacing $\mathcal X$ with a compressed, query-centric set $\mathcal X' = [z_1, ..., z_n]^\top$, with $n \ll M$, that maintains both semantic coverage and temporal information.

The end-to-end sequence consists of:  
- Vision encoder → ViT tokens with absolute time encoding  
- QTSplus (cross-attention scoring → adaptive budget prediction → token selection → lightweight re-encoding)  
- Compressed tokens to LLM decoder

## 3. Architecture: Core Components and Algorithms

### 3.1 Cross-Attention Scoring

Relevance of each vision token $x_i$ to the input query sequence $\mathcal Q = (q_1, ..., q_L)$ is computed by a single-layer, multi-head cross-attention module:
\[
Q = \mathcal Q W^Q, \quad K = \mathcal X W^K
\]
For each head $h$ and text position $\ell$, the attention is
\[
\alpha_{h,\ell,i} = \mathrm{softmax}_i \left( \frac{Q_{h,\ell} K_{h,i}^\top}{\sqrt{d_h}} \right)
\]
Token relevance $r_i$ is obtained by:
\[
r_i = \max_{h = 1...h} \max_{\ell = 1...L} \alpha_{h,\ell,i}
\]
yielding a relevance vector $r \in [0,1]^M$ reflecting the peak attention incurred by any word-head combination.

### 3.2 Instance-Specific Retention Budget

QTSplus predicts the retention rate $\rho \in [\rho_{min}, \rho_{max}]$ for each instance by aggregating:
- Mean query embedding $s_q = \frac{1}{L}\sum_{\ell=1}^L q_\ell$
- $\log M$ (token count scale)
- Max relevance $\max_i r_i$
- Relevance entropy $H(p)$, with $p_i = r_i/\sum_j r_j$

The input $\phi_{in} = [s_q, \log M, \max_i r_i, H(p)]$ feeds a small MLP $\phi(\cdot)$. The logistic-transformed output predicts:
\[
\rho = \rho_{min} + (\rho_{max} - \rho_{min}) \, \sigma(u)
\]
with $u = w^\top \phi(\phi_{in}) + b$, and $n = \min(\lceil \rho M \rceil, n_{max})$.

### 3.3 Token Selection

#### 3.3.1 Training (Differentiable Top-n Gate)
During training, to maintain end-to-end differentiability, a soft Top-n gate is implemented using a threshold $t$ given by:
\[
\sum_{i=1}^M \sigma\left(\frac{r_i - t}{\tau_s}\right) = \rho M
\]
solved by Newton iterations. For each token, logits $[r_i - t, 0]$ are fed through a Gumbel-Softmax sampler ($\tau_s = 0.1$, hard sampling and straight-through gradients) to yield binary selection indicators $s_{keep,i} \in \{0,1\}$. Tokens with $s_{keep,i}=1$ are retained, and if none are selected, the token with maximal $r_i$ is forced to be kept.

#### 3.3.2 Inference (Hard Top-n Gate)
At inference, tokens are ranked by $r$ and the top-$n$ selected. Temporal ordering is restored post-selection.

### 3.4 Temporal Order Re-encoding

Absolute time encoding is added to all vision tokens. After selection, a shallow Transformer block (two layers: RMSNorm → MHA → RMSNorm → FFN, FlashAttention enabled, weights initialized from Qwen2.5-VL’s text model) re-encodes the token subset, yielding a stream that preserves both semantic relevance and precise timing, supporting second-level temporal localization.

## 4. Quantitative and Qualitative Performance

When incorporated into Qwen2.5-VL-3B-Instruct, QTSplus was evaluated on video inputs of up to 600 frames (e.g., 20 seconds at 30 fps):
- Vision-token load reduced from ≈180,000 to ≈20,000 ($89\%$ compression)
- End-to-end latency (single NVIDIA A100 GPU) reduced from ≈83 seconds to ≈60 seconds ($28\%$ speedup)

Across eight long-video understanding benchmarks (lmms-eval suite), QTSplus-3B matches the teacher model within $\pm$3 points on most metrics and improves:
- TempCompass direction accuracy by $+20.5$ points (from $43.58\%$ to $64.07\%$)
- TempCompass order accuracy by $+5.6$ points (from $63.91\%$ to $69.54\%$)
- Video-MMMU adaptation by $+2.0$ points (from $28.33\%$ to $30.33\%$)

A plausible implication is that attention-efficient routing of visual evidence enables temporally focused reasoning performance not accessible to uniform token downsampling approaches.

Fine-tuning the full LM (QTSplus-3B-FT) recovers or exceeds teacher performance on broad-coverage tasks, maintaining token and latency savings.

## 5. Training Regimes and Implementation Details

QTSplus variants include:
- QTSplus-3B (LLM frozen, $\approx$129 M QTSplus parameters, trained on VSCQ distillation)
- QTSplus-3B-FT (LLM + QTSplus, $\approx$3.2 B parameters, VSCQ and VQA distillation)

Critical hyperparameters:
- Cross-attention: 1 layer; Re-encoder: 2 layers
- Gumbel-Softmax temperature $\tau_s=0.1$
- Newton iterations for threshold $t$ solving: $J=6$
- Budget head MLP $\phi$: Two hidden layers (width 512, GELU)
- Compute-aware loss with $\lambda_t=\lambda_m=0.1$, $\lambda_s=0.01$

Optimization uses AdamW, learning rate $3 \times 10^{-5}$, batch size 64, up to 3 epochs. Experiments are conducted on 8× NVIDIA RTX 5090 GPUs and a 200-core Intel Xeon CPU.

## 6. Significance, Extensions, and Release Plan

QTSplus provides a general, lightweight, and highly efficient mechanism for scaling MLLMs to long-video scenarios with strict compute and memory requirements. Its principal architectural innovation—dynamic, query-aware budget prediction and token selection—enables global context preservation and fine-grained temporal localization without compromising downstream accuracy.

Continuous release of code, data, and weights is planned to facilitate community reproducibility and further development. The modular nature of QTSplus suggests straightforward extension to other large-scale multimodal domains with similar input redundancy and temporal complexity.

[2511.11910]

Source: https://www.emergentmind.com/topics/qtsplus