Multimodal Task Vectors Enable Many-Shot Multimodal In-Context Learning

Authors: brandon  huang
chancharik  mitra
assaf  arbelle
leonid  karlinsky
trevor  darrell
roei  herzig
Venue: NeurIPS_cc_2024_Conference
Published: 2024-05-09 20:39:02

Abstract: The recent success of interleaved Large Multimodal Models (LMMs) in few-shot learning suggests that in-context learning (ICL) with many examples can be promising for learning new tasks. However, this many-shot multimodal ICL setting has one crucial problem: it is fundamentally limited by the model's context length set at pretraining. The problem is especially prominent in the multimodal domain, which processes both text and images, requiring additional tokens. This motivates the need for a multimodal method to compress many shots into fewer tokens without finetuning. In this work, we enable LMMs to perform multimodal, many-shot in-context learning by leveraging Multimodal Task Vectors (MTV)---compact implicit representations of in-context examples compressed in the model's attention heads. Specifically, we first demonstrate the existence of such MTV in LMMs and then leverage these extracted MTV to enable many-shot in-context learning for various vision-and-language tasks. Our experiments suggest that MTV can scale in performance with the number of compressed shots and generalize to similar out-of-domain tasks without additional context length for inference. Code: https://github.com/Brandon3964/MultiModal-Task-Vector

Main paper: 
 introduction: 
 Large Multimodal Models (LMMs) such as GPT-4V [60] , LLaVA [49, 50] , and the BLIP [13, 43] family of models demonstrate state-of-the-art performance on a variety of vision and language (VL) tasks due to their strong reasoning capabilities over both text and images. Recent works show that LMMs pre-trained on interleaved text-image data can do multimodal in-context learning [6, 39] . In particular, few-shot, in-context learning (ICL) in text-only LLMs has been scaled with an increasing number of examples in long-context language models-a setting called many-shot learning [1] . A natural question arises on how to perform many-shot learning in the multimodal domain.The first issue with directly applying a many-shot learning regimen to LMMs is the intrinsic limitation of context length. This is especially true in the multimodal domain, as LMMs must encode both text and images, whose embeddings are token-expensive. Moreover, long-context language models, which LMMs leverage for reasoning, struggle to use their entire context length effectively for ICL [45, 51] . Secondly, perhaps due to the misalignment of pretraining tasks with ICL, many instruction-tuned LMMs underperform on tasks in the ICL setting [16] , suggesting the importance of interleaved LMMs. Finally, there is also the challenge of the increasing memory and run-time required for processing long contexts for every inference call. These challenges motivate a method for compressing multimodal in-context examples into compact, implicit representations. Therefore, in this paper, we propose Multimodal Task Vectors (MTV)-compact representations of multimodal in-context tasks-within Figure 1 : Multimodal Task Vectors (MTV) Overview. We overcome an LMM's context length limitation by encoding many shots of multimodal examples as activations in the LMM's latent space. We then directly replace this encoding into the LMM's activation space during downstream inference.the attention heads of LMMs to enable many-shot ICL. In particular, we show the existence of MTV in interleaved LMMs, and we use them to compress large numbers of multimodal ICL examples.However, research on these longer-context models finds that they struggle to use the entire context for ICL [45, 51] . Moreover, as inference on long contexts of inputs is also time and memory-expensive, it is unclear whether simply scaling the context of models is practical for enabling multimodal many-shot ICL in open-source models. There is some early evidence of multimodal many-shot ICL being effective in closed-source models [35] , so the question arises as to how to achieve something similar for open-source models. This has led to work that looks to compress explicit input tokens [11, 20, 34, 58, 73, 77] . But crucially, many of these methods require finetuning and only try to preserve performance. Our work is different in that it is the first to enable multimodal models with many-shot ICL capabilities, while also improving on complex VL tasks without finetuning.Task Vectors. Our work builds off of research in text-only and vision-only domains showing that internal representations of these models called task vectors [25, 27, 81] (or function vectors) can encapsulate tasks outlined by ICL examples. Our is the first demonstration of Multimodal Task Vectors (MTV) in LMMs. Going beyond previous work, however, we show that MTV enable LMMs not only to use many-shot, multimodal ICL examples but also scale with more samples, be used alongside explicit ICL shots, and even generalize to unseen classes or similar tasks.Model Domain Adaptation Methods. As LLM and LMM model architectures have advanced, so have methods to allow these models to generalize beyond their pretraining distributions. Methods like instruction tuning [5, 50, 68, 88] have shown strong zero-shot generalization to some out-of-domain tasks, but forgetting remains an issue. One popular solution to this issue involves Parameter Efficient Fine-tuning (PEFT) [28] : finetuning either a set of soft prompt input tokens [41, 46] , low-rank model weights [14, 29, 99] , or a separate adapter from the main model [18, 30, 100] .Prompting methods are a well-explored area for adapting models without finetuning. LLM prompting includes zero-shot methods [36, 83, 85] , few-shot and ICL methods [9, 15, 53, 56] , expert prompting [93] , and Chain-of-Thought (CoT) [90, 101] , with extensions like self-consistency [86] , Tree-of-Thought (ToT) [94] , and Graph-of-Thought (GoT) [8, 40, 95] for more complex structures. Similar multimodal prompting methods exist for LMMs as well [57, 84, 87, 102, 104] .Large Multimodal Models (LMMs). The state-of-the-art performance of LMMs [2, 6, 13, 17, 21, 43, 49, 50, 96, 97, 105] on multimodal tasks stems from combining LLMs' reasoning capabilities [3, 12, 26, 66, 71, 78] with the perception abilities of vision models. LMMs' generative reasoning also makes them more applicable to complex tasks than previous contrastive methods [42, 43, 65] . Such tasks include visual question-answering [4, 23, 24, 31, 32, 54, 67] as well as object identification and localization [37, 48, 59, 82] . Visual Programmatic Models (VPMs) are another class of multimodal methods that makes use of in-context APIs code generation [19, 22, 52, 64, 69, 72, 74, 76, 92] . However, context length limits both LMMs' and VPMs' ability to use multimodal prompting methods such as ICL [9] . Another key challenge is that many LMMs are pre-trained on single text-image pair data. Recently, many LMM models now pretrain on interleaved text-image data [2, 6, 16, 33, 39, 75, 103] , making effective multimodal ICL possible. In our work, MTV goes beyond simple few-shot multimodal ICL and scales to many-shot multimodal ICL. 
