Abstract
Topic Modelling is an established research area where the quality of a given topic is measured using coherence metrics. Often, we infer topics from Neural Topic Models (NTM) by interpreting their decoder weights, consisting of top-activated words projected from individual neurons. Transformer-based Language Models (TLM) similarly consist of decoder weights. However, due to its hypothesised superposition properties, the final logits originating from the residual path are considered uninterpretable. Therefore, we posit that we can interpret TLM as superposed NTM by proposing a novel weight-based, model-agnostic and corpus-agnostic approach to search and disentangle decoder-only TLM, potentially mapping individual neurons to multiple coherent topics. Our results show that it is empirically feasible to disentangle coherent topics from GPT-2 models using the Wikipedia corpus. We validate this approach for GPT-2 models using Zero-Shot Topic Modelling. Finally, we extend the proposed approach to disentangle and analyse LLaMA models.
Introduction: The Challenge of Superposition
In the field of mechanistic interpretability, a primary goal is to decode the internal representations of individual neurons within large-scale models. However, Transformer Language Models (TLMs) like GPT-2 and LLaMA exhibit a phenomenon known as superposition. Because these models must represent more features than they have available neurons, they "compress" multiple, often unrelated concepts into single neurons. This polysemanticity makes individual neurons appear as "gibberish" when analyzed through traditional methods.
This paper, presented at EMNLP 2023, proposes a mathematical framework to "unmix" these superposed representations. By treating TLMs as superposed topic models, the authors introduce a weight-based, model-agnostic approach to disentangle these overlapping concepts into human-interpretable topics without requiring additional training or Sparse Autoencoders.
Methodology: A Three-Step Disentanglement Approach
The core of the proposed method is a pipeline that maps raw neuron weights to coherent word clusters.
- Projection: The process begins by projecting a neuron's logit weights onto a reference corpus (e.g., Wikipedia-EN). Statistical relationships between words are calculated using Normalized Pointwise Mutual Information (NPMI).
- Shortlisting: The method identifies the "tails" of the logit distribution. As shown in the distribution analysis, neurons exhibit distinct regions of Promotion (strongly activated words) and Elimination (strongly suppressed words). Both tails are found to contain significant topical information.
- Exact Solving via Graph Theory: The shortlisted words are modeled as a graph where edges represent NPMI scores. Extracting a coherent topic is framed as finding a Maximum Edge-Weighted $b$-Clique. To handle the NP-hard nature of this problem, a "star heuristic" is employed to decompose the graph into manageable sub-graphs for exact solving.
Key Insights and Results
The authors analyzed GPT-2 (Small to XL) and LLaMA (7B and 13B) models, yielding several critical findings:
- Topical Coherence: Topics disentangled from GPT-2 neurons significantly outperformed random baselines in NPMI coherence ($p < 0.001$).
- Zero-Shot Topic Modelling (ZSTM): When used for ZSTM tasks across datasets like 20NewsGroup and BBC-News, the method proved competitive with state-of-the-art dedicated topic models such as ProdLDA and BERTopic.
- The Role of Elimination: A surprising insight is that the "negative" tail (Elimination) is often as coherent as the "positive" tail (Promotion). Neurons do not just signal the presence of a theme; they actively suppress competing concepts.
- Topical Sparsity and Scale: Larger models (e.g., GPT-2 XL) exhibit higher "topical sparsity," where concepts are more diffused across the network, making individual neurons appear noisier than in smaller models.
- The Tokenization Barrier: Interpreting LLaMA is more complex due to sub-word tokenization (SentencePiece), which causes a "word explosion" that requires additional reconstruction steps to map fragments back to meaningful concepts.
Conclusion
By reframing Transformers as superposed topic models, this research provides a powerful tool for peering into the "black box" of LLMs. The ability to disentangle polysemantic neurons into multiple distinct, coherent themes suggests that interpretability can be achieved through clever weight-based analysis and graph optimization, paving the way for more transparent and controllable AI systems.
Summary updated