Matryoshka Query Transformer for Large Vision-Language Models

Large Vision-Language Models (LVLMs) typically encode an image into a fixed number of visual tokens (e.g., 576) and process these tokens with a language model. Despite their strong performance, LVLMs face challenges in adapting to varying computational constraints. This raises the question: can we achieve flexibility in the number of visual tokens to suit different tasks and computational resources? We answer this with an emphatic yes. Inspired by Matryoshka Representation Learning, we introduce the Matryoshka Query Transformer (MQT), capable of encoding an image into m visual tokens during inference, where m can be any number up to a predefined maximum. This is achieved by employing a query transformer with M latent query tokens to compress the visual embeddings. During each training step, we randomly select m <= M latent query tokens and train the model using only these first m tokens, discarding the rest. Combining MQT with LLaVA, we train a single model once, and flexibly and drastically reduce the number of inference-time visual tokens while maintaining similar or better performance compared to training independent models for each number of tokens. Our model, MQT-LLAVA, matches LLaVA-1.5 performance across 11 benchmarks using a maximum of 256 tokens instead of LLaVA's fixed 576. Reducing to 16 tokens (8x less TFLOPs) only sacrifices the performance by 2.4 points on MMBench. On certain tasks such as ScienceQA and MMMU, we can even go down to only 2 visual tokens with performance drops of just 3% and 6% each. Our exploration of the trade-off between the accuracy and computational cost brought about by the number of visual tokens facilitates future research to achieve the best of both worlds.

Paper

References (44)

Scroll for more · 32 remaining

Similar papers

Peer review

Reviewer L7Jp7/10 · confidence 5/52024-06-15

Summary

This paper introduces a new concept called Matryoshka Query Transformer (MQT) that brings in the concept of Matryoshka information packing to make visual tokens flexible and can be used in multimodal vision language models like LLaVA. The reduced tokens tend to reduce the quadratic complexity of the language model due to potential flexibility in the processed visual tokens. Owing to this, there are significant efficiency benefits all the while retaining accuracy across various benchmarks. The paper also showcases analysis and further discussion on the technique. ---------------------------- The review will be short and does not reflect the time put in for the review or the quality of the paper. When the ideas are simple and clear -- I tend to write shorter reviews to the point.

Strengths

I will go sequentially 1) The paper is extremely well-written and easy to follow. 2) The core ideas, while not completely novel as mentioned by the authors, Matryoshka and the Query transformer, making them work together and showing incredible benefits is commendable and is a worthy contribution. 3) The modelling very clear and the mechanism to achieve and the details are very well fleshed out. 4) The experiments are extensive, with a good analysis. 5) Great job with visualizations and nice to see some TFLOPs measurement. 6) Good analysis beyond benchmark numbers. Overall, this is a solid work with practical utility. I have a few questions about the paper mentioned in the weaknesses and would appreciate answers for them in the rebuttal, however, I am happy with the paper and am willing to champion it unless there is something I am missing found by other reviewers.

Weaknesses

Most of these are not weaknesses, but rather questions 1) How are you measuring TFLOPs? What does it include, the cost of vision encoder? LLM processing and generation? I might have missed this in the paper and any pointer would be great. 2) While I understand the when you are picking a fixed # token for MQT, you make that choice before in hand. What happens if you actually just obtain 256 tokens and take the first 8? What will be the performance in that case? I know softmax etc make huge differences, but would be good to see that. 3) Any thoughts on sampling vs joint training? 4) Why is log-based (actually exponential) spacing so poor (not 3.5% as mentioned in the paper but 2.1% from the table) so much worse than fine granularity? This is a bit surprising to me because 256 token performance should not be affected because of the lower token counts. 5) In visualizations, what do you mean by one random token? I am looking forward to your answers on these things.

Questions

See above.

Rating

7

Confidence

5

Soundness

4

Presentation

4

Contribution

3

Limitations

Yes

Reviewer k14Y6/10 · confidence 4/52024-07-13

Summary

Authors try to use Matryoshka mechanism to guide the learning process of LVLMs such as llava. Authors show a pretty good scaling curve with different amount of visual tokens.

Strengths

1. The idea is interesting. 2. The presentation is clear. 3. The attention visualization is interesting.

Weaknesses

1. For a given image, which scale should I choose to achieve best trade off? Is there an answer? 2. Authors use more compute (2 epoch) to get the similar performance as LLaVA, is there any reason for this? 3. All designs are center upon the qformer. There is little study on this. How many layers do we need? Do we really need it?

