Language models now carry out tasks that unfold over thousands of tokens, and they behave
as if they were pursuing a goal. We ask whether that behavior is backed by an explicit goal
encoding inside the model’s computations.
We fix three criteria that functionally define a goal:
(i) pre-commitment, (ii) plasticity, and (iii) persistence. We find an encoding that meets these criteria
in the outputs of a sparse set of attention heads. We further ask how a depth-bounded transformer manages to keep such
a goal alive across a long generation without running out of layers.
Inspired by Bratman’s planning theory, we treat a goal as a functional state with the three properties below.
The target state is settled before the action that realizes it begins.
The same goal can be realized by different means, as the environment demands.
It is sustained while the action is carried out, and released once it is done.
In a controlled coding setup, we find an encoding that meets all three criteria in the outputs of a sparse set of attention heads.
This encoding can be transplanted into a different context to verbalize the upcoming action in natural language and trigger its implementation in a different programming language.
See the figure below, and browse the demo readouts →
indent token, three tokens before the LM writes the corresponding code, GoalScope can read out the next action in natural language with 94% accuracy.= token and the encoding sampled x% of the way
through its implementation, averaged over data types and languages. Encodings of the
same sub-goal stay well above those of a
different sub-goal all the way through, whether the
implementation is in the same programming language (solid) or a different one (dashed). The encoding is sustained throughout the implementation, and fades away at the end, when the LM is ready to move on to the next one.
Transformer LMs have a limited number of layers, and the only way they can pool information from a previous token is through the attention mechanism, which costs a layer. How, then, does a transformer LM keep a goal alive in its computation for many tokens?
We find that instead of carrying a goal encoding forward across the generated tokens, the LM frequently re-reads the goal from the task specification. Then the LM decides the next action by comparing the re-fetched goal with the progress made so far.
We call this the non-recurrent goal-seeking account (NRGS) of how the transformer LM achieves persistence.
" =" pivot the goal heads read the source’s
task span (red) instead of the destination’s (green). The model implements the source
next action, in the destination’s language. The GoalScope readout also flips with it.
and
between them, the same swap triggers the LM to implement the source’s next sub-sub-goal “ends with a digit” in the destination’s programming language (C++).
" =" pivot. Right: how often
the model then implements the source’s next sub-task.
" =" pivot we swap in only the goal heads’ query from the
source run, the side that should carry “what is already done”. The patched model skips
ahead to the destination’s third task. Right: the swap works much better when the source
frontier sits at the same position in its task list as the patched target (order-matched) than
when it does not (order-diff), so progress is not the only cue: position matters too.
The goal heads were found on code, but GoalScope reads intentions elsewhere too, with no re-training.
Explore more examples in the demo: ICL → Chat (EM) →
By our criteria, the encoding is pre-committed (decodable before the action) and plastic
(portable to another environment). It is also persistent (sustained throughout the action). However, transformer LMs achieve persistence through frequent re-derivation rather than carrying a single running state.
Does this count as a "goal"? The answer depends on whether there is a requirement on the mechanical implementation of persistence: if a goal must be a single state that survives the whole action, then this encoding does not qualify. But if we don’t care about the implementation, and only care whether the goal is present when it causes action, then this encoding qualifies. We leave the semantics of whether this is a “goal” or not to the reader.
The paper is available on arXiv.
@misc{sensharma2026goals,
title = {Goal Encoding in {LLMs}},
author = {Sen Sharma, Arnab and Todd, Eric and Feucht, Sheridan and Arditi, Andy and
Gandikota, Rohit and Shapira, Natalie and Sarti, Gabriele and Fierro, Constanza and
Schut, Lisa and Bau, David},
year = {2026},
eprint = {2611.17297},
archivePrefix = {arXiv},
primaryClass = {cs.CL},
url = {https://arxiv.org/abs/2611.17297}
}