Paper commentary
Goal Encoding in LLMs
LLMs hold a sub-goal internally in a sparse set of attention heads
- Problem Goal-like outputs don't show whether an LLM stores its goal inside its computation. Visible behavior can't separate a real internal goal from mimicry of human language.
- Method The authors localize goal heads, a sparse set of attention heads whose outputs encode the next sub-goal before it begins. Output transplants swap each head's contribution to the residual stream to test whether the sub-goal moves.
- Results Swapping the task-span encoding redirected the model to the donor's next sub-goal in 89% of cases, compared with 6% for the code-progress span.

Figure 1 :Goal pursuit and its non-recurrent implementation in a transformer LM.A goal such as implementing merge sort (G) decomposes into sub-goals g1, g2, g3, each realized as a sequence of tokens (left). (i) An idealized agent commits to a sub-goal gk, keeps it active while pursuing it, and moves on once it is done. (ii) A transformer LM cannot persist a state across long sequence of tokens without running out of layers.(a)The intent to pursue gk =“divide into two halves”is nonethelesspre-committed: it is already readable at the indent token, multiple tokens before its implementation.(b)Because this commitment cannot be carried forward, the LM compensates with frequent re-computation: the LM frequently re-encodes the current sub-goal gk by reading the task span, and the progress-so-far eprog from the growing context tape, and compares the two to produce the next token (thesub-sub-goal). Different levels of goal hierarchy are maintained in the same way. (c)Once the sub-goalg k is complete, the LM moves on to the next sub-goalg k+1.
Original paper · CC BY 4.0 · Arnab Sen Sharma, Eric Todd, Sheridan Feucht, Andy Arditi, Rohit Gandikota, Natalie Shapira, Gabriele Sarti, Constanza Fierro, Lisa Schut, David Bau · Goal Encoding in LLMs · Original paper figure · Extracted the figure area from page 2 of the original PDF.Why behavior alone can't settle the goal question
A model that writes merge sort one step at a time looks goal-directed from the outside. Its visible outputs don't show whether anything inside the model stands for the goal. Philosophers often attribute goals to systems, such as a thermostat, without saying how those goals are realized internally. Critics argue that because LLMs are trained to mimic human language, their behavior isn't evidence of true intentions.
The authors therefore ask whether an LLM has an explicit representation of its goal inside its computation.
The authors build on Bratman's planning theory and define a goal as a functional state with three attributes. Pre-commitment means an intermediate state that a resource-bounded agent commits to before acting. These three attributes turn the vague question about goals into tests that can run on a model's internals.
The authors study a merge sort task because it splits into sub-tasks: split the array, sort each half, and merge the sorted halves. Each of these steps gives a coding agent an opportunity to form and keep a sub-goal, such as merging the two halves. A sub-goal passes the test for pre-commitment if it appears before the action begins. It passes the test for plasticity if it still works across variations such as different programming languages.
It passes the test for persistence if a consistent encoding keeps guiding the model while it implements the sub-goal.
Finding goal heads in a controlled coding task
The authors look for a sub-goal encoding that sits in the internals of the model rather than in its next-token output. They study controlled settings where a prompt asks the model to implement an ordered list of sub-goals in Python or C++. Each prompt lists two to four sub-tasks, covering boolean checks, counts, filtering, and other transformations.
The model implements each sub-goal over a contiguous span of generated tokens, and the pivot marks where the next span is about to begin. Four pivots are inspected: the end of the preceding line, indentation, the variable name, and the assignment operator. The main evaluation covers 253 specifications, which gives 1012 observations per evaluation configuration.
Each attention head writes a weighted mix of value states, projected by its output weights, into the residual stream. Activation patching runs a destination prompt while overwriting a head's output with a value cached from a source prompt. An output transplant swaps a head's contribution to the residual stream, and this is how the authors localize the goal heads.
A head whose transplant moves the next sub-goal is taken as carrying a portable encoding. The selected set contains 122 goal heads.
To build the probe, the authors take each goal head's output-value projection and normalize the resulting direction. They then average these unit directions across the goal heads, and the average becomes the steering vector. This averaged direction is used in the GOALSCOPE probing setup with the additive_norm strategy. The readout is scored on two axes: faithfulness, whether the description matches the upcoming operation, and causality, whether the model then behaves that way after intervention.
Reading the next sub-goal before it is written
The first test asks whether the upcoming operation is visible before any token of its implementation. The authors find it readable at the indent token, several tokens before the sub-goal's implementation starts. So the commitment is already present while the model is still deciding how to begin.
The plasticity test moves the encoding into another environment, such as a different programming language. Swapping only the task-span latents redirected the model to the donor's next sub-goal in 89% of cases. Swapping both spans reached 98%, so adding the code-progress span raises the shift only modestly. The code-progress span alone achieved only about 6%, even though the next sub-goal is readable at earlier pivot positions.
The authors read the weak code-progress result as a sign that the progress span holds only a trace of the upcoming operation. The task span, by contrast, is what the model re-reads to decide the pending operation. Because the code-progress signal can be suppressed by that re-reading path, pre-commitment here shows presence without dominance.
The kv-transfer runs add a second check on the same question, using the 250 goal heads. Task-span kv-transfer triggers the source's next sub-goal about 77% of the time without amplification. Amplifying the value states by 4 raises the code-progress transfer to 0.26 for the 250 goal heads. They didn't test a code-progress transfer that matches the task-span result at amplification 1.
Whether the sub-goal encoding survives the implementation
The persistence test takes the goal-head vector at the eq pivot and compares it with the vector at every token of the implementation span. The model is Qwen2.5-Coder-32B-Instruct, and implementation spans shorter than 10 tokens or longer than 40 tokens are filtered out. The analysis covers 573 matched cases across 4 datatypes and 2 programming languages.
The LM generates up to 256 tokens, and a rule-based identifier finds the Python implementation span while an oracle-based identifier handles C++.
The goal-head vector is the sum of the goal heads' outputs at each token, the same steering direction used in the additive_norm strategy. The same-sub-goal curve starts at 1.0, because the pivot vector is compared with itself. That curve then gradually decays across the implementation, and it stays above the curves for a different sub-goal throughout.
The gap narrows toward the end of the implementation, so the same-sub-goal curve ends about as far from the pivot as the others. The authors read this narrowing as the LM retiring the sub-goal encoding, and then moving on to the next sub-goal.