Questions

1. What are the performance under other datasets like TextVQA and ChartQA? Those are dataset different from the natrual image distribution. 2. The visualizations are good but we don't have quantitive numbers to support your claim. Since those pictures can be cherry picked.

Rating

6

Confidence

4

Soundness

2

Presentation

2

Contribution

2

Limitations

See comments above.

Reviewer jmsV6/10 · confidence 3/52024-07-13

Summary

The paper considers multimodal vision transformers, in which we have a stream of both visual and textual tokens. Current architecture typically assume a fixed number $m$ of visual tokens. In contrast, the proposed `MQT` aims to achieves a dynamic number of visual tokens. This is done by integrating a form of compression+dropout mechanism during training. Specifically, the image tokens are compressed to $M$ tokens using cross-attention. To vary the number of tokens, the model only needs to use only $m < M$ queries from te cross-attention mechanism. At training time, this is done by randomly selecting $m$ and feeding the **first** $m$ queries.

Strengths

* The proposed method is a simple idea that can be added as plug-and-play to any model * generally the idea of using some form of dropout also often has benefits for regularization so it may also benefits more than efficiency * The paper is well written and has comprehensive ablation experiments

Weaknesses

- **Lack of comparison with dynamic baselines**: in the field of image-only ViT, there is a flourishing literature on dynamically reducing the number of tokens using merging or pruning or scale selection. I am not as familiar with this literature for multimodal models, but there does seem to be similar existing approaches: for instance, *LLaVA-PruMerge: Adaptive Token Reduction for Efficient Large Multimodal Models* is one, though it might be too recent for the authors to have considered it for the submission. However, more generally, having a simple off-the-shelf token merging/pruning approach for the ViT encoder would be interesting. - **No improvement over baselines in the low FLOPs regime**. From Figure 1, it seems that the benefits of the proposed `MQT` decrease in the low FLOPs regime, when increasing the sparsity ratio of $M / m$. This limits the usefulness of the methods in the realm of model efficiency, though it seems to be a useful and simple training strategy for the high FLOPs regime.

Questions

- How are the $m$ latent queries chosen at inference ? I am assuming $m$ is chosen as a hyperparameter, and the first $m$ queries are kept, however it is not very clear from the methods section - Addressing the **low FLOPs regime**: From Figure 1, it seems that the benefits of the proposed `MQT` decrease in the low FLOPs regime, when increasing the sparsity ratio of $M / m$. I think it is not necessarily a surprising result as increasing sparsity too much will severely impact accuracy. However, I am wondering how would the trade-off curves would look like when starting with a base `QRT` model with a smaller $M$ and lower sparsity ratio, i.e. with a model that would achieves same number of tokens/FLOPs, but where the relative sparsity ratio to achieve is less aggressive.

Rating

6

Confidence

3

Soundness

3

Presentation

3

Contribution

2

Limitations

The paper has a limitation section but in my opinion it does not fully address some limitations of the paper (e.g. no improvement in performance in the low FLOPs regime)

Reviewer gY5g5/10 · confidence 5/52024-07-15

Summary

This paper addresses the challenge of achieving flexibility in the number of visual tokens to suit different tasks and computational resources. Inspired by Matryoshka Representation Learning (MRL), the authors propose the Matryoshka Query Transformer (MQT), which allows for any number of visual tokens during inference. Experimental results demonstrate considerable performance across varied visual token lengths and show promising results even with extreme token numbers.

Strengths

1. The problem of handling an arbitrary number of visual tokens is highly valuable. The authors propose a novel MRL-based method to tackle this issue. 2. The experimental results are promising, highlighting the trade-off between performance and computational resources. 3. The analysis of the impact of visual tokens is valuable, providing meaningful conclusions that deepen our understanding.

Weaknesses

1. Can you explain the choice of the MQT transformer design? Does it need to maintain sufficient capability for extracting information from varied tokens? For example, Q-Former has multiple layers to achieve effective information extraction. 2. The extraction process V=Q(Z,G) lacks correlation with textual information. In Fig 4, different text prompts should result in the same attention map due to this. Therefore, this design might be limited when dealing with complex images, where visual representations should maintain different semantics. 3. How does the model perform in text-rich scenarios, such as TextVQA? The sophisticated recognition ability might be significantly compromised in these cases. 4. Since the number of visual tokens affects performance, how does the model perform when the number of visual tokens exceeds the original 576 tokens? 5. It would be better to provide a comparison with the LLaVA baseline, using adaptive pooling or vanilla Q-former to adjust token numbers.

