Skip to content

E03 — Representational Similarity Analysis

Section titled “E03 — Representational Similarity Analysis”

This framework asks: Do two representational spaces organize stimuli in the same geometric pattern?

RSA abstracts away the specific basis of a representation and instead compares the relational structure — which inputs are close to which. By computing pairwise dissimilarity matrices (RDMs) and correlating them, RSA can compare representations across layers, models, or even modalities without requiring aligned dimensions.

For circuit analysis, RSA reveals whether a circuit subspace organizes inputs the same way as a task-relevant variable. If the RDM of a circuit head’s activations correlates with the RDM predicted by the task structure, that head likely encodes task-relevant geometry.

SourceYearKey contribution
Kriegeskorte et al., “Representational similarity analysis”2008Introduced RSA framework for neural data
Kriegeskorte & Kievit, “Representational geometry”2013Formalized representational geometry theory
Diedrichsen & Kriegeskorte, “Representational models”2017Extended RSA to model-based hypothesis testing
Shahbazi et al., “Using distance on the Riemannian manifold to compare representations”2021Geometric corrections for RDM comparison

Given ( n ) stimuli and representations ( H \in \mathbb{R}^{n \times d} ), the RDM is:

[ \text{RDM}_{ij} = d(h_i, h_j) ]

where ( d ) is typically cosine distance or Euclidean distance. RSA then measures the second-order similarity between two RDMs using Spearman or Kendall correlation:

[ \text{RSA}(H_1, H_2) = \rho_{\text{Spearman}}\left(\text{vec}(\text{RDM}_1),, \text{vec}(\text{RDM}_2)\right) ]

High RSA between a circuit subspace and a task-model RDM (constructed from the known task variables) indicates geometric alignment. The method is basis-invariant — rotations of the representation do not affect the RDM.

Computes RDMs at each layer and correlates them against hypothesis RDMs derived from task structure (e.g., “same IO name” for IOI, “singular vs plural” for SVA).

What it establishes: Whether representational geometry at a layer matches task-predicted structure. What it does not establish: Whether that geometry is causally necessary (use E01 for that).

Usage:

uv run python rsa_analysis.py --tasks ioi sva --metric cosine

Computes RSA between all pairs of layers, producing a layer-by-layer similarity matrix that reveals representational transitions.

What it establishes: Where in the network the representation undergoes qualitative geometric shifts. What it does not establish: What information is gained or lost at each transition.

Usage:

uv run python rsa_analysis.py --tasks ioi sva --cross-layer
PatternWhat it means
RSA > 0.7 with task modelLayer geometry strongly reflects task structure
RSA drops between layers ( \ell ) and ( \ell+1 )Major representational transformation at that boundary
RSA high across many layersTask structure is preserved passively through the residual stream
RSA near zero everywhereTask variables not geometrically organized (may be nonlinear)