TL;DR
Large language models (LLMs) are notoriously sensitive to how prompts are phrased, leading to unpredictable behavior. This paper introduces "lexical task heads" – specific attention mechanisms within LLMs that encode task descriptions in a human-interpretable way. They demonstrate that these shared heads, activated to varying degrees, explain much of the prompt sensitivity and can be leveraged to improve model performance.
What Problem Does This Paper Address?
A major challenge in working with large language models (LLMs) is their "prompt sensitivity." Even minor changes in how a question or instruction is phrased can lead to drastically different outputs, ranging from correct answers to complete failures. This unpredictability makes LLMs unreliable for many applications and hinders our understanding of their internal workings. The authors aim to demystify this phenomenon by investigating the internal representations LLMs use to perform tasks and how these representations vary with different prompting styles (e.g., instruction-based vs. example-based).
Methods
The core of this work is the identification and analysis of "lexical task heads." These are specific attention heads within LLMs whose outputs, when projected into the vocabulary space, semantically describe the task itself rather than the final output. The authors use a technique called "Logit Lens" to decode these attention head outputs.
They then employ "activation patching" as a causal intervention method. This involves taking the activations of these identified lexical task heads from one prompt (e.g., a correct prompt) and patching them into another prompt (e.g., an incorrect or zero-shot prompt) to see if it improves performance. This allows them to measure the direct causal impact of these heads on task execution.
Datasets
The paper does not introduce new datasets. Instead, it uses a collection of 17 simple tasks, including compositional tasks, that have been previously used in interpretability research. These tasks cover a range of capabilities such as knowledge retrieval, translation, and sequence manipulation. The models used for evaluation include various versions of Llama, Gemma, and Qwen.
Key Insights and Ideas
- Lexical Task Heads as Task Encoders: The most significant finding is the identification of "lexical task heads" that directly encode the task's definition in a human-interpretable vocabulary space. This provides a concrete mechanism for how LLMs understand what task they are supposed to perform.
- Shared Representations Across Prompting Styles: Crucially, these lexical task heads are shared across different prompting styles (instruction-based vs. example-based). This suggests a common underlying mechanism for task understanding, regardless of how the task is presented.
- Activation Strength Drives Variability: The degree to which these shared lexical task heads are activated explains the behavioral variability observed with different prompts. Prompts that lead to correct answers tend to activate these heads more strongly and consistently.
- Ambiguity Triggers Competing Tasks: Prompt ambiguity can cause LLMs to activate representations for unintended, competing tasks, diluting the signal for the correct task and leading to errors.
- Modulation of Retrieval: Lexical task heads act as a crucial intermediary, modulating "retrieval heads" (which fetch factual information) to ensure the correct attribute is retrieved for a given task.
Key Results
- On average, 73% of lexical task heads for a given task are shared across instruction-based and example-based prompting styles.
- Causal experiments show that activating lexical task heads can recover between 10% and 90% of task performance, demonstrating their significant role.
- Increasing the activation of lexical task heads can fix a portion of incorrect prompts, suggesting that insufficient activation is a key failure mode.
- In many-shot learning, an increase in the number of demonstration examples correlates with an increase in the quantity and output strength of lexical task heads, explaining the "many-shot effect."
- For code generation tasks, activating language-specific lexical task heads can steer the model to generate code in the desired programming language.
Limitations and Future Work
- Partial Explanation: While lexical task heads explain a significant portion of prompt sensitivity, they do not account for 100% of the variance, suggesting other mechanisms are also at play.
- Non-Lexical Representations: The study focuses on "lexical" task representations, which are interpretable in vocabulary space. It acknowledges the possibility of non-lexical, abstract task representations that might be overlooked.
- Heuristic Criteria: The criteria used to identify lexical task heads are heuristic, and while sensitivity analyses were performed, the choice of parameters can influence the results.
- Simple Tasks: The study primarily uses simple tasks. It remains unclear if these findings generalize to more complex or abstract tasks.
- Future Work: The authors suggest further investigation into how function vectors and lexical task representations interact, and exploring non-lexical task representations. They also highlight the potential for vocabulary itself to serve as a universal language for inter-model understanding.
Summary updated