Deep Learning
Louis

LLM Interpretability: The Role of Sparse Autoencoders

Partager l’article :

Large language models (LLMs) like GPT-4 and Claude 3 are incredibly powerful, yet they remain black boxes that are difficult to decipher. It is only natural to wonder how these models manage to generate such precise responses or even come up with creative ideas. The interpretability of these models is a major challenge, and one promising approach to exploring these mysteries relies on "Sparse Autoencoders" (SAEs). In this article, we show you how SAEs allow us to break down these LLMs into interpretable components, offering a glimpse into how these complex artificial intelligence models function.

What is a Sparse Autoencoder?

To understand how SAEs contribute to LLM interpretability, it is essential to first understand what an autoencoder is. An autoencoder is a neural network that learns to compress and decompress its inputs. Simply imagine a neural network that takes a 100-dimensional vector as input, reduces it to 50 dimensions, and then reconstructs it back into 100 dimensions. The goal of the model is to learn how to minimize the difference between the input vector and the output vector after reconstruction.

‍

Explanatory diagram of an Autoencoder

‍

Sparse Autoencoders distinguish themselves by adding a "sparsity" penalty to their loss function, which encourages the model to activate only a small proportion of its neurons in the hidden layers. The sparsity penalty therefore pushes the model to create an intermediate vector (activations) with as many zero values as possible. We will see later that this penalization technique makes it possible to obtain a compressed, and therefore more interpretable, representation of the intermediate activations of other, larger models like LLMs.

‍

Explanatory diagram of a Sparse Autoencoder

‍

Sparse Autoencoders and LLM interpretability

The idea behind using SAEs for LLM interpretability is to decompose the intermediate activations of LLMs to make them easier for humans to interpret. The activations of a language model are often opaque: each neuron can potentially encode multiple concepts at once, a phenomenon known as superposition. This complexity makes it difficult to understand what each neuron truly represents.

SAEs can be trained using the model's intermediate activations at various points in its architecture, often between two layers. We call this a feature, an interpretable component of the activations produced by training an SAE between two layers of an LLM. Each feature aims to represent an identifiable concept that can be interpreted by humans (for example: semantic concepts—"human flaws" or "price increases"—grammatical categories, or specific themes). 

To summarize, the goal of using SAEs is to obtain a sparse representation (with as many zero values as possible), where each feature corresponds to an interpretable concept. These representations offer a way to break down LLMs into smaller, more explicit elements, thereby facilitating the interpretation of the responses produced by the model.

How Sparse Autoencoders extract features from LLMs

As previously explained, one of the strengths of SAEs is their ability to extract features from the intermediate activations of LLMs. The SAE training process transforms these complex activations into a set of features interpretable ones. Here is how it works:

  1. Encoding intermediate activations : an SAE takes the intermediate activations of an LLM as input; these intermediate activations are very large vectors (for example, 12,288 dimensions for GPT-3). The SAE is used to encode this vector into a new, higher-dimensional representation that is highly sparse (containing a large number of zero values).
  1. Sparsity and concept reduction : this encoding process imposes a sparsity constraint. This means that, although the representation is high-dimensional, only a small portion of neurons are activated. For example, out of 49,512 dimensions, perhaps only 100 of them are non-zero. The goal is to decompose the activations into different components where each feature is distinct and easier to interpret.
  1. Learning the features : during training, the SAE learns to identify combinations of neurons that correspond to important concepts within the LLM. The SAE decoder is then used to reconstruct the original activations from this compressed version. Each feature activated in the compressed representation represents a specific concept. Simply put, each feature extracted by the SAE can be seen as capturing a particular and identifiable aspect of the information processed by the model, which allows for a better understanding of how it works.
  1. Interpretability of features : once the features are extracted, we must try to understand what each feature represents. For example, a feature could correspond to a geographical concept like the Golden Gate Bridge or to a more abstract theme, such as relative clauses in sentences. By observing which types of inputs specifically activate certain features, researchers can get a better idea of what each feature captures.

‍

Example of Golden Gate Bridge feature extraction

‍