Figure 29 :Temporal persistence of the sub-goal encoding throughout the implementation span. We filter out the implementation spans that are too short (< 10 tokens) and too long (> 40 tokens), across 4 datatypes and 2 programming languages. Left figure is same as Figure 3, copied here for comparison with the encoding captured by a set of control heads randomly sampled from the later half of the LM (right). The teal curves show that the encoding captured by goal heads have higher affinity with the goal encoding captured at the pivot. The affinity of encoding captured by the control heads with the pivot encoding (captured by the same control heads) immediately drops sharply.
Original paper · CC BY 4.0The comparison also covers four relations: same sub-goal, same sub-goal in a different context, a different sub-goal in the same context, and a different sub-goal in a different context. Early in the implementation, the pivot encoding stays similar to the same sub-goal encoding captured from a different context. The authors take this as evidence that the sub-goal encoding is largely context-invariant across prefill order and programming language.
Table 13 shows GOALSCOPE read-outs along the implementation, and the cosine similarity drops toward the end in both examples.
The goal heads keep a higher affinity with the pivot encoding than the control heads do. So the retention looks specific to the goal heads rather than a generic property of late attention heads.
Sufficiency and necessity of the goal heads
The sufficiency test blinds every other head in layers 20 to 63 to the task span, so only the chosen heads can read it. Of the 1760 heads in those layers, 122 are goal heads. With only those 122 heads spared, the implementation score is 0.806, compared to 0.925 in the clean run. Sparing 122 random control heads instead drops the score to 0.103.
Sparing the 250 goal heads brings the score to 0.913, close to the clean run. Sparing 250 random control heads leaves the score at 0.087. In the single failure case, total_vowels, sparing 250 goal heads restores a correct implementation. The 122-head set fails on that case, with the spared-goal output computing a count of capitalized words instead.
The necessity ablation reverses the setup: the goal heads are restricted to the first token at every generation step from the eq pivot. Blinding 122 goal heads leaves the score at 0.854, compared to 0.925 in the clean run. Blinding 250 goal heads drops it sharply to 0.158, while blinding matched random heads leaves it at 0.925. The authors suggest that 122 heads can reroute through other goal heads to later layers.
They didn't test each redundant pathway separately, so that explanation remains a suggestion.
Why the model re-reads the goal instead of carrying it
A transformer without recurrence passes information forward only through an attention read, and each read uses up a layer. So a goal encoded in the upper layers at one token has too few layers left to affect a computation many tokens later. That makes a persisting goal state look impossible, yet the earlier tests show the encoding does persist.
The non-recurrent goal-seeking account offers a way out: the model re-derives the goal from the task specification at each step. Figure 1 sketches this loop, in which the model re-encodes the sub-goal and the progress at every pass. The authors say the goal is re-derived at each step rather than carried in the latents of the generated tokens.
The key/value test asks whether the goal is re-read from the task span, by swapping the key-value states of that span in 250 goal heads. Swapping them redirected the model in about 77% of cases, rising to 93% when the values are scaled by 2 and to 97% at scale 4. Transplanting only the task-span latents redirects the model to the donor's next sub-goal in 89% of cases, and transplanting both spans reaches 98%.
The authors read this as frequent re-reading of the goal from the task span, which fits the account.
The eq readout approaches the GOALSCOPE ceiling by layer 40, while most goal heads sit in layers 40 to 50. Because attention reads from earlier tokens would cost at least one layer, the authors infer the goal is re-fetched at eq. Pre-commitment-like readouts at earlier pivots are, in their view, eager preprocessing that the code-writing step suppresses.
Beyond the controlled code setting
The authors compare goal heads with function vector heads on in-context learning tasks from prior work. The function vector heads can't verbalize the implicit rule with GoalScope, since their readouts name it in only 2.3% of abstractive cases. On extractive tasks, the function vector heads name the rule in 1.5% of readouts across all 39 tasks.
Goal heads trigger the task for antonym and country-capital, but they often fall below the function vector heads.
For compositional ICL, the model generates 8 new tokens after a 10-shot prompt that demonstrates the composition. The probe asks the model to describe the two relations, f and g, that it is performing. It rarely names both rules, so a readout usually captures only one part of a composed rule.
In the clean chat, the model answers the chocolate cake question with a normal recipe. GOALSCOPE identifies the steering vector and verbalizes a refusal-adjacent response as early as the chocolate token.
Limits of the evidence
The study leaves obstacle persistence open, because the LMs at the scale studied don't robustly keep a sub-goal when a misleading prefix is forced onto it. The persistence test here measures only temporal retention, which means the sub-goal encoding stays across the tokens that implement it. The authors analyze obstacle persistence separately in Appendix K.2, so the main text doesn't settle that part of the claim.
Each prompt lists two to four sub-tasks, and the corpus supplies 1012 observations per evaluation configuration. Because the whole analysis runs on this one setup, the results may not carry over beyond it without further tests. The readouts also depend on an LM judge, and the authors manually spot-checked its outcomes to make sure they are reasonable.
Hand checks on a sample don't fully remove the judge's influence on the reported scores.
Projection-based readouts such as OVReader can't show when the encoding first forms in the network. The authors caution that a readout from layer 40 doesn't mean the sub-goal gets encoded only after that layer. Most goal heads sit in layers 40 to 50, so the projection approach may perform poorly outside that band. The authors present such lenses as useful for hypothesis generation and debugging, so they serve better for hypotheses than for proof.
Paper info
- Authors
- Arnab Sen Sharma, Eric Todd, Sheridan Feucht, Andy Arditi, Rohit Gandikota, Natalie Shapira, Gabriele Sarti, Constanza Fierro, Lisa Schut, David Bau
- Venue
- arXiv · Preprint
- First published
- 2026-11-12
- Added
- 2026-11-14
- Updated
- 2026-11-12
- Version
- v1
- arXiv
- 2611.17297
- Category
- cs.CL · cs.AI · cs.LG
- Original paper terms
- CC BY 4.0
- What we show
- Paper info, commentary and permitted figures from the original paper
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Abstract
We investigate whether and how LLMs encode goals: internal neural representations that precede and guide action, and that are flexible enough to be realized through many different execution paths. We construct a coding setting with multiple sub-tasks that allows us to evaluate goal-seeking behavior and the selection of sub-goals. In this setting, we localize an encoding of the next sub-goal in the outputs of a sparse set of attention heads. The same heads can be used to decode the LM's future actions in natural language (e.g., "I'm checking if a word is a palindrome"). We verify that this encoding is causal for next action and is plastic: transplanting it into a different environment, e.g., another programming language, triggers the same operation realized with a different sequence of tokens. The LM also sustains the encoding throughout the action's execution, which is puzzling because a transformer LM without recurrence cannot carry a state forward for more tokens than it has layers left. We propose that it does not need to. Under a non-recurrent goal-seeking (NRGS) account, the LM frequently re-reads the goal from the task specification, compares it with the progress visible in the growing context, and pursues what remains. We test the predictions of this account with targeted causal interventions.
Quote from the paper
Arnab Sen Sharma, Eric Todd, Sheridan Feucht, Andy Arditi, Rohit Gandikota, Natalie Shapira, Gabriele Sarti, Constanza Fierro, Lisa Schut, David Bau (2026). Goal Encoding in LLMs. arXiv:2611.17297v1. https://arxiv.org/abs/2611.17297v1
BibTeX
@misc{sharma2026goal,
title = {{Goal Encoding in LLMs}},
author = {Arnab Sen Sharma and Eric Todd and Sheridan Feucht and Andy Arditi and Rohit Gandikota and Natalie Shapira and Gabriele Sarti and Constanza Fierro and Lisa Schut and David Bau},
year = {2026},
eprint = {2611.17297},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2611.17297v1}
}