limitations: 
 Question: Does the paper discuss the limitations of the work performed by the authors? Answer: [Yes] Justification: We discussed about limitations in Section 7.Guidelines:• The answer NA means that the paper has no limitation while the answer No means that the paper has limitations, but those are not discussed in the paper. • The authors are encouraged to create a separate "Limitations" section in their paper.• The paper should point out any strong assumptions and how robust the results are to violations of these assumptions (e.g., independence assumptions, noiseless settings, model well-specification, asymptotic approximations only holding locally). The authors should reflect on how these assumptions might be violated in practice and what the implications would be. • The authors should reflect on the scope of the claims made, e.g., if the approach was only tested on a few datasets or with a few runs. In general, empirical results often depend on implicit assumptions, which should be articulated. • The authors should reflect on the factors that influence the performance of the approach.For example, a facial recognition algorithm may perform poorly when image resolution is low or images are taken in low lighting. Or a speech-to-text system might not be used reliably to provide closed captions for online lectures because it fails to handle technical jargon. • The authors should discuss the computational efficiency of the proposed algorithms and how they scale with dataset size. • If applicable, the authors should discuss possible limitations of their approach to address problems of privacy and fairness. • While the authors might fear that complete honesty about limitations might be used by reviewers as grounds for rejection, a worse outcome might be that reviewers discover limitations that aren't acknowledged in the paper. The authors should use their best judgment and recognize that individual actions in favor of transparency play an important role in developing norms that preserve the integrity of the community. Reviewers will be specifically instructed to not penalize honesty concerning limitations. 
