# Task Vector Geometry Underlies Dual Modes of Task Inference in Transformers

*Hao Yan, Haolin Yang, Yiqiao Zhong*

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

Category: [Interpretability & Model Adaptation](../pcat/15.md) › [Transformer In-Context Learning](../pgroup/655.md) · Type: new method · Keywords: task vectors, transformer inference, out-of-distribution generalization, geometry of representations, Bayesian task retrieval, extrapolative learning

Areas: [LLM Reasoning](../areas/reasoning.md) › Reasoning Mechanisms › Representation Geometry

## Summary
Task Vector Geometry reveals that transformers can infer tasks via two modes-Bayesian retrieval of seen tasks using convex combinations of learned task vectors and extrapolative learning for novel tasks in an orthogonal subspace-providing a principled characterization of OOD generalization.

## Explained to a 5-year-old
Transformers are computer programs that try to understand what they are supposed to do. Sometimes they can remember a task they have seen before, like a puzzle they know. Other times they have to figure out a new task they have never seen, like a brand-new game. The paper looks at how the computer stores these tasks inside little directions and how those directions are arranged. It shows that both ways of guessing work together, helping the computer do better on new problems.

## Explained to a 5-year-old, longer
A transformer is a kind of computer brain that reads sequences of symbols. It can be asked to do many different tasks, like translating words or drawing pictures. When it sees a task it has seen many times before, it can quickly recall how to do it. When it meets a brand-new task it has never done, it must try to learn how to do it on the fly. Researchers have discovered that the brain stores information about tasks in special directions. These directions are called task vectors because they point toward the way a task should be performed. The paper studies how these directions are arranged in the brain’s geometry. It shows that known tasks are combined in a simple way, like mixing colors to get a new shade. New tasks are stored in a different area that is almost perpendicular to the known task area. This separation helps the model not to forget old tasks when it learns something new. The findings explain why transformers can sometimes guess correctly on familiar problems and sometimes adapt to unfamiliar ones. Overall, the work gives a clearer picture of how transformers think about tasks.

## For a technical reader
The paper investigates how transformers internally represent tasks using learned direction vectors, showing that they can retrieve known tasks via convex combinations and discover new tasks through an orthogonal subspace. By training small transformers on synthetic latent-task sequences, the authors mathematically characterize the geometry that governs in-distribution Bayesian retrieval and out-of-distribution extrapolative learning. The results confirm that both inference modes coexist in a single model, providing a principled link between task-vector geometry, training distributions, and generalization behavior. This insight suggests that future architectures could be designed to better control task inference by shaping the underlying vector subspaces. The work offers a clear, mathematically grounded framework for understanding and potentially improving transformer adaptability.

## Problem
How does the geometry of task vectors in transformers influence the coexistence of recognizing known tasks and adapting to unseen ones, and what geometric properties enable out-of-distribution generalization?

## Method
The authors train small transformers from scratch on synthetic latent-task sequences, analyze the geometry of learned task vectors, and characterize in-distribution behavior through convex combinations of these vectors and OOD behavior through a nearly orthogonal subspace.

## Results
The approach demonstrates that in-distribution task inference follows Bayesian retrieval via convex combinations of task vectors, while out-of-distribution inference uses an orthogonal extrapolative subspace, confirming the coexistence of the two inference modes.

## Contributions
It provides a principled mathematical characterization of task-vector geometry, reveals the dual inference modes in a single transformer, and links training distribution geometry to OOD generalization.

## Limitations and assumptions
The study uses a synthetic latent-task distribution, which may limit direct applicability to real-world tasks.

## Research questions this paper is counted under

- [How can a model simultaneously retain existing knowledge and effectively learn or adapt to new tasks under varying conditions?](../q/196.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/152712)
