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 the LM’s computations, we look for these criteria in a controlled setup with multi-step coding tasks:
the prompt lists several sub-tasks, and we prefill the code up to the point where a good model should start the next one (the frontier).
In this setup, we find an encoding that meets all three criteria in the outputs of a sparse set of attention heads.
When we transplant the collective encoding of these heads into a neutral probe, the LM can verbalize the upcoming action in natural language and implement it 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.
The only way a transformer LM can pool information from a previous token is through the attention mechanism, which costs a layer.
If the LM were to carry a running encoding of the goal from one token to the next, it would have only a limited number of layers to do so.
As an example, an encoding formed at layer 40 of a 64-layer model has only 24 layers left to pass it on, yet we see goals sustained
well beyond that limit.
We find that instead of carrying a goal-encoding forward, 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 on the ICL and chat (EM) pages of the demo.
By our criteria, the encoding is pre-committed (decodable before the action) and plastic (portable to another environment). It is also persistent, but through frequent re-derivation rather than a single running state. Whether that counts as a "goal" 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 during the action, then this encoding qualifies. We leave the semantics of whether this is a “goal” or not to the reader.
The paper is under review; a preprint and the final citation will be posted here.
@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},
note = {Preprint},
url = {https://goals.baulab.info/}
}