multimodal task vectors: 
 To address the challenge of performing many-shot multimodal in-context learning, we demonstrate the existence of MTV in LMMs and then leverage them for many-shot multimodal ICL. We begin by describing some background on multimodal ICL and task vectors (Section 3.1). We then introduce our three-step approach: (i) We calculate the mean activations of the attention heads from the manyshot multimodal ICL examples (Section 3.2); (ii) We then extract the set of LMM attention heads locations that best align to the downstream task using an adapted version of the REINFORCE [91] algorithm (Section 3.3); and (iii) We replace the calculated mean activation values into the LMM for a downstream task (Section 3.4). The detailed method visual is shown in Figure 1 .In the multimodal in-context learning setting, an LMM learns a new task outlined by a set of multimodal examples. The input to the LMM would be outlined as follows: where the model is prompted to answer a query Q given a set of input-output examples (each x i being a multimodal input and each y i a text output).EQUATIONWe note that in-context examples are commonly passed sequentially to the LMM, necessarily restricting multimodal ICL to being small numbers of shots due to limited context length. Furthermore, the images require more tokens to embed, which means enabling many-shot ICL is even more challenging in the multimodal domain. To solve this, we utilize our method MTV-which are implicit representations in the model's attention heads that encode a many-shot multimodal ICL task.We start with a background on task vectors for some task j. Given a model F , we denote the set of attention-head locations as λ = {l | ∀l ∈ F } where each location l is indexed as l = (h, m) for the h th layer and m th attention head. Now, task vectors utilize the intermediate outputs of an LMM, called activations. For a given input sequence of written in terms of its tokens x = {x 1 , x 2 , . . . , x T }, each attention head (h, m) produces an activation z l ∈ R d H for each token x i , where d is the model's embedding dimension and H is the number of heads. These activations are simply the output vectors of each attention head before any linear projection. While each head's activation is typically concatenated with others and projected to form the layer's output, task vectors specifically utilize the pre-projection activations of the final token x T from each attention head. We thus define the task vectors as follows: (1) the task vector values µ j are a subset of mean activations produced by the attention heads of F given examples of a task, and (2) the task vector locations λ j , which denotes a subset of the attention head indices per task. Thus, the task vector is (µ j , λ j ). For inference, µ j replaces the activation values of the heads in the locations given by λ j .In prior work [25, 27, 81] , the calculation of the mean activations µ j and the extraction of the attention-head locations λ j are used together to extract the task vector. Interestingly, we find that these two steps should be decoupled in order to better align with the downstream task. In our work, we calculate the mean activations µ j corresponding to the last token specifically to encode a dataset of many-shot multimodal ICL examples by averaging them across multiple inference calls. However, the downstream task may not always be in the same ICL format as the many-shot examples (e.g., the downstream task uses a different number of shots or is zero-shot). To solve this, we use a separate set of examples that are of the exact format of the downstream task to align the extracted attention-head locations λ j with the inference task. This separation of responsibilities, wherein µ j captures the essential information from the many-shot examples and λ j identifies the specific attention head locations for the downstream task, optimizes the utilization of the encoded information at relevant locations within the model.Our approach to finding Multimodal Task Vectors (MTV) (µ MTV j , λ MTV j ) allows LMMs to actually leverage many-shot multimodal ICL examples for complex vision-language tasks without being limited by context length. We proceed by first describing how to calculate the mean activations.The ultimate objective of many-shot multimodal ICL is to use a large number of input-output examples when solving a task j. However, it is not trivial to get the LMM to see more examples during inference time than its context length allows.To address this issue, we pass a few-shot input I t for each inference call t for a total of T > 1 inference calls. Each I t consists of N shots (where N > 1) of multimodal in-context examples in the form of randomly-selected input-output response pairs (x t : y t ), and Q t , which is the query to be answered by the LMM in that iteration.EQUATIONThus, over T LMM inference calls, we have a many-shot multimodal dataset (of N × T examples):EQUATIONHowever, this dataset is still just a disconnected set of few-shot examples. Next, we would like to connect the separate examples into one unified many-shot multimodal ICL representation.For each inference call, the LMM is given N -shot ICL examples. We calculate the mean of the activations corresponding to the last token of the input z l,j for each attention head index ∀l ∈ λ (Section 3.1) across T inference calls, yielding:EQUATIONIn this step, we have found the mean activations µ l,j , which encode an internal LMM representation of many shots of multimodal ICL examples. In the next subsection, we describe our methodology for selecting the set of attention heads where these mean activations will be used.After Step 1, we now have mean activations for the attention heads of the last token in a given many-shot multimodal task. Yet, we still need to find which set of attention heads λ MTV j should be chosen to encode our task.To choose the set of attention heads, we first prepare a separate set of S examples specifically aligned to the format of the downstream task. For instance, if the downstream setting is a 2-way, one-shot classification task, then the S examples should conform to this paradigm. For our explanation, let's consider a downstream task that is zero-shot such that there is a single query Q s and corresponding response R s for all s ∈ [1, 2, . . . , S].From these examples, we utilize an adapted version of the REINFORCE [91] algorithm-an iterative policy optimization method that can be used to find task vector locations [27] . Given an LMM F , we first select a proposed set of attention head locations by sampling a Bernoulli distribution over the locations multiple times. Next, we directly replace the values of the selected attention heads with the corresponding mean activations µ l,j . Then, after prompting the model with the query Q s , we use the negative cross-entropy loss between the LMM's output logits and the logits of the ground-truth response R s to optimize the Bernoulli distribution. By optimizing the Bernoulli distribution across S iterations, we are finding the best attention head locations λ MTV j for patching in our mean activations. Finally, we can extract λ MTV j , the optimized indices of attention heads, by sampling our optimized Bernoulli distribution.EQUATIONIt is important to note that MTV_EXTRACT does not require finetuning of the LMM parameters, but rather only inference calls. We describe further the underlying details of our adapted MTV_EXTRACT algorithm in Section A.2 of the Supplementary. Having found λ MTV j and µ l,j , we describe in what follows, the final procedure to use MTV for inference.After we have identified a set of attention heads λ MTV j , it is straightforward to apply MTV for inference. We denote the set of mean activations µ MTV j as follows µ MTV j = {µ l,j |∀l ∈ λ MTV j }.To run downstream inference on a new query Q new with our model F , we directly replace the values of attention heads λ MTV j with µ MTV j and produce the following response R new :EQUATIONR new is thus a response generated using many shots of multimodal examples as implicit context via MTV. The key insight of our method is the importance of N (the number of multimodal examples) and many T (the number of iterations) during the calculation of MTV. This enables an LMM to go beyond its context length to learn more nuanced properties of the task from seeing many examples. Additionally, insertion of MTV directly into the LMM also obviates the need for any context length during downstream inference, actually freeing additional context for other use (e.g., an additional prompt, more ICL examples, etc.). Finally, because we align the attention-head locations with the downstream task, MTV can be effectively applied to zero-shot and different ICL settings.Question: For each theoretical result, does the paper provide the full set of assumptions and a complete (and correct) proof? Guidelines:• The answer NA means that there is no societal impact of the work performed.• If the authors answer NA or No, they should explain why their work has no societal impact or why the paper does not address societal impact. • Examples of negative societal impacts include potential malicious or unintended uses (e.g., disinformation, generating fake profiles, surveillance), fairness considerations (e.g., deployment of technologies that could make decisions that unfairly impact specific groups), privacy considerations, and security considerations. • The conference expects that many papers will be foundational research and not tied to particular applications, let alone deployments. However, if there is a direct path to any negative applications, the authors should point it out. For example, it is legitimate to point out that an improvement in the quality of generative models could be used to generate deepfakes for disinformation. On the other hand, it is not needed to point out that a generic algorithm for optimizing neural networks could enable people to train models that generate Deepfakes faster. • The authors should consider possible harms that could arise when the technology is being used as intended and functioning correctly, harms that could arise when the technology is being used as intended but gives incorrect results, and harms following from (intentional or unintentional) misuse of the technology. • If there are negative societal impacts, the authors could also discuss possible mitigation strategies (e.g., gated release of models, providing defenses in addition to attacks, mechanisms for monitoring misuse, mechanisms to monitor how a system learns from feedback over time, improving the efficiency and accessibility of ML). 
evaluation: 
 In order for LMMs to perform multimodal ICL, it is important for interleaved data to be included in pretraining. We apply our MTV approach to Qwen-VL [6] , Idefics2-8B [38] , and ViLA-1.5-8B [47] three popular interleaved LMMs. For each model, we compare our method to using few-shot ICL across different vision-and-language tasks like VQA and object identification.We implemented MTV using PyTorch [61] . We used each model's respective official implementation.While the compute and memory requirements differ slightly between models, all our experiments can be run on a single NVIDIA A6000 GPU. For additional information, refer to Supplementary Section B.Our model and weights will be released upon acceptance, and our code is in Supplementary.In this work, we apply MTV to the following interleaved LMMs as they are better-suited for multimodal ICL as shown by [16] : (1) QwenVL [6] is a LLaMA-based model that has the ability to process high-resolution images, and its two-stage pre-training methodology, which includes multitask finetuning and interleaved text-image data. (2) Idefics2-8B [39] is a Mistral-based model that benefits from its pre-training on the expansive OBELICS dataset, which comprises a web-scale collection of interleaved image-text documents. We utilize the base version of the model. This demonstrates multimodal in-context learning abilities. (3) LLaMA3-ViLA-1.5-8B (abbreviated as VILA-1.5-8B). ViLA-1.5-8B [47] is an architecture that leverages LLaMA-3 as the LLM backbone.As in others, a significant portion of the model's pretraining data is interleaved text-image data.(4) MANTIS-LLaMA3-8B. MANTIS-LLaMA3-8B [33] is a combination of a SigLIP [98] visual encoder and LLaMA3 [55] language model finetuned using the MANTIS dataset, a specially curated multi-image dataset that emphasizes co-reference, reasoning, comparing, temporal understanding.We show the number of tokens per image embedding for each model in Table 1 to illustrate the especial importance of MTVs in the image-text domain: We briefly describe the tasks and datasets we evaluate our method on. More details about the datasets and their setup can be found in Section B.VQA Datasets. We use the following commonly-evaluated datasets which emphasize different aspects of multimodal reasoning, including visual features (VizWiz) and outside knowledge (OK-VQA):(1) VizWiz [23] consists of images taken by visually impaired individuals paired with questions they pose about these images, making it crucial for developing AI systems that assist in real-world, accessibility-focused visual understanding tasks. (2) OK-VQA dataset [54] is designed to push the boundaries of Visual Question Answering (VQA) by focusing on knowledge-based questions, where answers require external knowledge beyond the image content. (3)Object Classification. We use the following datasets, which are commonly used for object classification in multimodal ICL: (1) The Flowers dataset [59] , commonly known as the Oxford 102 Flowers dataset, is a collection specifically designed for image-based flower species recognition for fine-grained classification of 102 different categories of flowers. (2) Caltech's CUB Dataset on Birds [82] is a well-known resource for evaluating algorithms on the task of object identification, specifically focused on bird species. It features 200 bird species with roughly 30 images each, annotated with key attributes and bounding boxes. Both Flowers and Birds are formatted as 2-way,1-shot classification episodes, with model inputs being a positive and negative image for the class to be identified in the query image. The response format is a short text response. 
