Skip to content

Goal encoding in LLMsGoal Encoding in LLMs

arXiv· arXiv:2611.17297· Arnab Sen Sharma, Eric Todd, Sheridan Feucht, Andy Arditi, Rohit Gandikota, Natalie Shapira, Gabriele Sarti, Constanza Fierro, Lisa Schut, David BauNortheastern University; Parallax; University of Copenhagen; University of OxfordIndexed by this site · 10 days ago· Originally publishedSelected AlignmentSelectedAttention39

Quick read

Interpretability

Based on the paper PDF (AI-generated); refer to the original

In multi-step code generation, the authors localize sparse attention heads that encode the next subgoal, claim these can be read out in advance and ported across languages, and that a non-recursive rereading mechanism maintains the goal.

Questions
LLMs exhibit goal-directed behavior, but it is unclear whether an antecedent, plastic, and persistent goal representation exists internally; the authors want to test whether this behavior corresponds to a localizable, intervenable internal computation.
Methods
In multi-subtask code generation, the authors learn a sparse mask to localize goal heads, then use GoalScope to read out the next subgoal, and test its causal role and the NRGS mechanism through output/query/KV transplant and ablation.
Experiments and results
The authors report that goal heads can read out the next operation multiple tokens before implementation, and transplanting to C++ can trigger the same operation; KV transfer has a causal-shift of 0.97 on py→py, and after blinding 250 goal heads the success rate drops to 0.158.
Limitations and future work
The authors state that the complete implementation of NRGS has not yet been mapped, the query results provide only partial evidence, and it cannot answer how the first among multiple pending operations is selected; the experiments also show that the model's adaptation rate under hard obstacles is only about 0.15.
Experimental setupQwen2.5-Coder-32B-Instruct、Qwen2.5-32B-Instruct (emergent misalignment model organism) · 253 个多子任务代码规格语料(int、str、list[int]、list[str],Python 与 C++)、single-relation ICL tasks (Todd et al., 2024) et al. · faithfulness、causality et al.
Evaluated models
Qwen2.5-Coder-32B-InstructQwen2.5-32B-Instruct (emergent misalignment model organism)
Benchmarks
253 个多子任务代码规格语料(int、str、list[int]、list[str],Python 与 C++)single-relation ICL tasks (Todd et al., 2024)compositional ICL tasks (Khandelwal & Pavlick, 2026)superposition ICL tasks (Xiong et al., 2025)emergent misalignment first plot questions (Turner et al., 2025)
Metrics
faithfulnesscausalitycausal-shiftreadout-shiftADAPTED-rateverbalization accuracy
AI summaryand selection rationaleResearchers from Northeastern University and other institutions examined in an arXiv paper whether LLMs explicitly encode goals internally. In multi-step coding tasks, they localized sparse attention heads that carry the next subgoal, selecting 122 goal heads on Qwen-2.5-Coder-32B-Instruct, and built the GoalScope probe to read out the next operation in natural language. This encoding can be read out before implementation begins, with readout scores at the indentation position reaching above 0.90, and when transplanted from that position to a C++ context, 96% triggered the same operation. The paper proposes a non-recursive goal seeking (NRGS) explanation: the model frequently rereads the goal from the task description and selects the next step by comparing against progress; rewriting the content read from the goal heads can steer the model to another subgoal with about 94% success. The same set of heads can also read out implicit rules from few-shot prompts, and at early token positions read out intentions consistent with the model's subsequent response tendencies in emergent misalignment.

Researchers from Northeastern University and other institutions examined in an arXiv paper whether LLMs explicitly encode goals internally. In multi-step coding tasks, they localized sparse attention heads that carry the next subgoal, selecting 122 goal heads on Qwen-2.5-Coder-32B-Instruct, and built the GoalScope probe to read out the next operation in natural language. This encoding can be read out before implementation begins, with readout scores at the indentation position reaching above 0.90, and when transplanted from that position to a C++ context, 96% triggered the same operation. The paper proposes a non-recursive goal seeking (NRGS) explanation: the model frequently rereads the goal from the task description and selects the next step by comparing against progress; rewriting the content read from the goal heads can steer the model to another subgoal with about 94% success. The same set of heads can also read out implicit rules from few-shot prompts, and at early token positions read out intentions consistent with the model's subsequent response tendencies in emergent misalignment.