This process, which allows for the extraction of precise concepts from LLM activations, also makes it possible to directly influence the model's behavior. By applying a technique called feature steering, it is possible to directly manipulate the activations of a feature to steer the model's responses toward a specific subject. Anthropic researchers demonstrated that by artificially amplifying the activation of the feature associated with the Golden Gate Bridge, they could prompt the Claude model to systematically include references to the bridge in its responses, even when the subject was irrelevant. For example, when asked to describe its physical form, Claude replied: "I am the Golden Gate Bridge... my physical form is the iconic bridge itself."

OpenAI and Anthropic: Promising results

Recently, notable efforts have been made by companies like OpenAI and Anthropic to develop methods for decomposing language models using Sparse Autoencoders. OpenAI has successfully decomposed GPT-4 activations into 16 million features potentially interpretable features. These features include themes such as "rising prices" or "human imperfection," which correspond to concepts activated within the model.

Anthropic has focused on extracting features from Claude 3 Sonnet. They have discovered complex features, ranging from "data type signatures in computer code" to "personality traits" or "cultural biases," and even "abstract behavioral traits related to deception or manipulation." Their work highlights that Sparse Autoencoders are capable of extracting very high-level features, which not only allow us to understand how the model reacts to certain types of input but also to manipulate it, for instance, to avoid certain forms of bias or to force the appearance of specific themes.

Current limitations and the future of interpretability

Despite their promise, Sparse Autoencoders have limitations. One of the main problems is evaluating interpretability: how can we ensure that a feature is truly interpretable or that it corresponds to a concept understandable to humans? Today, evaluation methods still rely heavily on subjective assessment. One must manually examine the activations of features and decide if they make sense. Furthermore, although SAEs are capable of decomposing activations locally, they reveal nothing about how these features are used across the other layers of the model.

However, the outlook is encouraging. Efforts to make LLMs more explainable help build trust in these models, a crucial issue for ensuring their safe use in sensitive contexts. Improvements in SAE training, particularly through increasing the size of decoders or applying new regularization methods, could eventually extend the reach of interpretability to a wider variety of models and use cases.

The latest breakthroughs

Anthropic recently introduced Sparse Crosscoders, a new approach that expands the capabilities of Sparse Autoencoders by allowing the extraction of interpretable features from LLMs across multiple layers simultaneously. Unlike traditional methods that analyze each layer in isolation, Sparse Crosscoders connect activations between layers and identify common patterns that persist throughout the model. This new approach allows for a clearer interpretation of the internal mechanisms of LLMs. Furthermore, they allow for the comparison of different training versions of the same model architecture by isolating the features shared and specific features, which is particularly useful for studying the effects of fine-tuning on these models. This promising approach paves the way for more granular analyses of model evolution, strengthening transparency and safety in AI development.

Explanatory diagram of the Sparse Crosscoders approach

‍

Conclusion

Sparse Autoencoders represent a promising breakthrough in opening the black box of LLMs by decomposing their activations into interpretable components. This approach is essential for improving understanding of and trust in these AI models. Research conducted by OpenAI and Anthropic shows that these methods can be applied to increasingly large models, offering valuable insights into their internal workings. Recently, the introduction of Sparse Crosscoders by Anthropic has opened new perspectives for interpretability by allowing the extraction of interpretable features across multiple layers simultaneously. With these advancements, SAEs and Sparse Crosscoders play a central role in improving the reliability and transparency of LLMs, paving the way for trustworthy AI that is more accessible for human analysis.

Sources

[1]An Intuitive Explanation of Sparse Autoencoders for LLM Interpretability by Adam Karvonen

[2] Scaling Monosemanticity: Extracting Interpretable Features from Claude 3 Sonnet by Anthropic

[3] Extracting Concepts from GPT-4 by OpenAI

[4] Sparse Crosscoders for Cross-Layer Features and Model Diffing by Anthropic

Un accompagnement de A à Z par nos experts dans le but d’une intégration de solutions IA sur-mesure.

Lorem ipsum dolor sit amet consectetur. Ipsum penatibus viverra feugiat amet varius pharetra porta risus lectus. Turpis enim massa non tincidunt in faucibus.

Découvrez plus d’articles

No items found.
Bird with red, yellow, and black feathers in flight, wings spread, against a blurred background of greenery.

Can you chat with your company database just like you do with ChatGPT?

Lire l’article
No items found.

TPOT vs. Auto-sklearn: Comparing Two AutoML Libraries

Lire l’article
Deep Learning

Strengthening convolutional neural networks (CNNs) using capsules

Lire l’article