results: 
 Our main results are shown in Table 2 . For VQA, we show the results of MTV with 4 shots per 100 iterations to calculate the mean activations and 100 examples for task vector locations (500 examples total). The task vector is extracted using examples from the train set of the dataset and evaluated on the validation set. For object classification, we extract MTV based on a 2-way, one-shot regimen per 100 iterations for both mean activations and task vector locations (200 examples total). The task vector is extracted using a train set of 30% of the object classes and evaluated on the remaining 70% of unseen classes. We demonstrate how Multimodal Task Vectors outperforms zero-shot and few-shot ICL settings on three different models on VL tasks, highlighting the effectiveness of our method. Next, we describe the unique capabilities of our method, such as scaling to more samples and showing some generalizations to other tasks. More results can be found in Section A.1 of Supplementary. We are interested in evaluating (i) the effect of different numbers of shots used per iteration to extract MTV and (ii) the effect of different numbers of iterations used. We test the impact on accuracy when increasing both of these parameters for QwenVL on the VizWiz validation set. In Figure 3 , we show on the left that the optimal number of multimodal ICL shots is 16 shots per iteration. Further, we show on the right side of the figure that 1000 examples yield the best performance. These results illustrate that MTV can effectively scale by utilizing larger numbers of ICL examples per iteration and also in aggregate.One of the benefits of MTV over a few-shot ICL is the context length that is saved during inference. This is because the many-shot examples are encoded directly in the activation space rather than in the input token space. Thus, we ask whether the LMM can use the freed context for additional few-shot examples. For object classification, we formulate both Flowers and CUB as a 1-shot comparison between a positive and negative sample to identify the correct class (i.e., 2-way, 1-shot ICL by construction). We report results on 1-shot ICL and MTV with 1-shot classification during inference. MTV+1-shot ICL surpasses 1-shot ICL accuracy on these tasks, showing that MTV can be utilized alongside few-shot examples. Furthermore, it is vital to note that the evaluation classes are completely unseen by MTV. Thus, with just a 1-shot ICL example, MTV is able to generalize to unseen classes.In this experiment, we further ask whether the MTV heads λ MTV j extracted on one task j can generalize to a separate, but similar task k. To test this, we use the attention heads extracted from 3 demonstrate that the extracted heads from one task can improve accuracy on another similar task. This generalizability of the heads is significant because it suggests that the heads from MTV may only have to be extracted once to be applied to many other similar tasks. The only calculation necessary then would be the mean activations of the many-shot examples used for the target dataset, making the application of many-shot multimodal ICL even more efficient for similar tasks. In Table 3b , we compare our method to finetuning. To do this, we use finetune on the same number of examples as MTV uses from the train set and evaluate not only on the validation set but also on the validation set of another similar dataset. In particular, for a ViLA-1.5-8B model finetuned on VizWiz, we report accuracy on both VizWiz and OK-VQA validation sets. It can be seen that finetuning is indeed an upper bound on the dataset the model was finetuned on. However, we show that finetuning leads to overfitting on the finetuned dataset and even forgetting the zero-shot capabilities. In contrast, we also show that MTV not only improves zero-shot capabilities but can generalize to similar tasks with only a few inference examples Table 2b and Table 3a .We compare our method to two different methods that can find task vectors: Visual Task Vectors (VTV) [27] and Function Vectors (FV) [81] . Originally, these works could not be applied as-is to support multimodal ICL, but here, we have implemented a version that follows the original exactly with only minor modifications to allow performing our evaluated multimodal tasks. More details about the methods can be found in Section A.2 in the Supplementary. In our experiments Table 3b , we find that MTV surpasses both methods on VizWiz and OK-VQA. VTV are image-only task vectors that use only one-shot image examples for fixed small T iterations, and they calculate the mean activations and the locations together without aligning to the downstream task. FV are text-only task vectors that use Causal Mediation Analysis [62] to extract task vector locations from only the output activations of the last token. The results suggest the importance of finding the task vectors by decoupling the calculation of the mean activations and locations in two separate steps to perform many-shot multimodal ICL more effectively for complex multimodal tasks.  
conclusion: 
 In this work, we present Multimodal Task Vectors a compact, implicit representation that can efficiently encode many-shot multimodal ICL examples for use in complex vision-language tasks. We demonstrate this implicit model representation not only encodes a multimodal ICL task but can also enable many-shot multimodal ICL to surpass zero-shot and few-shot performance on a variety of VL tasks. Our method stands out from previous work in its ability to scale, use additional explicit multimodal ICL examples, and generalize to other similar VL tasks. Our work is a viable way to surpass the limit of context length of an LMM for multimodal ICL and demonstrates clearly that these additional examples aid in multimodal reasoning. Finally, we do not anticipate a specific negative impact, but, as with any Machine Learning method, we recommend exercising caution. 
