[Paper Review] Linear Representations of Sentiment in Large Language Models
This paper reveals that sentiment in large language models is represented linearly along a single direction in activation space, which is causally significant for sentiment prediction. Through causal interventions and circuit analysis, the authors identify a 'summarization motif' where sentiment is aggregated at neutral tokens like commas, explaining 36% of zero-shot SST accuracy loss when ablated.
Sentiment is a pervasive feature in natural language text, yet it is an open question how sentiment is represented within Large Language Models (LLMs). In this study, we reveal that across a range of models, sentiment is represented linearly: a single direction in activation space mostly captures the feature across a range of tasks with one extreme for positive and the other for negative. Through causal interventions, we isolate this direction and show it is causally relevant in both toy tasks and real world datasets such as Stanford Sentiment Treebank. Through this case study we model a thorough investigation of what a single direction means on a broad data distribution. We further uncover the mechanisms that involve this direction, highlighting the roles of a small subset of attention heads and neurons. Finally, we discover a phenomenon which we term the summarization motif: sentiment is not solely represented on emotionally charged words, but is additionally summarized at intermediate positions without inherent sentiment, such as punctuation and names. We show that in Stanford Sentiment Treebank zero-shot classification, 76% of above-chance classification accuracy is lost when ablating the sentiment direction, nearly half of which (36%) is due to ablating the summarized sentiment direction exclusively at comma positions.
Motivation & Objective
- Investigate how sentiment is represented internally within large language models (LLMs), particularly whether it is encoded linearly.
- Determine whether a single direction in activation space causally influences sentiment prediction in both synthetic and real-world tasks.
- Identify the neural mechanisms—specific attention heads and neurons—responsible for sentiment representation and summarization.
- Explore the existence and role of intermediate, non-valenced tokens (e.g., commas, names) in summarizing sentiment information across layers.
- Assess the robustness and generalizability of sentiment representation across diverse models and datasets, including SST and OpenWebText.
Proposed method
- Use a causal mediation analysis framework to isolate and test the influence of a sentiment direction in activation space.
- Apply activation patching and directional ablation to measure the causal contribution of the sentiment direction to model predictions.
- Train a sentiment direction via K-means clustering on activation embeddings from a toy dataset (ToyMovieReview) and validate it on real-world data (SST).
- Use the transformer-lens library to perform detailed circuit analysis, identifying key attention heads and neurons involved in sentiment representation.
- Implement directional patching to test whether injecting or removing sentiment information at specific tokens affects final predictions.
- Compare results across multiple models (GPT-2, Pythia) and layers to assess consistency and generalization of the sentiment direction.
Experimental results
Research questions
- RQ1Is sentiment represented as a single, linear direction in the activation space of LLMs across diverse models and tasks?
- RQ2Is this sentiment direction causally relevant to final sentiment predictions, as demonstrated through intervention techniques?
- RQ3Do intermediate, non-valenced tokens (e.g., commas, periods, proper nouns) serve as hubs for summarizing sentiment information?
- RQ4Which specific attention heads and neurons are most responsible for encoding and propagating sentiment representations?
- RQ5How much of the model’s sentiment classification performance can be attributed to the sentiment direction, particularly when ablated at summarization tokens?
Key findings
- A single linear direction in activation space captures sentiment across diverse contexts, including English and French text, with high correlation to sentiment labels.
- Causal ablation of the sentiment direction reduces zero-shot SST accuracy by 76% above chance, demonstrating its causal significance.
- Ablating the sentiment direction specifically at comma positions accounts for 36% of the total accuracy loss, revealing the 'summarization motif'.
- The sentiment direction is robust across multiple models (GPT-2, Pythia) and layers, indicating a generalizable internal representation.
- A small subset of attention heads and neurons are primarily responsible for encoding and propagating sentiment, suggesting a compact, interpretable circuit.
- The sentiment direction is not simply a proxy for valence words but captures a higher-level abstraction, with information funneled through neutral tokens like punctuation and names.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.