Shared Lexical Task Representations Explain Behavioral Variability In LLMs

Zhuonan Yang, Xiaochen Li, Francisco Piedrahita Velez, Eric Todd, David Bau, Michael Littman, Stephen Bach, Ellie Pavlick

Large Language Models (LLMs) are notoriously sensitive to how a prompt is phrased. A model might solve a task perfectly when given five examples but fail completely when given a slightly different natural language instruction. This "brittleness" remains a major hurdle for AI reliability.

Previous research suggested that different prompting styles—specifically instruction-based (telling the model what to do) and example-based (showing the model what to do via In-Context Learning)—might rely on entirely different internal circuits. However, recent findings challenge this assumption. Researchers have identified "lexical task heads" (LTHs): specific attention heads that internally represent a task by its literal definition.

This paper demonstrates that these heads form a shared mechanism across different prompting styles, and that prompt sensitivity is largely a function of how strongly these internal "task labels" are activated.

Uncovering Lexical Task Heads

To understand how models process tasks internally, the authors applied a suite of interpretability techniques to 13 different LLMs, including Llama-3.1, Gemma-2, and Qwen. They evaluated these models across 17 simple tasks (e.g., antonyms, country-to-capital), 3 compositional two-hop reasoning tasks, and code generation using the HumanEval-X dataset.

The methodology relied on several core techniques:

  • Logit Lens: By projecting the outputs of individual attention heads directly into the model’s vocabulary space, researchers could observe if a head was "thinking" in human-readable words.
  • LTH Identification: Lexical Task Heads were defined as those whose top-decoded tokens matched the task's definition (e.g., a head for a "Country-Capital" task outputting the word "cities").
  • Activation Patching & Scaling: To prove these heads cause the model's behavior, the authors performed causal interventions. They cached the activations of LTHs from successful prompts and patched them into failing prompts. They also multiplied the activation strength of these heads to observe the impact on task execution.

Key Insights into Model Behavior

The Model "Names" the Task Internally

Before producing an answer, the model activates heads that literally describe the task in the vocabulary space. This suggests that LLMs use language as an internal "latent variable" to organize their own computations.

Shared Circuitry Across Prompt Styles

Despite the surface-level differences between natural language instructions and few-shot examples, the two prompting styles share an average of 73% of their lexical task heads. This points to a unified internal "understanding" of the task that transcends how the prompt is formatted.

Explaining the "Many-Shot" Mechanism

The well-known "many-shot" effect—where providing more examples improves model performance—can be explained by the gradual accumulation of internal evidence. Each additional example increases the activation strength (specifically, the $L_2$ norm) of the lexical task heads.

Task Superposition and Ambiguity

Failures often occur because of "competing" task representations. If a prompt is ambiguous (e.g., "Apple: America" could imply Product-Country or Brand-Origin), the model activates multiple task heads simultaneously. This "task superposition" dilutes the signal for the target task, leading to incorrect or hallucinated outputs.

Empirical Results and Causal Impact

The identification of LTHs is not just observational; manipulating them has profound causal effects on model outputs:

  • Repairing Failures: Activating lexical task heads alone can recover 10% to 90% of task performance across different prompts. By patching LTH activations from "correct" prompts into "incorrect" ones, the authors significantly boosted the accuracy of previously failing prompts.
  • Steering Code Generation: In coding tasks, the authors successfully steered a model to switch from generating JavaScript to Python with 90% success simply by scaling the "Python" lexical heads. This proves these heads act as high-level control switches.
  • Retrieval Modulation: LTHs act as a "directional filter" for retrieval heads. When LTHs are strongly activated, they help retrieval heads narrow down the search space—for example, shifting the internal query from "all facts about Japan" to specifically "the capital of Japan."

Limitations and Future Directions

While lexical task heads provide a compelling explanation for prompt sensitivity, the study primarily focuses on tasks with clear lexical definitions. It remains unclear if these mechanisms hold for highly abstract reasoning or tasks that are difficult to describe in a few words. Furthermore, because LTHs account for up to 90% of performance recovery, other non-lexical or abstract representations (such as function vectors) are clearly still at play.

The identification of these heads also relies on predefined lists of "task-descriptive terms," which introduces some heuristic dependency, though the authors mitigated this by using LLM-generated lists. Future research will need to investigate how these lexical representations emerge during the pre-training and fine-tuning processes, potentially unlocking new ways to train inherently robust models.

Summary updated

BibTeX
@inproceedings{yang2026shared,
  author = {Zhuonan Yang and Xiaochen Li and Francisco Piedrahita Velez and Eric Todd and David Bau and Michael Littman and Stephen Bach and Ellie Pavlick},
  title = {{Shared Lexical Task Representations Explain Behavioral Variability In LLMs}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=1kmTTgPJAm},
}
Figure