Learn the Effects, Not the Examples: Implicit ICL via Attention Patching
Abstract
In-context learning (ICL) enables language models to adapt to new tasks from demonstrations, but repeatedly including multiple examples increases context length and inference cost. Many existing implicit ICL methods encode demonstrations as fixed vectors, limiting adaptation of the intervention to individual queries and token positions. We propose Attention-Patching, an implicit ICL method that models contextual changes in self-attention outputs through task-specific updates to attention output projections. Using query-answer pairs processed with and without a fixed demonstration set, Attention-Patching fits layer-wise affine transformations from non-contextual attention representations to the demonstration-induced output changes. Across 12 classification benchmarks and four model families, Attention-Patching achieves higher average accuracy than the evaluated implicit ICL baselines while maintaining performance comparable to explicit ICL at near zero-shot inference cost. Further experiments on diverse generation tasks demonstrate its applicability to autoregressive multi-token generation.
Create a lesson
Metadata
- Categories
- cs.CL, cs.LG
Related papers
Look Back, Draft Ahead: Corrective Prefix Attention for Parallel Speculative Decoding
Shared title terminologycs.CLMohammad Mahdi Moradi, Ali Pourranjbar, Zongzuo Wang et al.
From Rewarding What Models Say to How They Think: Attention Process Reward Model for LLM Reinforcement Learning
Shared title terminologycs.CLKairong Han, Nuanqiao Shan, Ziyu Zhao et al.
The Temporal Residual: Fast and Effective Retrofitting of Latent Feedback into Pretrained Language Models
Shared title terminologycs.CLZiyang Cai, Xingyu Zhu, Sanjeev Arora
Position-Skipped Distillation of Sparse-Attention Indexers: Train Short, Serve Long
Shared title terminologycs.CLFu Dai, Haodi Quan, Kamal Taha
Reducing Permutation Sensitivity in Multimodal Large Language Models via Shared Positions and Attention-Only Distillation
Shared title terminologycs.CLYifei Cheng, Xiaolin Zhang, Yu-Xuan Qiu
From Reward Engineering to Data-Centric Reinforcement Learning for Effective Agentic Visual Tool Use
Shared title terminologycs.CLJin Cui, Xinyue Long, Jiepeng Zhou et al.