limitations: 
 While Multimodal Task Vectors offers substantial benefits for handling complex vision-language tasks compared to finetuning or few-shot ICL, it is important to recognize certain limitations that accompany our approach. MTV requires access to the internal architecture of an LMM, so while it is an effective solution for all open-source models, its application is restricted from proprietary models, such as GPT-4 [60] and Gemini [79, 80] . Furthermore, while many-shot ICL is incredibly attractive for many applications, it may not be practical for low-data scenarios where synthetic data [1] or the transfer of MTV extracted from another dataset may be required. We feel these challenges represent great opportunities for future work in the many-shot multimodal in-context learning domain. 
safeguards: 
 Question: Does the paper describe safeguards that have been put in place for responsible release of data or models that have a high risk for misuse (e.g., pretrained language models, image generators, or scraped datasets)? Answer: [No] Justification: We don't have any safeguards to discuss here. Guidelines:• The answer NA means that the paper poses no such risks.• Released models that have a high risk for misuse or dual-use should be released with necessary safeguards to allow for controlled use of the model, for example by requiring that users adhere to usage guidelines or restrictions to access the model or implementing safety filters. • Datasets that have been scraped from the Internet could pose safety risks. The authors should describe how they avoided releasing unsafe images. • We recognize that providing effective safeguards is challenging, and many papers do not require this, but we encourage authors to take this into account and make a best faith effort. 12. Licenses for existing assets Question: Are the creators or original owners of assets (e.g., code, data, models), used in the paper, properly credited and are the license and terms of use explicitly mentioned and properly respected? Answer: [NA] Justification: All data and code are credited. Guidelines:• The answer NA means that the paper does not use existing assets.• The authors should cite the original paper that produced the code package or dataset.• The authors should state which version of the asset is used and, if possible, include a URL. • The name of the license (e.g., CC-BY 4.0) should be included for each asset.• For scraped data from a particular source (e.g., website), the copyright and terms of service of that source should be provided. • If assets are released, the license, copyright information, and terms of use in the package should be provided. For popular datasets, paperswithcode.com/datasets has curated licenses for some datasets. Their licensing guide can help determine the license of a dataset. • For existing datasets that are re-packaged, both the original license and the license of the derived asset (if it has changed) should be provided. • If this information is not available online, the authors are encouraged to reach out to the asset's creators. 
