Abstract
Current Vision-Language (VL) models typically process images by converting them into long sequences of visual tokens, which are then concatenated with text inputs. This approach creates a significant computational bottleneck due to the quadratic complexity of the Transformer's self-attention mechanism relative to sequence length. We present Memory-Space Visual Prompting (MemVP), a novel fine-tuning method that bypasses this bottleneck by injecting visual information directly into the Feed-Forward Network (FFN) weights of a Large Language Model (LLM). By treating the FFN as a key-value memory, MemVP achieves superior performance on benchmarks like ScienceQA while delivering up to 1.7x faster training and 1.4x faster inference compared to standard input-space prompting.
1. Introduction
The integration of visual perception into Large Language Models (LLMs) has led to the development of powerful Vision-Language (VL) models such as LLaVA and Flamingo. The standard architecture for these models involves a pre-trained vision encoder whose outputs are projected into the LLM's input space as a series of "visual prompts."
However, this "input-space" approach suffers from a fundamental efficiency problem. A single image typically generates hundreds of visual tokens (e.g., 256 tokens), whereas the associated text prompt might be quite short. Because the computational cost of the Transformer architecture scales quadratically with the total sequence length, the model spends the majority of its compute budget processing visual tokens. This makes both training and deployment slow and memory-intensive.
2. Methodology: Memory-Space Visual Prompting (MemVP)
MemVP proposes a paradigm shift: instead of adding visual information to the input sequence, it injects it into the "memory" of the model.
2.1 FFN as Key-Value Memory
The core insight of MemVP relies on the observation that Feed-Forward Networks (FFNs) in Transformers function as key-value memories. In a standard FFN layer, the operation is defined as $FFN(x) = \phi(xW_1)W_2$, where $W_1$ acts as a set of "keys" and $W_2$ acts as "values."
MemVP leverages this structure by concatenating projected visual features directly onto the $W_1$ and $W_2$ weight matrices. This effectively adds "new rows" to the model's internal knowledge base for the duration of the task. When the LLM processes a text token, it can retrieve relevant visual information from its FFN memory via the standard forward pass, eliminating the need for visual tokens in the input sequence.
2.2 Implementation and Training
The MemVP architecture consists of three main components:
- Projector: A linear layer or MLP that maps features from the vision encoder to the LLM's hidden dimension.
- Position Embeddings: Learnable embeddings added to the visual features before they are injected into the FFN to preserve spatial information.
- Parameter-Efficient Fine-Tuning (PEFT): During the fine-tuning process, the vision encoder and the original LLM weights remain frozen. Only the projector and the position embeddings are updated, making the process highly efficient.
3. Experimental Setup
The authors evaluated MemVP across several LLM architectures, including BART, T5, and LLaMA (7B and 13B). The method was tested on a diverse set of benchmarks:
- Visual Question Answering: VQAv2, GQA, and ScienceQA.
- Image Captioning: COCO Captions.
- Video QA: TVQA and How2QA.
- Instruction Tuning: LCS-558K and 665K datasets.
4. Results and Analysis
MemVP demonstrates significant improvements in both performance and efficiency over existing Parameter-Efficient Fine-Tuning (PEFT) methods.
4.1 Performance Benchmarks
On the ScienceQA benchmark, MemVP (7B) achieved an accuracy of 93.07%, notably outperforming LLaVA-LoRA (90.85%) and LaVIN (89.41%). When scaled to 13B parameters, MemVP reached 93.78% accuracy.
4.2 Efficiency Gains
By maintaining short input sequences, MemVP avoids the $O(L^2)$ complexity spike associated with long visual prompts. Compared to standard input-space prompting (VL-PET), MemVP provides:
- 1.7x faster training speeds.
- 1.4x faster inference speeds.
- 44% reduction in training memory usage (using only 56% of the memory required by previous state-of-the-art PEFT methods).
4.3 Spatial Awareness
Qualitative analysis suggests that the model maintains spatial awareness despite the lack of explicit visual tokens in the input. Visualization of the "lookup" process shows that specific text tokens (e.g., "man") successfully retrieve information from the FFN entries corresponding to the correct spatial locations in the image.
5. Discussion and Limitations
MemVP redefines the role of visual information in VL models, treating images as external knowledge injected into the model's weights rather than mere context in the input stream.
However, certain limitations remain. The speedup is most pronounced during the "prefill" stage (processing the prompt). In tasks requiring long-form text generation, the bottleneck eventually shifts back to the auto-regressive decoding of text tokens. Additionally, for complex instruction-following tasks, MemVP is most effective when paired with LoRA to help the language model adhere to specific formatting or reasoning requirements.
6. Conclusion
Memory-Space Visual Prompting offers a highly efficient alternative to traditional vision-language integration. By shifting visual data from the input sequence to the FFN memory, MemVP achieves state-of-the-art performance while significantly reducing the computational and memory overhead of multi-modal fine-tuning.
Summary updated