Towards Generalizable Implicit In-Context Learning with Attention Routing

Jiaqian Li, Yanshu Li, Ligong Han, Ruixiang Tang, Wenya Wang
9/26/2025
cs.CL

No confident code implementation found for this paper.

Abstract

Implicit in-context learning (ICL) has newly emerged as a promising paradigm that simulates ICL behaviors in the representation space of Large Language Models (LLMs), aiming to attain few-shot performance at zero-shot cost. However, existing approaches largely rely on injecting shift vectors into residual flows, which are typically constructed from labeled demonstrations or task-specific alignment. Such designs fall short of utilizing the structural mechanisms underlying ICL and suffer from limited generalizability. To address this, we propose In-Context Routing (ICR), a novel implicit ICL method that internalizes generalizable ICL patterns at the attention logits level. It extracts reusable structural directions that emerge during ICL and employs a learnable input-conditioned router to modulate attention logits accordingly, enabling a train-once-and-reuse framework. We evaluate ICR on 12 real-world datasets spanning diverse domains and multiple LLMs. The results show that ICR consistently outperforms prior implicit ICL methods that require task-specific retrieval or training, while demonstrating robust generalization to out-of-domain tasks where existing methods struggle. These findings position ICR to push the boundary of ICL's practical value.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Cite this paper

@article{li2025towards,
  title  = {Towards Generalizable Implicit In-Context Learning with Attention Routing},
  author = {Jiaqian Li and Yanshu Li and Ligong Han and Ruixiang Tang and Wenya Wang},
  year   = {2025},
  eprint = {2509.22854},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2509.22854v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2509.22854.svg)](https://codeofpaper.com/paper/2509.22854)

Discussion