How Do LLMs Encode Goals Internally? New Research Reveals Sparse Attention Head Mechanism

Research identifies sparse attention heads that encode subtasks and proposes the NRGS hypothesis to explain goal persistence.
A new study systematically investigates the internal neural representations of goal-directed behavior in large language models. In a multi-subtask programming scenario, researchers located a sparse set of attention heads whose outputs encode the "next subtask." This encoding can be decoded into natural language action descriptions and can be causally intervened on to change the model's subsequent actions. The encoding is also plastic: transplanted into a new programming language, it triggers the same operational intent, indicating that it encodes abstract goals rather than concrete action templates. To address the mystery of how a non-recurrent Transformer maintains goal encoding, the researchers propose the NRGS hypothesis: the model "maintains" goals by frequently rereading task instructions and comparing progress in context, rather than relying on hidden-state propagation. This work turns goals into localizable and intervenable internal variables, offering new perspectives for mechanistic interpretability and long-horizon task design.
Large language models often exhibit goal-directed behavior when completing complex tasks—first planning subtasks, then executing them one by one. But is there a clear internal neural representation behind this behavior? A new study systematically investigates this question and proposes a counterintuitive explanatory framework.

Study Design: Probing Goal Encoding with Programming Tasks
The researchers constructed a programming scenario containing multiple subtasks to evaluate the model's goal-seeking behavior and subtask selection process. In this setup, the model must assess its current progress, decide what to do next, and actually perform the operation. This multi-step structure makes "goal" an observable and intervenable variable.
By analyzing the model's internal activations, the research team successfully located a sparse set of attention heads whose outputs encode information about the "next subtask." In other words, the model does not represent goals diffusely across the entire network, but concentrates them in a small number of specific components.
Attention Heads are basic computational units in the Transformer architecture. In multi-head attention, each position in the input sequence generates multiple sets of attention weights through multiple independent query, key, and value projections, with each set corresponding to an "attention head." Each head can learn to focus on specific relational patterns between positions in the sequence, such as syntactic dependencies, coreference relations, or task-relevant features. Because different heads differentiate functionally, researchers often probe their causal roles by ablating or intervening on individual heads. The "sparse attention heads" identified in this study mean that goal information is not uniformly distributed across the entire network but is concentrated in a few heads, providing an operational handle for mechanistic interpretability.
Goal Encoding Is Decodable and Causally Intervenable
The capability of this set of attention heads goes beyond "carrying information." The researchers found that the same attention heads can be used to decode the model's future natural language action descriptions, such as "I am checking whether a word is a palindrome." This means there is a direct mapping between the goal representation and subsequent behavior.
More critically, causal validation: intervening on this encoding changes the model's next action choice. This rules out the possibility that "goal encoding is merely a byproduct of behavior" and indicates that it occupies a driving position in the causal chain.
Causal Intervention in mechanistic interpretability research refers to actively modifying a model's internal activations or inputs and observing behavioral changes to determine whether a representation lies in the causal chain. Common methods include activation patching, ablation, and targeted perturbation. Unlike merely training linear probes for "decoding," causal intervention can rule out confounding by correlation: if modifying the output of a certain set of attention heads systematically changes the model's subsequent actions, then that representation is more likely a causal variable driving behavior. This study uses exactly this logic to elevate goal encoding from "readable information" to "controllable variable."
Encoding Is Plastic and Transferable Across Environments
The study also reveals the "plasticity" of goal encoding. When researchers transplanted the encoding into different environments—for example, switching to another programming language—the model triggered the same operational intent, only implementing it with different token sequences. This shows that what is encoded is an abstract goal rather than a concrete action template, and that it has cross-context generalization ability.
This finding has direct implications for understanding LLM transferability: part of the reason models can reuse skills in new environments is that goal-level representations are environment-independent.
The Mystery of Persistence and the NRGS Explanation
A puzzling phenomenon is that the model can maintain goal encoding throughout the entire action execution process. But a standard Transformer has no recurrent structure, so in theory it cannot continue passing state forward after exhausting the remaining layers.
The researchers propose the "Non-Recurrent Goal-Seeking" (NRGS) hypothesis: the model does not actually need to maintain a persistent internal state. It frequently rereads the goal from the task instructions, compares it with the visible progress in the growing context, and then pursues the unfinished part. Goal "persistence" is the result of rereading and comparison, not state propagation.
The team tested predictions of this hypothesis through targeted causal intervention experiments, providing supporting evidence for the NRGS framework.
The non-recurrent nature of standard Transformers refers to the fact that their forward computation is a finite-depth network stacked layer by layer, without recurrent connections like those in RNNs or hidden state propagation across time steps. In a single forward pass, information can only flow upward through the layers and is no longer retained once it passes through the final layer. Therefore, if a model is to "remember" a goal in a multi-step task, in theory it must rely either on text in the context window (such as task instructions and completed steps) or on some external memory mechanism. The NRGS hypothesis is proposed precisely on the basis of this architectural constraint: the model does not need to maintain a persistent internal state but repeatedly rereads the goal from context and compares progress, thereby exhibiting goal persistence at the behavioral level.
Implications for Interpretability and Model Design
The value of this work lies in transforming "goal" from an abstract behavioral description into a localizable and intervenable internal variable. Sparse attention heads, as the carriers of goal encoding, provide a clear entry point for mechanistic interpretability research.
If the NRGS explanation holds, then the model's stability in long tasks depends more on context management and goal rereading mechanisms than on hidden-state memory. This has practical reference value for prompt design and context organization in long-horizon tasks.
The study also leaves open questions: Do goal encodings share the same set of attention heads across different task types? How does rereading frequency affect execution efficiency? These await future work.
Related articles

Gemini 4 Neon Leak: A Potential Strong Contender Against Opus 5.5
A Hacker News thread suggests Gemini 4 Neon looks like an Opus 5.5 competitor. This article unpacks the product positioning behind this community signal, shifts in the top-model competitive landscape, and what it means for developers' model selection strategy.

Claude Fable 5.2's Self-Authored Short Film 'Fable' Sparks Discussion
A short film 'Fable,' credited to Claude Fable 5.2 for script, visuals, and directing, appears on Hacker News. This article analyzes the significance of full-pipeline AI creation, community reactions, and what it means for content creators.

Anthropic IPO Pricing: A Signal of AI Giants Going Public
Anthropic's IPO pricing draws attention. This article analyzes its potential impact on AI industry valuation, commercialization paths, and the competitive landscape, and highlights public-market expectations and challenges for AI companies.