Skip to main content
QUICK REVIEW

[Paper Review] VISIT: Visualizing and Interpreting the Semantic Information Flow of Transformers

Shahar Katz, Yonatan Belinkov|arXiv (Cornell University)|May 22, 2023
Explainable Artificial Intelligence (XAI)Computer Science3 citations
TL;DR

This paper introduces VISIT, a tool that visualizes and interprets the semantic information flow in GPT-like transformers by projecting hidden states and attention memory values to the vocabulary space using the logit lens. It reveals that layer norms act as semantic filters, and identifies consistently activated neurons—termed 'regularization neurons'—that stabilize model outputs, offering new mechanistic insights into attention and residual stream dynamics.

ABSTRACT

Recent advances in interpretability suggest we can project weights and hidden states of transformer-based language models (LMs) to their vocabulary, a transformation that makes them more human interpretable. In this paper, we investigate LM attention heads and memory values, the vectors the models dynamically create and recall while processing a given input. By analyzing the tokens they represent through this projection, we identify patterns in the information flow inside the attention mechanism. Based on our discoveries, we create a tool to visualize a forward pass of Generative Pre-trained Transformers (GPTs) as an interactive flow graph, with nodes representing neurons or hidden states and edges representing the interactions between them. Our visualization simplifies huge amounts of data into easy-to-read plots that can reflect the models' internal processing, uncovering the contribution of each component to the models' final prediction. Our visualization also unveils new insights about the role of layer norms as semantic filters that influence the models' output, and about neurons that are always activated during forward passes and act as regularization vectors.

Motivation & Objective

  • To improve interpretability of transformer language models by visualizing the semantic flow of information through attention mechanisms and hidden states.
  • To investigate the functional roles of dynamic components like attention memory values and layer normalization in the residual stream.
  • To develop an accessible, interactive visualization tool that simplifies complex internal model dynamics for researchers and practitioners.
  • To uncover previously unobserved patterns in how neurons and attention heads contribute to final predictions.
  • To provide mechanistic insights into components like layer norms and consistently active neurons in GPT-2.

Proposed method

  • Projects hidden states and attention memory values to the vocabulary space using the logit lens, enabling human-readable interpretation of model activations.
  • Constructs interactive flow graphs where nodes represent neurons or hidden states and edges represent information flow between components.
  • Analyzes attention mechanisms by tracking the semantic content of queries, keys, values, and output heads across layers.
  • Applies layer normalization (LN) effects to hidden states and compares token probabilities before and after LN to assess semantic filtering.
  • Identifies neurons that are consistently activated across all forward passes, characterizing them as regularization neurons distinct from rogue dimensions.
  • Uses case studies on GPT-2 to validate findings on indirect object identification, LN filtering, and neuron behavior.
Figure 1: Modeling a single layer (number 14) of GPT-2 for the prompt: “The capital of Japan is the city of”. Each node represents a small group of neurons or HS, which are labeled by the top token of their projection to the vocabulary space. The plot should be read from left to right and includes t
Figure 1: Modeling a single layer (number 14) of GPT-2 for the prompt: “The capital of Japan is the city of”. Each node represents a small group of neurons or HS, which are labeled by the top token of their projection to the vocabulary space. The plot should be read from left to right and includes t

Experimental results

Research questions

  • RQ1How do attention memory values and hidden states carry semantic information through the residual stream in GPTs?
  • RQ2What is the functional role of layer normalization layers in shaping the semantic content of hidden states?
  • RQ3Are there neurons that are consistently activated during inference, and what is their impact on model behavior?
  • RQ4How does the logit lens projection of hidden states reveal the model's internal reasoning process before prediction?
  • RQ5To what extent do layer norms act as semantic filters that alter the probability distribution of generated tokens?

Key findings

  • Layer normalization layers act as semantic filters that suppress function words and promote domain-specific or contextually relevant tokens like 'Redmond' or 'downtown'.
  • The logit lens projection without the final layer norm ($ln_f$) produces semantically incoherent token distributions, highlighting $ln_f$'s critical role in maintaining contextual coherence.
  • Neurons consistently activated across all forward passes—termed 'regularization neurons'—are distinct from rogue dimensions and contribute to model stability.
  • The attention mechanism's memory values (keys and values) carry meaningful semantic content, with information flow patterns revealing how past tokens influence current predictions.
  • The visualization tool successfully captures the dynamic flow of semantic information, enabling detection of individual neuron contributions to final outputs.
  • Case studies confirm that the tool can reproduce known mechanistic behaviors, such as indirect object identification, in a simplified and interpretable manner.
(a) Without $W_{O}$ projection
(a) Without $W_{O}$ projection

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.