acceptodds
Published as a conference paper at NeurIPS 2026

Task Vector Geometry Underlies Dual Modes of Task Inference in Transformers

Hao Yan, Haolin Yang, Yiqiao Zhong

Abstract

Transformers are effective at inferring the latent task from context via two inference modes: recognizing a task seen during training, and adapting to a novel one. Recent interpretability studies have identified from middle-layer representations task-specific directions, or task vectors , that steer model behavior. However, a lack of rigorous foundations hinders connecting internal representations to external model behavior: existing work fails to explain how task-vector geometry is shaped by the training distribution, and what geometry enables out-of-distribution (OOD) generalization. In this paper, we study these questions in a controlled synthetic setting by training small transformers from scratch on latent-task sequence distributions, which allows a principled mathematical characterization. We show that two inference modes can coexist within a single model. In-distribution behavior is governed by Bayesian task retrieval, implemented internally through convex combinations of learned task vectors. OOD behavior, by contrast, arises through extrapolative task learning, whose representations occupy a subspace nearly orthogonal to the task-vector subspace. Taken together, our results suggest that task-vector geometry, training distributions, and generalization behaviors are closely related.

Keywords:
Atlanta

Reviews

Among:
Shape:
123456this paper, Top 8%
Figure 1. Mean review rating of the reviewed papers at NeurIPS 2026. This paper averages 5.00 over 3 reviews, above 92% of the others.
Reviewer_GdjiOpenReview ↗
Rating
5
Clarity
3
Confidence
3
Originality
3
Quality
3
Significance
3
Read review
Summary

This paper studies how a transformer behaves on different types of tasks and argues that a single model does this in two different ways. The authors train transformers on synthetic tasks, define a task vector, and propose a set of properties describing how the model encodes the task. For familiar tasks, the model recognizes and retrieves the answer using the space spanned by these task vectors, while for new tasks it uses separate space that is nearly perpendicular to the first.

Strengths and weaknesses

Strengths

  • S1. The paper replaces heuristic-based task-vector extraction with a principled framework that defines task vectors through testable properties (P0 to P3 in the paper). I like this because the earlier definitions had no property to fail against. This paper (at least in its controlled setting) can check whether a candidate vector captures task structure rather than just happening to steer the output.
  • S2. I believe the double dissociation is a very convincing result with a clean cause-and-effect test. Turn off the task subspace and the model fails on memorized tasks but still handles new ones. Turn off the near-orthogonal subspace and the opposite happens. Since the two behaviors break independently, they point to two separate mechanisms rather than one thing described two ways.
  • S3. The authors include a bracket-matching experiment that deliberately breaks the paper's core assumption. I value this because it shows the authors know exactly where their framework stops applying, which points to a well-designed setup.

Weaknesses

  • W1. The properties and the dissociation are stated as if they hold in general, but the paper's per-layer results show they mostly hold in the middle layers. Table 2 also reports its intervention result as an average over a middle-layer band rather than across all layers. Presenting the properties and Table 2 without this depth qualifier can invite over-generalization. In fact, extracting a task vector from a late layer would recover none of these properties, so the depth band is part of what makes the method work and belongs in the statement of the claims rather than being left to the appendix.
  • W2. The paper does not cleanly explain the depth pattern it relies on. The appendix offers partial evidence, but it does not elaborate why the transitions land at the particular layers observed nor how this depth localization connects to the two-mode claim. This leaves the reader unable to tell whether the middle-layer concentration is a fundamental feature of how the two modes are represented or just an artifact of these particular models and tasks.
Questions
  • Q1. Why do the properties and the mode separation show different trends across layers? The authors should investigate the reason for this layerwise trend more deeply and connect with prior work on how transformer layers specialize with depth. The point is to clarify whether the depth localization is an incidental artifact or a structural feature of the two-mode claim.
  • Q2. The per-layer results (Figs 18 and 19) show the double dissociation is a middle-layer phenomenon. What should a reader conclude about the two modes at the output layers that produce the token? It would help to distinguish two cases. One is that the modes merge back together near the output. The other is that they resolved in earlier layers, thus the information is still present but no longer arranged along the perpendicular directions the probe measures. The paper hints at the second case but does not confirm it and so, showing whether the modes stay active at the output would help.
