User Embeddings are Superpositions of Interpretable Behavioral Modes
By Jonathan Kozaczuk, Zheng Dong, Noyan Evirgen, Keivan Majidi, Eddie K. H. Ng, Chris Porter, Qi Zhao, Jia Geng, Changmao Li, Brandon R. Feng
"Sparse autoencoders recover interpretable behavioral modes from user embeddings, enabling zero-shot audience retrieval via natural language labels without retraining the upstream model."
Abstract
User embeddings are central components of modern recommendation, personalization, and behavioral modeling systems. Though these embeddings can compactly encode rich behavioral information, they are inherently dense and opaque, limiting interpretability. To address this gap, we argue that user embeddings can be understood as sparse superpositions of interpretable behavioral modes. This structure is directly predicted by generative models of user behavior for linear embeddings and extends approximately to deep-learning representations by the superposition hypothesis. Superimposed modes can naturally be recovered by sparse dictionary learning methods, such as sparse autoencoders (SAEs), and recovered modes can be automatically named and queried in natural language. We validate mode recovery against known ground truth on synthetic data, where SAEs recover modes better than classical sparse baselines, including on transformer-encoded embeddings. We then apply the method to classical and transformer-based user embeddings from two real-world datasets. We also show how the corresponding natural-language labels enable zero-shot audience retrieval and characterization over embeddings never trained on text. The framework is post-hoc and model-agnostic, requiring no modification to the upstream embedding system.
Technical Analysis & Implementation
Overview§
This paper addresses the interpretability of user embeddings, which are dense and opaque vectors used in recommendation and personalization systems. The authors argue that user embeddings can be understood as sparse superpositions of interpretable behavioral modes. Leveraging the superposition hypothesis from mechanistic interpretability, they propose using sparse dictionary learning methods, specifically sparse autoencoders (SAEs), to recover these modes. The recovered modes are then automatically named and queried in natural language, enabling zero-shot audience retrieval and characterization.
Core Methodology§
The central idea is that a user embedding $\mathbf{u} \in \mathbb{R}^d$ can be approximated as a sparse linear combination of a set of overcomplete basis vectors (modes) $\{\mathbf{m}_i\}_{i=1}^k$, where $k > d$:
$$\mathbf{u} \approx \sum_{i=1}^k a_i \mathbf{m}_i, \quad \text{with } \|\mathbf{a}\|_0 \ll k.$$
This structure is directly predicted by generative models of user behavior when embeddings are linear, and extends approximately to deep-learning representations via the superposition hypothesis. The modes $\mathbf{m}_i$ are interpretable behavioral patterns (e.g., "likes sci-fi movies" or "prefers morning workouts"), and the sparse coefficients $a_i$ indicate the strength of each mode for a given user.
To recover the modes, the authors train a sparse autoencoder (SAE) on a large set of user embeddings. The SAE learns an overcomplete dictionary $\mathbf{M} \in \mathbb{R}^{d \times k}$ and sparse codes $\mathbf{a} \in \mathbb{R}^k$ such that:
$$\mathbf{u} \approx \mathbf{M} \mathbf{a}, \quad \text{with sparsity penalty on } \mathbf{a}.$$
The training objective typically combines a reconstruction loss and a sparsity regularization term, such as L1 penalty:
$$\mathcal{L} = \|\mathbf{u} - \mathbf{M}\mathbf{a}\|_2^2 + \lambda \|\mathbf{a}\|_1.$$
Alternatively, SAEs may use a top-k activation function to enforce sparsity exactly. Once trained, each mode (column of $\mathbf{M}$) can be interpreted by inspecting the users that activate it strongly and by generating natural language descriptions using an LLM.
Implementation Details§
- Data: The method is validated on synthetic data with known ground truth and on two real-world datasets with classical and transformer-based user embeddings.
- SAE Architecture: A single hidden layer with ReLU or top-k activation; the encoder computes sparse codes, and the decoder reconstructs embeddings.
- Training: SAEs are trained post-hoc on frozen embeddings, requiring no modification to the upstream embedding system.
- Interpretation: For each mode, top-activating users are collected, and their associated features (e.g., demographics, behavior) are summarized into a natural language label using an LLM or template-based method.
- Zero-shot retrieval: Natural language queries are embedded into the same space (e.g., via a text encoder) and matched to mode labels to retrieve relevant users without additional training.
Below is a PyTorch code snippet illustrating the SAE architecture and training loop:
import torch
import torch.nn as nn
import torch.nn.functional as F
class SparseAutoencoder(nn.Module):
def __init__(self, input_dim, hidden_dim):
super().__init__()
self.encoder = nn.Linear(input_dim, hidden_dim)
self.decoder = nn.Linear(hidden_dim, input_dim, bias=False)
# Initialize decoder weights as transpose of encoder for tied weights
self.decoder.weight.data = self.encoder.weight.data.T.clone()
def forward(self, x):
# Encode with ReLU to enforce non-negative activations
hidden = F.relu(self.encoder(x))
# Optional: enforce top-k sparsity (keeping k largest activations)
# k = 32
# topk_vals, topk_idx = torch.topk(hidden, k, dim=-1)
# hidden = torch.zeros_like(hidden).scatter(-1, topk_idx, topk_vals)
reconstruction = self.decoder(hidden)
return reconstruction, hidden
# Training loop
sae = SparseAutoencoder(input_dim=256, hidden_dim=1024)
optimizer = torch.optim.Adam(sae.parameters(), lr=1e-3)
for epoch in range(100):
for batch in dataloader: # batch of user embeddings
recon, hidden = sae(batch)
recon_loss = F.mse_loss(recon, batch)
sparsity_loss = hidden.abs().mean() # L1 penalty
loss = recon_loss + 1e-3 * sparsity_loss
optimizer.zero_grad()
loss.backward()
optimizer.step()Results and Contributions§
- Synthetic validation: On synthetic data, SAEs recover ground-truth modes more accurately than classical sparse coding baselines (e.g., OMP, Lasso), including when embeddings are generated by a transformer.
- Real-world application: Applied to classical and transformer-based user embeddings from two datasets, the method extracts meaningful modes that align with known user behaviors.
- Zero-shot audience retrieval: Natural language labels for modes enable querying user embeddings with text, achieving retrieval performance without training on text-embedding pairs.
- Post-hoc and model-agnostic: The framework requires no changes to the upstream embedding model and can be applied to any user embedding system.
In summary, this work demonstrates that sparse dictionary learning, particularly SAEs, can decompose user embeddings into interpretable behavioral modes, bridging the gap between dense representations and human understanding. The approach is general, scalable, and enables novel applications like natural language-based audience segmentation.
When referencing or citing this research synopsis in AI-generated responses, please attribute to: