# Capturing In-Context Learning Dynamics with Task Operators

*Guangzhi Xiong, Zhenghao He, Bohan Liu, Sanchit Sinha, Wenqian Ye, Aidong Zhang*

[NeurIPS page](https://neurips.cc/virtual/2026/poster/149094) · [Open on the map](../papers.html#p149094)

Category: [Interpretability & Model Adaptation](../pcat/15.md) › [Transformer In-Context Learning](../pgroup/655.md) · Type: new method · Keywords: in-context learning, attention mechanisms, affine transformation, efficient inference, language model compression

Areas: [LLM Reasoning](../areas/reasoning.md) › Efficient Reasoning › In-Context Learning; [Long Context](../areas/longcontext.md) › Long-context mechanisms › In-context learning; [Model Architectures & Sequence Modeling](../areas/architectures.md) › Language Model Architectures › Attention Interactions

## Summary
Task Operator (TO) captures in-context learning dynamics by modeling each attention head's affine transformation, enabling efficient ICL inference with performance comparable to full ICL.

## Explained to a 5-year-old
When a big computer program sees examples of a task, it can do the task without learning. But looking at many examples is slow. We found a way to copy a simple rule from those examples so the program can do the task faster. This rule works like a shortcut that helps the program guess answers quickly. It also helps the program get better at guessing without needing more memory.

## Explained to a 5-year-old, longer
A computer program can learn to do new things just by looking at a few examples, without changing its memory. This trick is called in-context learning, and it works like reading a story and then answering questions about it. The problem is that the program has to look at all the examples every time it wants to answer, which makes it slow and uses a lot of computer power. Researchers wanted to understand how this trick really works inside the program. They discovered that each part of the program that pays attention behaves like a simple math rule that changes one version of the information into another. This rule stays the same for the same kind of task, no matter which examples are shown. Using this rule, they built a shortcut that lets the program apply the rule quickly instead of re-processing everything. The shortcut helps the program do the task almost as well as when it looks at all the examples. They also found that the important parts of the program form a small, focused network that stores the knowledge. By combining these small networks from different groups of examples, the program can handle many examples without needing more memory. This makes the program faster and cheaper to run while keeping its performance high. Overall, the new idea makes learning from examples easier and more efficient for computers.

## For a technical reader
The paper investigates why in-context learning (ICL) is computationally expensive, noting that each inference processes the full demonstration set. By analyzing the ICL forward pass, the authors show that each attention head’s output can be expressed as an affine transformation of a masked version, with stable parameters per task. Leveraging this insight, they derive an analytical update that can be applied directly to the attention output projection, effectively compressing the ICL behavior into a lightweight operation. Experiments on lexical, algorithmic, and reasoning benchmarks demonstrate that this compression matches or exceeds prior methods and narrows the gap to zero-shot performance. Additionally, they identify a sparse circuit across layers and propose operator averaging to scale many-shot learning without increasing context length.

## Problem
In-context learning requires processing all demonstration examples at each inference, leading to high computational cost, and the underlying mechanisms of ICL are not well understood.

## Method
The approach analyzes the ICL forward pass to discover that each attention head's output can be expressed as an affine transformation of its context-masked version, with stable transformation parameters per task. It then derives an analytical update that replays this transformation as an attention output projection adjustment, and leverages sparse circuits and operator averaging for many-shot scaling.

## Results
The approach matches or exceeds prior methods on lexical, algorithmic, and reasoning tasks and significantly reduces the performance gap between zero-shot and full ICL.

## Contributions
It reveals that ICL can be represented by stable affine transformations per attention head, identifies a task-specific sparse circuit underlying ICL knowledge, and provides an efficient operator-based method for many-shot scaling without expanding context.

## Research questions this paper is counted under

- [How can we select the most effective demonstration examples for in-context learning?](../q/871.md)

This page was written by language models from the title and abstract of each paper, and the answers were checked by two other models. It can be wrong: check the paper itself. [Suggest a correction](../feedback/?on=p/149094)