Limitations

yes

Paper formatting concerns

N/A

Final justification

Overall, the strengths outweigh the weaknesses. I recommend accept.

The authors resolved my main concern by clarifying that the two-mode separation is strongest in intermediate layers and by agreeing to narrow the claims and better present the full layerwise results.

Some remainders: the interpretation of Table 2 and the differing layerwise behavior of P0–P3.

Reviewer_x7HZOpenReview ↗
Rating
5
Clarity
3
Confidence
4
Originality
3
Quality
3
Significance
3
Read review
Summary

This work is motivated to understand how transformers internally infer latent tasks from context and how this inference relates to task-vector geometry. The paper studies small transformers trained from scratch on controlled synthetic latent-task sequence distributions. The authors define task vectors as latent-task-dependent directions in hidden-state space and propose a geometric framework in which hidden states decompose into task-related and token-related components. 

The claims of the paper are that two modes of task inference can coexist in a single transformer. For in-distribution tasks, the model performs Bayesian task retrieval: hidden states represent convex combinations of task vectors, and the coefficients approximately track the true Bayesian posterior over training tasks. For out-of-distribution tasks, the model shifts toward extrapolative task learning, where context statistics are represented in a subspace nearly orthogonal to the task-vector subspace.

Strengths and weaknesses

Strengths

Clear mathematical/statistical setup The paper provides a clear mathematical vocabulary for discussing task vectors. The properties P0–P3 give a useful hierarchy. This is an valuable and insightful attempt to make the heuristic notion of task vectors more precise.

Controlled synthetic setup The synthetic setup is well chosen for mechanistic analysis. Since the latent task and data-generating distributions are known, the authors can compute oracle Bayesian posteriors, estimate hidden-state coefficients​, and directly compare the two. This makes the posterior-alignment claim much cleaner than it would be in natural-language settings. 

Intervention experiments The work shows that β\beta correlated with α\alpha, it also ntervenes on the task-subspace component and shows outputs move toward the corresponding target mixture predictions, and the orthogonal-subspace interventions establish a double dissociation. This provides stronger evidence that the task-vector subspace is functionally involved in prediction. The two-mode analysis is also appealing. By varying task diversity, the paper shows a transition from retrieval-like behavior to extrapolative behavior, and the projection analyses suggest that OOD representations move away from the major-task subspace.

Weaknesses: novelty, experimental setup, applicability

Some findings may follow from linear factor analysis

In the Markovian synthetic settings, if I understand correctly, the optimal sufficient statistic is essentially the posterior over a finite task set plus the current token or input. If hidden states encode this statistic linearly, projecting onto class-conditional task-mean directions could naturally recover posterior-like barycentric coordinates, so the β≈α\beta \approx \alpha result may be less surprising than the framing suggests.

The causal results go beyond a passive factor-analysis account (which is nice), but the paper would be stronger if it established what the task-vector construction adds over standard baselines. Relatedly, Theorem 2 reads as a dimension-mismatch obstruction; here the empirical claim is near-orthogonality to col(Θ^\hat{\Theta}), whereas the theorem appears to justify only distance from the task subspace, and since random high-dimensional directions are near-orthogonal to any fixed low-dimensional subspace by default, a random-direction baseline would help show the separation is learned rather than generic.

Synthetic examples The experimental setup is quite favorable to the proposed framework. E1–E3 satisfy a first-order Markov property conditioned on the latent task, making it plausible that hidden states can be summarized by task identity and current token. The non-Markovian Dyck example is useful because it shows that this structure can fail, but it also highlights that the main framework may require a compact sufficient state representation to be meaningful.

Questions

How much of posterior alignment is explained by supervised linear factor analysis?

Since task vectors are estimated from task-conditioned hidden-state means, and β\beta is obtained by projecting hidden states onto the task-vector simplex, the posterior-alignment result may partly follow from the geometry of class-conditional means. Could the authors compare their task-vector basis against simpler baselines such as PCA/FPCA of hidden states, LDA-style class-mean subspaces, or linear regression probes from hidden states to α\alpha? This would clarify what the proposed construction adds beyond standard belief-state factorization.

What exactly is gained by Theorem 1 beyond decoding from assumed posterior coordinates?

Theorem 1 assumes posterior-aligned representations and then constructs a downstream computation that recovers the Bayesian predictive distribution. This seems like a useful expressivity statement, but it does not address whether training finds such a representation.

Can Theorem 2 be positioned as a low-rank approximation obstruction?

Could the authors connect the result to PCA/low-rank approximation or manifold embedding theory to clarify its contribution? Separately, the empirical claim is near-orthogonality, but the theorem appears to justify only distance from the task subspace. A baseline would help here too: how orthogonal are random same-dimension directions to col(Θ^\hat{\Theta}), and how does the reported R2R^2 compare?

How sensitive are the conclusions to the layer used for task-vector extraction?

The paper notes that task identity is most cleanly represented in middle layers, while later layers become more prediction-oriented. Could the authors provide a more systematic layer-selection criterion? This matters because task vectors extracted from different layers may support different interpretations.

Could the authors clarify the novelty relative to belief-state geometry and classical latent-variable models?

The paper connects to Bayesian belief states, linear representation hypotheses, and superposition, but the main synthetic results also resemble classical latent-variable posterior encoding plus low-rank geometry. A clearer comparison to classical factor-analysis/mixture-model interpretations would help readers understand what is uniquely transformer-specific.

Limitations

Yes

Paper formatting concerns

No concern

Final justification

Across two rounds of rebuttal, the authors resolved all three with concrete new experiments. The contribution is now clearly delineated and well-supported, and I recommend acceptance.

Reviewer_spCnOpenReview ↗
Rating
5
Clarity
3
Confidence
3
Originality
3
Quality
3
Significance
3
Read review
Summary

The paper proposes a framework for understanding the representation geometry behind task inference in transformers. Tasks are latent variables drawn from a finite training set, and sequences are generated conditionally with a first-order Markov property given the latent. Task vectors are defined in activation space, not in weights-space, as the row main effects of an ANOVA-style (task x current token) decomposition of the hidden states. The authors state four properties P0-P3 of increasing strength, ending with the claim that the simplex coefficients of the hidden state track the Bayesian posterior over tasks. Two inference modes are studied: Bayesian retrieval (M1), where in- distribution (ID) hidden states interpolate inside the task-vector simplex, with an expressivity result (Theorem 1) that two extra blocks + a proper unembedding layer can realize Bayesian prediction. Then, an extrapolative learning (M2), where their Theorem 2 states that when the OOD prediction map has intrinsic dimension d0 is sufficiently larger than k*, i.e. the dimension of the subspace spanned by the main (ID) tasks, the OOD representations must exit the task subspace, and empirically they show not only that, but also that those OOD tasks exit by forming near-orthogonal sub-spaces. They verify P0-P3 on three synthetic settings (dice, in-context linear regression, Markov chains), then the authors show a phase transition from M1 to M2, showing that the two subspaces are near-orthogonal. Finally, a non-Markovian experiment shows P0 fails when there's no compact sufficient statistic, i.e. when the entire context is needed for the prediction.

Strengths and weaknesses

Strengths:

  • very nice topic to shed lights on
  • nice formulation for the task vectors, using the ANOVA grid
  • Formulating the main properties as incrementally more difficult (P3 > P2 > P1 > P0) is clever, so that the authors only needed to verify the strongest one (P3)
  • Theorem 2 is interesting and it is not only verified in theory but also empirically by the authors
  • interesting transition regime from M1 to M2