new assets: 
 Question: Are new assets introduced in the paper well documented and is the documentation provided alongside the assets?Answer: [NA] . Justification: We present a method and no additional assets are introduced in the paper. Guidelines:• The answer NA means that the paper does not release new assets.• Researchers should communicate the details of the dataset/code/model as part of their submissions via structured templates. This includes details about training, license, limitations, etc. • The paper should discuss whether and how consent was obtained from people whose asset is used. • We recognize that the procedures for this may vary significantly between institutions and locations, and we expect authors to adhere to the NeurIPS Code of Ethics and the guidelines for their institution. • For initial submissions, do not include any information that would break anonymity (if applicable), such as the institution conducting the review. 
 
 Appendix: Supplementary MaterialHere, we provide additional information about our experimental results, qualitative examples, implementation details, and datasets. Specifically, Section A provides more experiment results, Section A.2 provides additional method details, Section B provides additional implementation details, and Section C provides qualitative visualizations to illustrate our approach.We present several additional experiments that further demonstrate the benefits of our MTV approach.Here we provide additional experiments and ablations that further illustrate different characteristics of MTV.Motivation for encoding shots in the activation space.. We highlight our paper's motivation in addressing the context length token limitation of LMMs by encoding ICL shots in the activation space. An additional limiting factor in the token space is the physical constraints of memory and runtime, which we ablated in Section 5.6 of the paper. For example, 25-shot ICL is actually the maximum number of vanilla ICL shots that can be run on a single 48GB A6000 GPU for Qwen-VL. We demonstrate the degradation of increasing numbers of multimodal token-space ICL shots (VizWiz-QwenVL) in Table 5a .Effect of shot quality on MTV:. We assess the connection between textual and activation-space shot quality by comparing MTV using random selection with MTV using high-quality shots selected with the Facility Location algorithm [70] . We apply MTV to QwenVL and use the Qwen GTE embedding model to obtain embeddings for the Facility Location algorithm and present the results in Table 5b . Excitingly, we find that high-quality shots do indeed lead to significant improvements in MTV performance.MTV with noisy exemplars.. We compare the robustness of MTV compared to that of vanilla ICL. For QwenVL on VizWiz and OKVQA, we replace 1 of the 4 examples in each iteration of 4-shot ICL and 4-shot-100-iteration MTV with an example from the opposite dataset. We report both accuracy and degradation in Table 5c Attention head generalization on object classification tasks Table 6a . We also test generalization for object classification tasks identical to the formulation described in Section 5.3. For clarity, MTV shows another kind of generalization when it is leveraged alongside additional explicit ICL samples. This capability is described in Section 5.2. To summarize our experiment, we calculate MTV using the Flowers dataset using 1-shot ICL example for 100 iterations for both the mean activations µ MTV j and the attention head locations λ MTV j . Then, we apply MTV to the CUB task using the same set of attention head locations from Flowers. We just calculate the mean activations for the CUB dataset using a 1-shot for 100 iterations (halving our data requirement for this specific scenario). Once again, we find that the heads of MTV can indeed generalize between similar classes. MTV one-to-one comparison with ICL -Table 6b . Although not directly comparable, we consider an extreme case of MTV where we encode only 4-shots of ICL examples for 1 iteration. This matches the exact setting used in standard 4-shot ICL. Interestingly, MTV applied to both VizWiz and OK-VQA exceeds performance on the 4-shot-ICL case and even MTV formulated on 4-shots per 100 iterations for calculating the mean activations. This result suggests that there may be scope for MTV to be effective in both high and low-data regimens. More research needs to be done to explore this idea. MTV at extreme shot counts. We delve further into the scaling capabilities by evaluating the performance of MTV at the maximum number of VizWiz shots per iteration allowable by the memory constraints of a single NVIDIA RTX A6000. The experiment shown in Table 7a indicates that while MTV does continue to scale, there is also certainly a saturation point for VizWiz. The exact saturation point likely depends on the specific task.Effect of permutation. We consider applying five random seeds to different configurations of MTV comparing its variability under permutation of example order to standard few-shot ICL. We present the mean and standard deviation for these experiments in Table 7b . Although not significant, in both 4-shot and 8-shot settings, MTV shows less variability to example permutation. This intuitively makes sense as more examples are averaged over multiple iterations, leading to more stable performance across different seeds. MTV for language-only tasks. While we show the importance of MTV especially for visionlanguage tasks, the methodology can be a powerful way to learn tasks in the language-only domain as well. We demonstrate in Table 8a the effectiveness of MTV on two common LLM tasks using LLaMA-3-8B [55] : MTV on additional document datasets. Multimodal documents are a form of data with complex compositions of visual and textual modalities, with interleaved language, photograph, and chart information. As such, we provide some preliminary results on the effectiveness of MTV on these types of datasets in Table 8b . These encouraging results prompt future research into the domain of leveraging task vectors for learning challenging document tasks.Here we provide some additional method details about MTV, Visual Task Vectors (VTV) [27] , and Function Vectors [81] (FV).We describe the particulars of our MTV-EXTRACT algorithm for finding the set of attention head locations that best align with the downstream task as follows (Q s and R s are formatted identically to the downstream task): Sample λ i ∼ Bernoulli(σ(θ))5:Replace activations for λ i in F with µ l,j 6:Compute output logitsO s ← F (Q s ) ▷ Pass Q s to LMM F 7: L i ← Negative Cross-Entropy(O s , R s ) 8:end for9: θ ← Adam(θ, ∇ θ 1 32 32 i=1 L i ) ▷ Update rule 10: end for 11: Sample final λ MTV j ∼ Bernoulli(σ(θ))▷ Final set of head locations 12: return λ MTV j We point out a few important factors. It is important to note that none of the parameters of F are being finetuned through any gradient update. We take the negative cross-entropy (negative as MTV_EXTRACT draws inspiration from REINFORCE [91] , which is a policy optimization algorithm) between the output logits O s and the first token of the target response R s for a simple update scheme. This along with the choice of 32 samples of the Bernoulli distribution are ones we encourage more experimentation with in future work.Visual Task Vectors (VTV) [27] were originally designed to be applied to large vision-transformerbased models. We make as few changes as possible to apply this method for multimodal tasks. We preserve VTVs distinct factors like a the usage of 1-shot examples for both calculation of the mean activations and attention head locations regardless of the format of the downstream task. Furthermore, we fix the number of iterations for both mean activation and attention head calculation at 10. Finally, we replace the proposed MSE loss with a cross-entropy loss that is more suited for an LMM task.Because Function Vectors describe text-only task vectors, we follow the implementation of Function Vectors [81] almost exactly as LLMs and LMMs are similar. The only major change made is the use of many-shot multimodal ICL examples for mean activation calculation. We preserve the lack of an optimization method for the layer used to replace the mean activations. Rather than performing a standard grid search over the set of layers, we set the layer number to 20 as recommended for LLaMA and LLaMA-based models by the paper. The only other difference is the encoding of multimodal ICL examples. Again due the the similarity between LMMs and text-only LLMs, these tests can be used as needed as long as the multimodal inputs are properly processed by the LMM.To run all of our experiments, we use 1 NVIDIA RTX 6000 GPU. Importantly, this includes the runtime and efficiency ablations, which were evaluated on the same GPU for consistency. Please refer to the respective model's paper for their specific implementation details of the architecture. Besides the output token generation length, which varies depending on the standard setting for each task, we use the default generation parameters (e.g. temperature and no. of beams in beam search) recommended for each model. In the following sections, we describe some of the finer nuances of our MTV-EXTRACT process as well as our implementations of the Visual Task Vectors (VTV) and Function Vectors (FV) implementations.Dataset. The VizWiz dataset is designed to challenge and evaluate the capabilities of Large Multimodal Models (LMMs) in understanding and responding to real-world visual questions. This dataset is comprised of images accompanied by spoken questions, which have been transcribed and paired with answers. Each image in this dataset is sourced from visually impaired individuals seeking assistance, thereby incorporating a wide array of everyday challenges they face. This setup is inherently diverse and often requires high-level visual understanding combined with contextual reasoning, making them a robust benchmark for assessing the practical utility of LMMs in assistive technologies. The format of the dataset samples is an image paired with a text question. The LMM is required to provide a short response limited to 10 tokens or respond with "unanswerable" if the question is not answerable give the image.For this research paper, we specifically utilize the VizWiz dataset to benchmark the performance of our proposed task vectors in multimodal in-context learning (MM-ICL) on a dataset that challenges visual scene understanding of LMMs. We extract MTV on the training set and evaluate on the evaluation set containing 4,319 validation image/question pairs. Inference details. We use the standard VQA question-answer response format that is outlined in the QwenVL repository https://github.com/QwenLM/Qwen-VL. Put simply, the LMM is presented with an image and a corresponding text question. The response is then expected in a short text format of no more than 10 tokens (set as the "max_tokens" parameter in the LMM). One nuance is the special answer "unanswerable". We handle this by providing MTV and all baselines with the following prompt for every question: "First carefully understand the given examples. Then use the given image and answer the question in the same way as the examples. If the question can not be answered, respond unanswerable. " The official dataset can be downloaded at https://vizwiz.org/tasks-and-datasets/vqa/.Dataset. The OK-VQA dataset, differs from traditional VQA datasets in its focus on necessitating knowledge beyond what is presented in the given images. This dataset encompasses over 14,000 questions that are not merely reliant on visual cues but require associative reasoning with external data sources, making it a unique tool for evaluating AI's capability in handling complex, knowledge-driven queries. Thus, we evaluate on this dataset to test whether MTV can be beneficial for this type of reasoning.We once again extract MTV on the train set and evaluate on the validation set. OK-VQA is formatted as an image with a corresponding text question. However, it is important to note that the text question heavily relies on external knowledge to answer. Examples of questions can be found in Section C.Inference details. We use the standard VQA question-answer response format that is outlined in the QwenVL repository https://github.com/QwenLM/Qwen-VL. Put simply, the LMM is presented with an image and a corresponding text question. The response is then expected in a short text format of no more than 10 tokens (set as the "max_tokens" parameter in the LMM). We do not add any additional prompts or special tokens apart from prompt format or image tokens required by the model being evaluated. The official dataset can be downloaded at https://okvqa.allenai.org/.Dataset. Flowers [59] is an object classification dataset that requires fine-grained classification of 102 different flower species. The Flowers dataset is formulated as a 2-way, 1-shot task where one example is the positive sample and the other is the negative sample. In this way, the data poses a unique challenge for MTV having to store examples with two associated images. Thus, given the 2-way examples and the query image, the LMM is tasked with selecting the correct class from the given two options. Examples can be found in Section C Implementation Details. We use the official data released by the authors which is available at https://www.robots.ox.ac.uk/~vgg/data/flowers/. We provide a Python code snippet below showing the Flowers data format: def format_flower(cur_data): cur_query = f"<img>{query}</img>What is the type of bird in the image? A.{ pos_label} B.{neg_label}\nAnswer with the option's letter from the given choice directly. Answer:" query_label = "A" return pos_example + neg_example + cur_query, query_label, -1 else: pos_example = f"<img>{pos}</img>What is the type of bird in the image? A.{ neg_label} B.{pos_label}\nAnswer with the option's letter from the given choice directly. Answer: B\n" neg_example = f"<img>{neg}</img>What is the type of bird in the image? A.{ neg_label} B.{pos_label}\nAnswer with the option's letter from the given choice directly. Answer: A\n" cur_query = f"<img>{query}</img>What is the type of bird in the image? A.{ neg_label} B.{pos_label}\nAnswer with the option's letter from the given choice directly. Answer:" query_label = "B" return neg_example + pos_example + cur_query, query_label, -1We present further qualitative success and failure cases of QwenVL-MTV in Figure 5 on OK-VQA and Flowers.The license, PII, and consent details of each dataset are in the respective papers. In addition, we wish to emphasize that the datasets we use do not contain any harmful or offensive content, as many other papers in the field also use them. Thus, we do not anticipate a specific negative impact, but, as with any machine learning method, we recommend exercising caution. NA answer to this question will not be perceived well by the reviewers. • The claims made should match theoretical and experimental results, and reflect how much the results can be expected to generalize to other settings. • It is fine to include aspirational goals as motivation as long as it is clear that these goals are not attained by the paper. 


