Share your thoughts, 1 month free Claude Pro on usSee more
WorkDL logo mark

Train Once, Reuse Everywhere: Generalizable Implicit In-Context Learning by Routing Attention

About

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 captures and utilizes 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 an efficient 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 existing implicit ICL methods that require task-specific retrieval or training, while demonstrating robust generalization to out-of-domain tasks where they struggle. These findings position ICR to push the boundary of the practical value of ICL. The code is available at https://github.com/Lijiaqian1/In-Context-Routing.git.

Jiaqian Li, Yanshu Li, Ligong Han, Ruixiang Tang, Wenya Wang• 2025

Related benchmarks

TaskDatasetResultRank
Question AnsweringPIQA
Accuracy82.6
589
Physical Interaction Question AnsweringPIQA
Accuracy57
462
Question ClassificationTREC
Accuracy82.2
274
Sentiment AnalysisSST-5 (test)
Accuracy41.4
189
Sentiment AnalysisSST-2
Accuracy93.8
175
Sentiment ClassificationMR (test)
Accuracy89.4
154
Question ClassificationTREC (test)
Accuracy83.8
150
Topic ClassificationAG News (test)
Accuracy86.6
128
Commonsense ReasoningCSQA (test)
Accuracy82
123
Physical Commonsense ReasoningPIQA (test)
Accuracy82.6
71
Showing 10 of 33 rows

Other info

Follow for update