This repo contains the official code for the following paper published at ACL 2026:
Yu Wang, Sharon Li. "Why Multimodal In-Context Learning Lags Behind? Unveiling the Inner Mechanisms and Bottlenecks"
- Coming soon — Dataset release
- June 28, 2026 — Code released 🎉
- April 15, 2026 — We released the paper on Arxiv.
In-context learning (ICL) enables models to adapt to new tasks via inference-time demonstrations. Despite its success in large language models, the extension of ICL to multimodal settings remains poorly understood in terms of its internal mechanisms and how it differs from text-only ICL. In this work, we conduct a systematic analysis of ICL in multimodal large language models. Using identical task formulations across modalities, we show that multimodal ICL performs comparably to text-only ICL in zero-shot settings but degrades significantly under few-shot demonstrations. To understand this gap, we decompose multimodal ICL into task mapping construction and task mapping transfer, and analyze how models establish cross-modal task mappings, and transfer them to query samples across layers. Our analysis reveals that current models lack reasoning-level alignment between visual and textual representations, and fail to reliably transfer learned task mappings to queries. Guided by these findings, we further propose a simple inference-stage enhancement method that reinforces task mapping transfer. Our results provide new insights into the mechanisms and limitations of multimodal ICL and suggest directions for more effective multimodal adaptation.
- Two GPU with more than 80GB VRAM and CUDA (Ver.
12.4recommended) are strongly required to run all the experiments. - Network connection to
huggingfaceis needed to download the pre-trained model. And ahuggingfaceuser token with access to the [Qwen2.5-VL-7B/32B] and [Gemma-3-12B/27B] model is recommended to run a part of the experiments.
git clone https://github.com/deeplearning-wisc/Multimocal-ICL-Analysis-Framework-MGI.gitDirect Installation
conda env create -f environment.yaml
conda activate icl_analysisDue to the fact that this paper consists of many relatively independent experiments, we provide a unified script-based approach to generate the main visualizations. The detailed experiment instructions are included in each section below.
python Experiments/vis_attention_analysis.py \
--model "Qwen/Qwen2.5-VL-7B-Instruct" \
--mode image_vis \
--output-dir results/vis_attentionVisualizes demo label token attention to image patches layer-by-layer with heatmap overlay on the original images.
python Experiments/finding1_attntion_curve_indemo.pyShows layer-wise attention ratios to correct/false/irrelevant evidence regions for both correct and incorrect predictions.
python Experiments/finding2_attntion_curve_query2image.py
Computes and visualizes the attention difference (Correct - Error) in layer-wise last-token attention to evidence regions for both models.
python control_att_exp.pypython IMP_mllm_ours_v1.py python IMP_mllm_ours_gt_mask.pyrefer to plot.ipynb
- This project builds upon ICL_Circuit and
StaICC. We thank the authors for their excellent work.
If you find this work useful for your research, please cite our paper:
@inproceedings{wang2026multimodal,
title={Why Multimodal In-Context Learning Lags Behind? Unveiling the Inner Mechanisms and Bottlenecks},
author={Wang, Yu and Li, Sharon},
booktitle={Proceedings of the 64th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)},
pages={13670--13685},
year={2026}
}