Decision: This paper received 4 reviews, but the review that gave a score of 1 due to desk reject reasons has been ignored since the case was already handled by the PCs. The paper addresses an open and highly challenging problem in the MLLM space, namely to maximize its potential for many-shot in-context learning. The reviewers find that the paper is well written, with a good motivation, and good results. One reviewer had concerns about how the paper is unique in the large landscape of MLLMs, as well as open questions about design choices. These questions were positively answered in the rebuttal, resulting in an accept consensus amongst the reviewers. The AC agrees with the general applicability and broad use of the method and recommends acceptance.

Reviews: review: paper_summary: paper_summary: In-context learning with many examples can be effective for learning new tasks. However, there are challenges with many-shot multimodal in-context learning (ICL), such as the limitation caused by the model’s context length. This issue is more challenging in the multimodal setting because it processes both images and text, requiring additional tokens. Therefore, a method to compress this information into fewer tokens without finetuning is necessary. The paper proposes using large language models (LLMs) to perform many-shot in-context learning with multimodal task vectors (MTVs). MTVs are compact, implicit representations of in-context samples, compressed by the model’s attention head. The paper provides experiments showing that outperform existing methods.
strength_weakness: strength_weakness: I would recommend the authors compare their work with “Many-Shot In-Context Learning
in Multimodal Foundation Models”. I think this can be a concurrent work, however, a general comparison of the methods and adding the reference to the paper helps the paper. 

I am a bit confused with the number of data used in each case in Tables 1 and 2. Can the authors elaborate on that? Also, can the authors explain more about the MTV+ 1-shot ICL setting?
Is the setting for MTV in Table 1 2-way 1-shot always?

While the FV and VTV are other existing methods, the paper does not clearly explain those in the main text and related work. I would recommend adding an extra link to the explanation on the supplementary material. Also, would the authors elaborate on the main differences here as well?

Based on Figure 2, the best shot is 16 and iterations 100. However, the paper does not provide any data on shots more than 16 and iterations more than 100, which makes the conclusion suboptimal. Similarly, the paper discusses the effect of permutation only with one experiment (running for different seeds) which is not enough. 



Writing:

In line 227, (3) is extra

Referring to steps 1 and 2 in lines 42-55 while these steps are not clearly defined makes it hard to follow the text. 

I would recommend the authors explain more about the notion of interleaved data in the paper. The current writing can be difficult to read.

In section 5.2, the reference to the table is missing

Reference missing on “scaling on flowers dataset” section