Questions

As in LLaVA-1.5, the 576 visual tokens do not introduce significant computational overhead. It would be more meaningful to evaluate this method on a more extensive case like LLaVA-NEXT.

Rating

5

Confidence

5

Soundness

3

Presentation

3

Contribution

3

Limitations

Please consider answer the questions above.

Reviewer L7Jp2024-08-07

Thanks for the rebuttal. 1) Good to know about what was being measured in TFLOPs 2) Can you please share the results of the experiment of picking first 8 tokens? 3) Sounds good about joint vs sampled 4) I would prefer having aboslute numbers than relative to reduce confusion. But I am still suprised by the performance gap here. But I can see why it might happen. 5) Thanks for the information. Please add this to the main paper as promised. I shall look at other reviews, rebuttals and discssion before making a final decision, but I lean to accept this paper even in the current stage.

Authorsrebuttal2024-08-07

Thank you for the discussion

Dear reviewer, Thank you for your promptly and insightful feedback. We appreciate your lean to accept this paper. 1. Thanks. 2. The results of inference with the first 8 tokens are in our paper's Table 1. We have tested your proposed scenarios and found to be exact the same numbers. 3. Thanks. 4. Thank you for your advice, we realized this confusion, too. We will revise this expression in line 249 and 258 to absolute scores. 5. Thanks, we will definitely add this visualization to the main paper.

Reviewer k14Y2024-08-10

Reply to authors

Thank you authors for providing the rebuttal. I am still doubtful about the visualizations and even overall the story line provided. The supervision signal under different granularities of visual tokens are from the same set of captions. How can we make sure this makes sense and model really learns the correct granularity? If so, then the assumption about the visualizations do not make sense.

Authorsrebuttal2024-08-11

Reply to the question on correct granularity.

Dear reviewer, Thank you for your feedback. As demonstrated in the original Matryoshka Representation Learning (MRL) work (Kusupati et al., NeurIPS 2022), the model can learn the correct granularity even when the supervision signals come from the same source. As mentioned in MRL work, this coarse-to-fine granularity is achieved by explicit optimization of $O(log(d))$ lower-dimensional vectors in a nested fashion. Similarly in our work, although the supervision signal remains consistent, our model is trained with nested varying numbers of visual tokens, allowing it to adapt to different settings. We acknowledge that the model may learn the correct granularity implicitly, even though we employed an explicit variation in the number of visual tokens. Thus, to support this, we provide both quantitative data (Table 1) and qualitative visualizations (Figures 4, 5, and 7) demonstrating that this implicit training is effective and that the learned patterns are intuitive. We hope our response can address your question. Thank you.

Reviewer jmsV2024-08-11

Dear authors, Thanks for your response. I do agree that elastic inference is a beneficial property, which MQT seems to reach with a simple training strategy. Although I still think the efficiency/accuracy trade-off of the method could be investigated a bit more in-depth, in particular for different number of baseline tokens. (see below). However, since I do not have any strong negative left after the rebuttal, I will raise my score to weak accept. **Regarding 2/4:** My suggestion was rather on trying different sparsity ratio vs baseline number of tokens trade-off, to see how this affects the performance in the lower FLOPs regime: Taking Figure 1 as an example, it is my understanding that the blue curve is a model trained with 576 tokens (baseline) + MQT to enable elastic inference with a lower number of tokens. so for instance, to achieve 64 tokens at inference a sparsity ratio of ~10% is applied. But another way to attain 64 tokens at inference would to use a 256 token baseline model (*which seems to only be roughly $0.2$ point of accuracy below the 576 tokens one in Figure 1*) with a less drastic sparsity ratio of 25%, which may hurt accuracy less and lead to a better trade-off curve.

Authorsrebuttal2024-08-11

Thank you for the discussion

Dear reviewer, Thank you for your feedback. We are encouraged by your decision to raise the score to accept this paper. We agree that the efficiency and accuracy trade-off method can be investigated more in-depth. As you mentioned, we demonstrated elastic inference and compared it with independently trained baselines to support our "beneficial property". We will leave a more in-depth exploration of the efficiency and accuracy trade-off to future work. Thank you!

Program Chairsdecision2024-09-25

Decision

Accept (poster)

© 2026 NYSGPT2525 LLC