Weaknesses:

  • Real world applicability: the theorems formulated and proven by the authors, especially Theorem 2, are nice and interesting, and using a controlled environment with toy tasks is a good setting to show the theory in practice. However, this reviewer can’t help but wonder how much of these findings can be actually applied in more realistic settings, with harder tasks and bigger and more powerful (often pre-trained) models.
  • The “qualitative” pretrained-LLM evidence is rather thin: 3-6 hand-picked tasks, one layer, one model. I don’t think it qualifies as a true experiment for real world scenarios.
  • The first-order Markov property is omni-present in the paper, and the moment it is violated (as shown by the authors in their “Dyck” experiment in Section 7) show how fragile this hypothesisreally is, and when that collapses, so do all the interesting findings in the paper.

(minor)

  • Since the term “task-vector” is used a lot in the recent literature with different meanings (for instance, in the model editing, model merging and task arithmetic literatures it indicacates the different between the fine-tuned and the pre-trained weights of a model), few words of disambiguation would enhance the readablity of the paper for many readers.
Questions
  • since the paper relies on important things like the first-order Markov property or the clean- sufficient-statistic assumptions and builds simple settings to empirically show the findings, how much of these nice findings actually applies to more complex, real world scenarios, where the important assumptions are relaxed? More concretely, if you take one of your E1-E3 and extend the conditioning from a single token to a local window of size w like you suggested in the Limitations, do P0-P3, the phase transition, and the near-orthogonality degrade gracefully or collapse as w grows? The thing this reviewer is interested in is whether the Markov property is something such that everything dies the moment is violated like in the Dyck test, or if it’s smoothed.
  • Theorem 2 states that, when d0 is much larger than k*, the new tasks must leave the established simplex. However, to the best of the reviewer’s knowledge, this does not mean that they must do so by forming near-orthogonal sub-spaces with respect to the simplex, while it is indeed the case when we look at the experiments. Why? Do the authors have an explanation, mathematical or not (although mathematical would be better) as to why this happens?
  • While the M1 to M2 transition is nice, it is driven by the vanishing per-task weight (0.1/N_minor). Have the authors decoupled this from the raw “capacity” of the representation space? In other words, does this transition still happen at the same N_minor if d is much larger, meaning that we still have more task but plenty of data for them instead of having number of samples for each task inversely proportional to the number of tasks as it is done in the paper?

Addressing these points would positively move my score.

Limitations

Yes

Paper formatting concerns

No major concerns.

Final justification

The authors addressed my main concern and I therefore suggest acceptance.

Comments on the paper

1 comment
Meta-review

Given the unanimous positive leaning, I am tentatively in favor of accepting the paper. The core claim of the paper is that under certain assumptions about the generative process (called P0--P3), one can demonstrate the existence of "task vectors" that are a simplicial mixture of the individual tasks the model was trained on; however, if task diversity is high (and some other conditions, e.g., large context, are met), one will find a transition into a general Bayesian inference strategy whereby the model assumes a continuous prior over underlying generative process. While there has been a lot of rich work in the past on this topic, the authors identified a well-defined setup where this phenomenology can be theoretically grounded. The main weaknesses of the paper boil down to use of toy setups that favorably match authors' assumptions and a lack of validation in realistic scenarios. I liked the Dyck example and would argue that as long as that example is properly emphasized, the paper clarifies to the reader the validity of the claims made being conditioned on the assumptions---I would thus strongly the authors highlight this experiment earlier on in the paper. Meanwhile, for a more realistic scenario, I would recommend the authors check out [1], which can offer a simple yet rich experimental setup that will plausibly match their assumptions; if it does, it would be a good spot to validate the claims in a more practical scenario. Adding this experiment would help me weight this paper for a sure accept.

[1] https://arxiv.org/abs/2511.00617

From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.

Related papers

Loading the map…

Discussion (0)

Sign in to comment.