Just-in-time and distributed task representations in language models

Yuxuan Li, Declan Campbell, Stephanie C. Y. Chan, Andrew Kyle Lampinen · DOI

Introduction

Large Language Models (LLMs) exhibit a remarkable capacity for In-Context Learning (ICL), adapting to new tasks through a few provided examples. However, the internal dynamics of how these tasks are represented and executed remain poorly understood. A recent study by Google DeepMind explores whether LLMs maintain stable mental models of tasks or if their functional machinery is more ephemeral.

The Dual-Mechanism Hypothesis

The researchers propose that LLMs manage tasks through two distinct internal mechanisms:

  1. Identifiable Representations (Task Identity): A persistent, "inert" sensitivity to the task type that is present throughout the prompt.
  2. Transferrable Representations (Task Execution): An active, "just-in-time" functional vector required to drive specific behavior, appearing only at critical "trigger" tokens.

Methodology: Probing and Patching

To map these representations, the study employed two primary techniques across model families like Gemma and Qwen:

  • Linear Decoders (Probes): Used to determine if task identity (e.g., "this is a translation task") could be decoded from internal activations at any given token.
  • Activation Patching: Researchers extracted "task vectors" from the residual stream of a few-shot prompt and injected them into a zero-shot prompt. This "recontextualization" tests if the model can perform the task without seeing the original examples.
The process of extracting a task representation from few-shot examples and patching it into a zero-shot context.

Key Insights

Just-in-Time Execution

The most significant finding is the temporal locality of functional task vectors. While a model can "identify" the task at almost any point in the context, the vector capable of transferring task performance only forms at specific trigger tokens—typically the punctuation (like a colon) immediately preceding the expected answer.

Inert vs. Active Knowledge

The model maintains a constant awareness of the task context (identity) but only "loads" the execution machinery into active memory at the moment of use. This suggests an efficiency strategy, potentially to avoid saturating the residual stream's capacity with unnecessary functional data.

Evidence Accrual and Convergence

As the number of examples increases (up to 32 shots), task vectors become more effective and "sharper." The internal representations "denoise," converging toward a stable functional state. However, complex tasks like counting or multi-step reasoning show "semantic fading," where the functional representation fails to persist across chained subtasks.

Results and Performance

The experimental results highlight a sharp contrast between identity and execution:

  • Identity Accuracy: Linear decoders achieved near 100% accuracy in identifying the task from activations at almost any token.
  • Transfer Accuracy: Patching activations from non-trigger tokens resulted in nearly 0% task accuracy. Only trigger-token patching successfully restored performance in zero-shot settings.
Overview of recontextualization accuracy and the development of task representations across model sizes.

As shown in the figures above, recontextualized zero-shot performance significantly outperforms standard zero-shot baselines, approaching few-shot levels as the model size and context length increase.

Conclusion

This research indicates that LLMs do not maintain a static "mental state" for tasks. Instead, they utilize a distributed identity representation coupled with a highly localized, just-in-time execution mechanism. Understanding these micro-second dynamics is essential for improving model steerability and developing more robust mechanistic interpretability frameworks.

Summary updated

BibTeX
@inproceedings{li2025just,
  author = {Yuxuan Li and Declan Campbell and Stephanie C. Y. Chan and Andrew Kyle Lampinen},
  title = {{Just-in-time and distributed task representations in language models}},
  booktitle = {MechInterp @ NeurIPS},
  year = {2025},
  url = {https://openreview.net/forum?id=KC13tBPbQg},
}
Figure