References to sections are missing in A1
questions: questions: please refer to the weaknesses.
limitations: limitations: The paper includes limitations.
paper_summary: paper_summary: In the context of multimodal understanding, this work studies the area of many shot, long-context ICL (in context-learning) in natively multimodal models (large multimodal models i.e. LMMs, where images and text are interleaved). The premise proposed is that the pretrain time context of existing LMMs is prohibitive w.r.t generalization to longer contexts for adding many-shot multimodal examples. To leverage many examples under this context budget, this work proposes a technique to compress i.e. encode these multimodal exemplars into the weight space (multimodal task vectors i.e. MTV) by encoding them via mean attention head activations and replacing these mean activations into heads which are most aligned for a downstream task (which is potentially out of domain / zero shot). This selection is done at inference time via a REINFORCE based selection mechanism. Empirically, consistent improvements are demonstrated compared to the ICL baseline across open models (where weights can be accessed) on 4 tasks covering visual question answering and object classification.
strength_weakness: strength_weakness: While the empirical improvements are encouraging, following are some weaknesses where I have concerns regarding the motivation of the method and it would be great to have a discussion on these:

1. How is the proposed method uniquely situated in the context of "multimodal" QnA? The context length limitation, encoding exemplars efficiently and tuning head selection for a downstream task seem to be applicable in the text-only domain too. Can this same technique be applied to the text-only space as well? What is specific about the methodology proposed which would make sense for the multimodal domain but probably not work for text?

2. There are repeated claims on images being "more expensive" in the token space e.g. “Image embeddings are expensive”, “the images require more tokens to embed”. I believe these claims could be concretized better by doing a simple analysis of difference in tokens, because I believe this difference is usually not prohibitive. It would also be nice to have numbers on the context lengths in the benchmarks mentioned. 

3. There is no evidence of degradation of model performance with increasing context length in the number of multimodal shots. Without this, it is hard to understand the motivation for choosing to encode shots in the weight space. If one can see the degradation being more rapid for vanilla ICL compared to this method, the motivation would be much more convincing.

3. Why does one need REINFORCE based selection? Concretely, how would the current method compare with the baseline of simply replacing all heads with the mean activations? It is unclear why the authors chose to use REINFORCE. 

4. Having many shots in the context (v/s in the weight space) provides the benefit of interpretability - what is the intuition on losing on this benefit? Does shot quality in the textual space correspond to shot quality in the weight space? As a follow up, how does the "cost of prompt iteration" compare between vanilla ICL v/s MTV?

5. How robust is this technique to shot quality e.g. noisy exemplars? Is it more or less robust than vanilla ICL?

6. The empirical results focus on comparisons with vanilla ICL. While encouraging, it would be convincing if the method shows performance improvements on long context tasks where vanilla ICL fails but this method works. Further, the tasks considered are still limited and a wider range of longer-context multimodal benchmarks could be considered. (to name some e.g. MMMU, TextVQA, DocVQA).
questions: questions: Besides the above, here's a suggestion: there are many abbreviations (e.g. VL benchmarks) which could be expanded clearly.
limitations: limitations: Limitations are mentioned.
paper_summary: paper_summary: This paper should be desk rejected as the single PDF submission does not have the paper checklist. 
It would be unfair to make an exception as this requirement has been clearly stated at https://neurips.cc/Conferences/2024/CallForPapers and the latex template file.
strength_weakness: strength_weakness: NA
questions: questions: NA
limitations: limitations: NA
paper_summary: paper_summary: This work presents MTV to enhance the in-context learning (ICL) capabilities of LMMs, which typically have limited context length, especially when dealing with multimodal data that includes both text and images. MTV addresses this by compressing many-shot examples into compact implicit representations within the model's attention heads. The approach involves calculating mean activations of attention heads across multiple inference iterations and selecting optimal locations for these activations using an adapted REINFORCE algorithm. This method allows LMMs to effectively use more examples than their context length permits, improving performance on various vision-and-language tasks without finetuning. Experiments demonstrate that MTV not only scales with more examples but also generalizes to similar out-of-domain tasks and works alongside explicit few-shot examples, offering a practical solution for efficient and effective many-shot multimodal ICL.
strength_weakness: strength_weakness: 1. Minor: the dataset can always be included more: Try MMMU[1], OpenFlamingo and Otter did worth with 1/3/5-shot examples.
2. Minor: the models can also be included more: Try Mantis[2]

[1] Yue et al., MMMU: A Massive Multi-discipline Multimodal Understanding and Reasoning Benchmark for Expert AGI. 2023 ArXiv.

[2] Jiang et al., Mantis: Interleaved Multi-Image Instruction Tuning, 2024 ArXiv.
questions: questions: 1. Can this method work on LMMs that can only take in one image? Because most of models currently being evaluated are models that can take multiple images. Since your work is like to use the in-context examples as the prior, then I think it's possible.
limitations: limitations: No significant limitations

Comments: title: Reply To Reviewer
response to the rebuttal
High-level Summary
comment: We thank the reviewer for taking the time to review our rebuttal. We would be happy to know if there are any remaining concerns that we can clarify or address.
I thank the authors for the rebuttal. After going through the answers, I stick to my current rating.
Thank you for the detailed responses. After going through the comments and other reviewer's comments, I have decided to raise my score. I look forward to seeing these results and the surrounding discussion in the final version.
Thanks for the addtional results, hope to see these results in the final version.
I raised my score as an outcome of the discussion.
We thank the reviewers for their valuable feedback. In this work, we present Multimodal Task Vectors (MTV)--- compact implicit representations of many-shot in-context examples compressed in the model’s attention heads— and leverage them for many-shot in-context learning in LMMs.

We are encouraged that the reviewers find our work and findings to be "important" (``dwXj``), "challenging" (``3gQC``), and "interesting" (``Xn5t``). The reviewers also noted the strength of our MTV method, which "outperforms existing methods" (``dwXj``), as well as the insightful nature of the ablation studies and efficiency results (‘Xn5t’), which help to ‘better analyze and understand the model’ (``dwXj``). Furthermore, they all noted our paper to be "well-written" (``dwXj``) and "coherent" (``3gQC``), especially appreciating the "step-by-step" (``Xn5t``) presentation and the clarity of Figure 1. 

We address all concerns separately in the section and look forward to an open and constructive discussion with the reviewers.