Multimodal Function Vectors for Visual Relations

Shuhao Fu, Esther A Goldberg, Ying Nian Wu, Hongjing Lu

Large Multimodal Models (LMMs) like GPT-4V and Qwen-VL have demonstrated remarkable capabilities, yet their internal reasoning processes remain largely opaque. A persistent challenge for these models is systematic relational reasoning—understanding how objects interact or are spatially positioned relative to one another (e.g., "the cat on the mat").

Traditionally, In-Context Learning (ICL) is used to teach these tasks by providing a few examples in the prompt. However, LMMs often struggle to generalize these relations or require numerous examples to succeed. This paper investigates whether relational knowledge is localized within specific internal structures of the model and if this knowledge can be extracted to control the model more effectively than standard text prompting.

The Solution: Multimodal Function Vectors

Researchers discovered that LMMs encode visual relations—such as "above" or "carrying"—within a remarkably small subset of their internal attention heads. By extracting the activations from these specific heads, the authors created "function vectors." These vectors can be injected back into the model to steer its reasoning, significantly outperforming standard in-context learning and even solving novel analogies by linearly combining different relation vectors.

Methodology

The authors extended the concept of Function Vectors (FVs)—previously established in text-only Large Language Models—to the multimodal domain. Their approach involves three primary steps:

  1. Causal Mediation Analysis (CMA): To locate the "relational" components, the researchers systematically perturbed the activations of various attention heads while the LMM processed tasks. They identified a sparse subset of heads, typically in the intermediate layers, that exert the strongest causal influence on relational predictions.
  2. Extraction and Injection: Activations from these top-performing heads are averaged to form a single function vector. During a zero-shot prompt (where no examples are provided), this vector is injected into the model’s hidden state, effectively instructing the model on which relation to identify.
  3. Fine-Tuning and Composition: These vectors can be fine-tuned using a small dataset while keeping the entire backbone model frozen. Furthermore, the authors introduced Composite Function Vectors (CFVs) to solve visual analogies. For an untrained, complex relation like "above-left," they linearly combined the individual "above" and "left" vectors based on a single source example.

The methodology was evaluated on both controlled and "in-the-wild" datasets:

  • Synthetic Image Dataset: Constructed using 42 object cutouts placed in specific spatial configurations (above, below, left, right).
  • GQA (Real-world): A dataset featuring real-world images with detailed scene graphs, focusing on Spatial relations (e.g., behind, next to) and Agentic relations (e.g., carrying, riding).

Key Findings & Results

  • Relational Localization: Relational reasoning is highly localized. It is not a "whole-brain" activity for LMMs. Injecting vectors too early or too late in the model's depth fails; the knowledge resides specifically in intermediate layers.
  • Massive Performance Gains: On the synthetic dataset, using a fine-tuned function vector improved the Qwen3-VL model's accuracy from 26.8% (using 4-shot ICL) to an impressive 72.2%. Similarly, for real-world GQA Spatial tasks, fine-tuned FVs more than doubled the zero-shot baseline accuracy of OpenFlamingo.
  • The Power of Linearity and Analogies: The "Linear Representation Hypothesis" extends to multimodal relations. By adding vectors together, the composite approach improved Qwen3-VL's accuracy on novel relation analogies (like "below-right") from 28.7% to 45.1%.
  • Robust Generalization: Vectors extracted from simple synthetic images successfully applied to complex, real-world GQA images. Furthermore, performance remained strong even when test images contained novel objects unseen during the extraction phase, suggesting the model learns a fundamental, abstract representation of these relations.

Limitations & Future Directions

While groundbreaking, the study has constraints. It focused on a narrow set of spatial and agentic relations, leaving it unclear if abstract social or physical relations (e.g., "helping" or "supporting weight") are similarly localized. Additionally, creating composite vectors for analogies still requires at least one "source" example to calculate correct weights.

Finally, because the "relational geometries" differ between models like OpenFlamingo and Qwen3-VL, vectors are not yet plug-and-play across different architectures. Future research will explore how these vectors interact with noisier, real-world prompts and whether they can be utilized to audit models for biased relational reasoning.

Summary updated

BibTeX
@inproceedings{fu2026multimodal,
  author = {Shuhao Fu and Esther A Goldberg and Ying Nian Wu and Hongjing Lu},
  title = {{Multimodal Function Vectors for Visual Relations}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=KBvnXHCIch},
}
Figure