Why it was selectedThe paper localized and causally verified the internal encoding of subgoals in LLMs during multi-step coding tasks, providing a mechanistic-level method for reading out model intentions before action.

Paper analysis

6 questions; open one to read the full answer

  1. What problem does this paper attempt to solve?

    The authors study whether LLMs contain internal goal representations that are antecedent, plastic, persistent and causally intervenable.

    Core question: whether LLM goal-directed behavior corresponds to an explicit internal goal representation, and how such a representation is maintained in a transformer without recurrence.

    • Research setting: the authors construct a multi-subtask code generation setting, where the prompt lists 2–4 subtasks and the model implements them in order in Python or C++; each subtask is treated as a testable subgoal.
    • Why it matters: the authors argue that if goal-directed behavior can be mapped to internal states, one can directly test whether LLMs have goal-like computation, rather than inferring only from output behavior.
    • Gaps in existing discussion: the authors cite debates on intention and goals by Dennett, Fodor, Bratman, etc., and point out that behavior-level attribution does not explain the internal mechanism; the paper seeks internal states satisfying pre-commitment, plasticity, and persistence.
    • Core observation: the authors localize a next-subgoal encoding in the outputs of sparse attention heads, stating that it can be read out before implementation, trigger the same operation across programming languages, and be maintained during execution.
    • What the paper proposes: the authors propose the GoalScope readout probe and the non-recurrent goal-seeking (NRGS) explanation: the model repeatedly re-reads the goal from the task description, encodes progress from context, and compares the two to select the next step.
    • Analysis subjects: most results in the main text are based on Qwen2.5-Coder-32B-Instruct; the appendix also compares models of multiple sizes and families, and extends readout to ICL and emergent misalignment chat settings.
  2. What related research exists?

    Related work covers goal philosophy, LM planning representations, portable task vectors, internal readout, and causal intervention.

    Functional explanations of goals and intentions

    • Dennett (1987), Fodor (1987), Block (1981)—respectively represent explaining goals from behavioral prediction, treating beliefs and desires as real internal representations, and reminding that the same behavior may have different internal implementations; the authors use these to show that looking only at outputs is insufficient to determine goals.
    • Bratman (1987), Bratman et al. (1988), Lee & McShea (2020)—provide the three criteria adopted in this paper: pre-commitment, plasticity, persistence.
    • Cohen & Levesque (1990), Goschke & Kuhl (1993), Altmann & Trafton (2002)—discuss goal maintenance, release after completion, and goal memory; the authors use these works to compare the decay and release of goal encoding in LMs.

    Internal anticipatory and planning representations in LMs

    • Lindsey et al. (2025)—found that LMs encode a rhyme plan before writing the next line of poetry, and intervention can change the candidate rhyming words.
    • Maar et al. (2026), Pal et al. (2023), Wu et al. (2024), Hanna & Ameisen (2026), Dong et al. (2025)—study future tokens, implicit planning, or anticipatory signals that strengthen with scale; the paper treats these works as precedents for "internal states containing information about future behavior."

    Portable task and operation representations

    • Hendel et al. (2023), Todd et al. (2024), Davidson et al. (2025), Li et al. (2025)—study task representations in task vectors, function vectors, or a few key tokens.
    • Sen Sharma et al. (2026)—found abstract predicate encoding in a list-filtering task; the authors state they were inspired by these portable encodings to look for subgoal encodings in code generation.

    Reading out internal representations and causal intervention

    • logit lens, tuned lens, PatchScope, SelfIE—respectively use the decoding head, affine transformations, or transplanted hidden states to read out internal information; GoalScope is built directly on PatchScope.
    • Karvonen et al. (2025), Li et al. (2026), Pan et al. (2026)—train interpretation models to convert latents into natural language; this paper does not train an interpreter, but instead injects goal-head encodings to let the same LM verbalize.
    • Vig et al. (2020), Mueller et al. (2026)—provide activation patching and causal mediation analysis frameworks; this paper uses output, query, and key/value transplant for goal mechanism intervention.

    Baselines and controls

    • Readout baselines: full attention module output and residual states (Figure 2, Figure 12).
    • Ablation controls: randomly sampled equal numbers of later-half heads (Table 4, Table 6).
    • ICL controls: the 150 function vector heads of Todd et al. (2024) (Table 16).

    The authors position the distinction of this paper as: not merely looking for task vectors or future-token signals, but testing whether a sparse set of heads simultaneously satisfies the three functional criteria of a goal, and explaining its cross-token maintenance mechanism.

  3. How does the paper address this problem?

    The authors first localize goal heads, then read them out with GoalScope and test the causal mechanism and NRGS with transplantation and ablation.

    The overall approach is: in controlled multi-subtask code generation, locate the goal heads that carry the encoding of the next subgoal, then use GoalScope to verbalize or transplant that encoding into a new context, and finally test NRGS with causal interventions.

    Controlled task and pivot setup

    • Task form: the prompt gives an ordered set of subgoals G = {g1, ..., gn}, which the model implements in sequence; the main evaluation contains 253 specifications, covering int, str, list[int], list[str], with 2–4 subtasks per specification.
    • Pivot position: the authors check four tokens—prev_end, indent, var, eq—before implementing gk; each evaluation configuration has 1012 observations.
    • Prefill design: the source context is prefilled up to the pivot so that the next subgoal is known, making it easier to compare the readout with the model's subsequent actual implementation.

    Locating goal heads

    • Contrast prompt pairs: the source prompt and target prompt require different predicates and use different programming languages; the authors claim this rewards transfer of abstract operation encodings rather than copying implementation tokens.
    • Sparse mask: learn a joint mask over all attention heads; in the patched run, mix source head outputs with target head outputs according to the mask; the objective is to minimize the KL divergence from the target run's next-token distribution plus a sparsity penalty.
    • Main configuration: in Qwen2.5-Coder-32B-Instruct, 122 goal heads are selected, distributed across layers 28–55 of 64 layers; threshold τ = 0.9.

    GoalScope readout

    • Encoding aggregation: cache the OV outputs of the selected heads at the source pivot and sum them into a vector vg.
    • Verbalizer run: inject vg into a separate run of the same model; the text input does not contain the source context, so the authors believe source information can only come from the injected activations.
    • Main intervention parameters: additive_norm, injected at layers 35–45, scaled to 0.1 times the local residual norm, re-injected at each generated token with greedy decoding.
    • Two metrics: faithfulness measures whether the readout describes the gk about to be implemented; causality measures whether injecting the same encoding into a C++ stub triggers the same operation.

    Causal bottlenecks and NRGS test

    • output transplant: replace the contribution the heads write to the residual stream, used for localization and readout.
    • query transplant: replace the goal-head query at the pivot to test whether the progress encoding changes the next subgoal selection.
    • key/value transplant: from the pivot onward, have the goal heads read the KV states of the source task span, to test whether the model repeatedly rereads the goal from the task description.
    • NRGS meaning: the authors propose that the model does not carry a single goal state forward, but repeatedly computes the task goal and progress and selects the remaining operation; one illustrative implementation is ATTN(q−1 ≈ −Eprog, {K,V}task−span ≈ G), i.e., using the query to suppress completed subgoals and expose pending subgoals.

    Judgment method

    • LLM oracle: claude-sonnet-4-6 judges whether the readout or generation covers a nontrivial part of the target subgoal; YES counts as success, everything else as failure.
    • Human verification: on 130 faithfulness readouts, agreement between humans and claude-sonnet-4-6 is 96.2% (125/130), Cohen’s κ = 0.69 (Table 2).
  4. What experiments did the paper conduct?

    The experiments cover readout, cross-model, ablation, NRGS intervention, ICL generalization, and qualitative readout of misaligned models.

    Experimental setup

    • Models tested: the main text uses Qwen2.5-Coder-32B-Instruct; the appendix additionally tests Qwen2.5-Coder-14B-Instruct, Qwen2.5-32B-Instruct, Olmo-3.1-32B-Instruct, Olmo-3.1-32B-Instruct-SFT, Qwen3-32B, Devstral-Small-2-24B-Instruct, GLM-4.5-Air, Qwen2.5-72B-Instruct, GLM-4-32B-0414, and the emergent misalignment model organism of Qwen2.5-32B-Instruct.
    • Dataset: 253 code specifications, each containing 2–4 subtasks; n = 1,012 per model and mode; n = 32 per cell for NRGS interventions.
    • Baselines/controls: full attention output, residual states, random later-half heads, function vector heads.
    • Metrics: faithfulness, causality, causal-shift, readout-shift, implementation success rate, ADAPTED-rate, verbalization accuracy.
    • Review method: judged by claude-sonnet-4-6; the appendix uses gpt-5 and 12 human annotators to validate 130 faithfulness readouts.
    • Decoding: readout and intervention rollouts are mostly greedy decoding, up to 256 tokens.

    Main results

    According to Figure 2, GoalScope readout for Qwen2.5-Coder-32B-Instruct:

    Conditionfaithfulnesscausality
    prev_end0.590.67
    indent0.910.94
    var0.890.96
    eq0.970.96
    mean0.850.87
    full attention (L40–50)0.330.61
    residual (L40–50)0.010.01
    • The authors state that the next subgoal can be read out multiple tokens before implementation, with scores above 0.90 at indent.
    • The authors state that transplanting the same encoding to C++ can trigger the same operation, demonstrating plasticity; the main text separately writes "from indent" as 96%, with mean success about 87%.
    • Appendix E.1 reports mean scores for the same setting of 85.3% faithfulness and 87.3% causality, higher than full attention's 32.6% and 60.9%.

    Causal bottleneck ablation

    • Sufficiency: keeping only goal heads' access to the task and code segments, and blinding other heads in layers 20–63; with 122 heads the implementation success rate is 0.806, with 250 heads 0.913, clean 0.925, and random-head controls 0.103/0.087 (Table 4).
    • Necessity: restricting goal heads' attention to the first token; with 122 heads the success rate is 0.854, with 250 heads it drops to 0.158, and the random-head control remains 0.925 (Table 6).
    • Authors' interpretation: the authors state that 122 heads are sufficient to maintain most of the performance, but when 122 heads are blinded the model can compensate via redundant paths, and only blinding 250 heads clearly disrupts implementation.

    NRGS interventions

    • Task-segment KV transfer: from the pivot onward, 250 goal heads read the source task-segment KV states; Figure 5 reports causal-shift of 0.97, 0.91, 0.90, 0.90 and readout-shift of 0.91, 0.90, 0.95, 0.93 for py→py, py→cpp, cpp→py, cpp→cpp respectively.
    • query transfer: under the order-diff setting, Figure 6 reports causal-shift of 0.66, 0.55, 0.51, 0.56 and readout-shift of 0.51, 0.38, 0.36, 0.40; the random-head control is about 3%.
    • order-matched: in Table 9, query transfer has higher causal-shift, e.g., 0.91 for int, py→py; the authors state that task order also participates in selecting the next operation.
    • Hierarchical generalization: causal-shift for sub-sub-goal KV transfer is about 79%; in the broader goal setting it is 0.77 (74/96, Table 8).
    • Authors' interpretation: the authors state that the results support the model frequently re-reading the goal from the task segment, but the query results are weaker, and the complete implementation of NRGS has not yet been mapped.

    Other ablations and analyses

    • Model scale: from Qwen2.5-Coder 14B to 32B, faithfulness rises from 78.9% to 90.7%, and causality from 62.5% to 91.7% (Table 3).
    • Code fine-tuning: the 32B coder's faithfulness/causality at prev_end is 73.5%/82.2%, versus 29.6%/49.0% for the non-coder (Figure 16).
    • RL tuning: Olmo-3.1-32B-Instruct compared with SFT, causality rises from 55.3% to 73.1%, and faithfulness is 69.1% versus 67.8% (Figure 17).
    • head budget: 25 heads already allow effective readout; beyond about 100 heads the gains are non-monotonic (Figure 13).
    • ICL generalization: across 39 single-relation tasks, mean verbalization accuracy is 36.2% ± 5.6%; abstractive is 49.9% ± 6.4%, extractive is 9.0% ± 5.7%.
    • FV heads control: FV heads achieve only 1.5% on ICL readout, versus 36.2% for goal heads; however, goal heads are often lower than FV heads on zero-shot trigger (Table 16).
    • Obstacle persistence: Qwen2.5-Coder-32B's ADAPTED-rate under aligned/easy/hard prefixes is about 0.97/0.63/0.15 (Figure 30).
  5. What are some points that can be further explored?

    The authors state that the NRGS implementation has not yet been fully mapped; the experiments mainly cover controlled code, several open-source models, and limited natural language settings.

    Limitations and future directions noted by the authors

    • NRGS mapping is incomplete: Section 5.1.2 and Appendix I.2.3 state that the interventions provide only a partial account, and the authors have not yet mapped the complete implementation of NRGS inside the LM.
    • Selection among multiple pending operations is unresolved: Appendix I.2.3 states that the contrastive setting guarantees only one target subgoal, and cannot answer how the LM selects the first among multiple pending operations.
    • Query mechanism is mixed: Appendix I.2.1 and I.2.3 state that, besides progress-so-far, signals such as position, completion count, and induction also play non-trivial roles, and no single rule explains the selection.
    • Earlier selection steps are not localized: Appendix I.2.2 and I.2.3 state that when the source's next subgoal is also in the target prompt, transplanting the query triggers the source subgoal about 96% of the time, indicating that selection may already be completed by earlier layers before goal heads participate.
    • Obstacle persistence is unstable: Appendix K.2 states that LMs at the studied scale do not robustly exhibit obstacle persistence in local continuations where chain-of-thought is not allowed.
    • Applicability boundary of the localization method: a footnote in Appendix C states that localizing only attention heads cannot be directly applied to models with novel linear attention mechanisms such as DeltaNet.

    Experimental coverage

    • Main-result model: the core configuration in the main text is Qwen2.5-Coder-32B-Instruct; cross-model readout covers 8 models, and obstacle persistence covers 7 models.
    • Code corpus: 253 specifications, 4 data types, 2–4 subtasks per specification; n = 1,012 per model and mode.
    • Intervention scale: NRGS KV/query transfer uses n = 32 per cell by datatype and language direction; the broader goal experiment has 96 contrastive pairs.
    • Natural language extension: ICL covers 39 single-relation tasks, 18 compositional tasks, and 5 superposition tasks; the EM chat portion is qualitative examples, with 4 of 8 questions producing contrastive cases.
    • Review information: the paper reports agreement among claude-sonnet-4-6, gpt-5, and human annotators on 130 faithfulness readouts; it does not report that all experiments used human review.
  6. Summarize the main content of the paper

    The authors localize and intervene on a class of goal heads, proposing that LLMs maintain goals by repeatedly rereading the task and progress.

    This analysis/interpretability paper studies whether a localizable goal representation exists inside LLMs, and uses controlled code generation to test its antecedence, plasticity, and persistence.

    • Problem: the authors argue that one cannot claim LLMs have goals based only on output behavior; one needs to find an internal encoding that forms before action, can be implemented across environments, and is maintained during execution.
    • Method: the authors learn a sparse mask in Qwen2.5-Coder-32B-Instruct to localize 122 goal heads; then use GoalScope to inject their aggregated output, letting the same model verbalize the next subgoal or execute it in a new language.
    • Main results: in Figure 2, the eq pivot's faithfulness/causality is 0.97/0.96, and prev_end is already 0.59/0.67; the authors state that the next operation can be read out multiple tokens before implementation.
    • Causal evidence: when only the 122 goal heads are kept with access to the task and code segments, the implementation success rate is 0.806; after blinding 250 goal heads it drops to 0.158, while the random-head control is unaffected.
    • Mechanism explanation: the authors propose NRGS: the model does not carry a single recurrent goal state, but repeatedly reads the goal from the task segment, encodes progress from context, and compares them. KV transfer reaches a causal-shift of 0.97 on py→py, and query transfer is about 0.57 under order-diff.
    • Boundaries and implications: the authors state that goal heads can also read out some implicit ICL rules and early intentions of EM models, but the complete implementation of NRGS, selection among multiple pending operations, and obstacle persistence remain unresolved.
Read originalarxiv.org