On the Similarity of Circuits across Languages: a Case Study on the Subject-verb Agreement Task

Javier Ferrando, Marta R. Costa-jussà

TL;DR

This paper reveals that large language models (specifically the Gemma family) use remarkably similar, language-independent internal "circuits" to handle subject-verb agreement in both English and Spanish. By identifying a specific one-dimensional subspace in the residual stream that encodes grammatical number, the authors demonstrate that they can causally flip a model's Spanish verb predictions using an activation direction discovered entirely from English data.

What Problem Does This Paper Address?

Mechanistic interpretability aims to reverse-engineer the internal neural algorithms of language models. While researchers have successfully mapped out "circuits" (subsets of attention heads and MLP neurons) responsible for specific tasks like indirect object identification or simple arithmetic, it remains unclear how universal these circuits are.

Specifically, do language models learn entirely different internal mechanisms to solve the same grammatical task in different languages, or do they rely on a unified, language-agnostic representation? This paper tackles this question by analyzing the Subject-Verb Agreement (SVA) task—ensuring a verb matches its subject in number (singular vs. plural)—across both English and Spanish.

Methods

The authors employ several standard mechanistic interpretability techniques to dissect Gemma 2B:

  • Direct Logit Attribution (DLA): Measuring the direct linear contribution of individual model components to the final prediction score (logit difference between the correct and incorrect verb forms).
  • Activation Patching (Denoising): A causal intervention method where activations from a "clean" prompt (e.g., a singular subject) are substituted into the forward pass of a "corrupted" prompt (e.g., a plural subject) to pinpoint exactly which components track grammatical number.
  • Principal Component Analysis (PCA): Used to study the activation space of key attention heads and isolate low-dimensional representations of grammatical features.
  • Activation Steering: A causal validation technique where the authors inject a vector representing "grammatical number" (derived from English data) directly into the model's activations during a Spanish forward pass to see if it alters the output behavior.

Datasets

The study evaluates contrastive sentence pairs where the subject and its corresponding verb form vary by grammatical number:

  • English SVA Dataset: Sourced from existing benchmarks (Arora et al., 2024), built on top of SyntaxGym. Example: "The executive that embarrassed the manager has..." (Clean/Singular) vs. "The executives that embarrassed the manager have..." (Corrupted/Plural).
  • Spanish SVA Dataset: Newly generated by the authors using GPT-4 to mirror the syntactic structure of the English dataset. Example: "El ingeniero que ayudó al cantante era..." (Singular) vs. "Los ingenieros que ayudaron al cantante eran..." (Plural). Words were carefully filtered to ensure they tokenized cleanly into single subwords, preventing tokenization artifacts during patching.

Key Insights and Ideas

  • A Language-Agnostic Subspace: The model does not maintain separate linguistic machinery for tracking English and Spanish plurality. Instead, a single attention head writes a "subject number" signal into a shared, one-dimensional subspace within the residual stream.
  • Highly Consistent Circuit Architecture: The information flow is virtually identical across both languages. Early layers process the subject noun; a specific mid-to-late attention head (L13H7 in Gemma 2B) extracts the grammatical number and writes it to the last token's residual stream; and a tiny subset of downstream MLP neurons (dominated by neuron 2069 in MLP13) reads this signal to promote the correct verb form.
  • Cross-Lingual Transferability: The internal representation of "plurality" is abstract enough that the principal direction found in English training data can be directly applied to Spanish sentences to reliably flip the model's predictions.

Key Results

  • Circuit Localization: Activation patching identified attention head 7 in layer 13 (L13H7) as the primary driver of the subject-number signal in Gemma 2B.
Figure 1: English dataset activation patching results on the logit difference metric on (a) the residual streams (b) attention blocks outputs, (c) MLP outputs, and (d) on attention heads at the last position.
  • 1D Encoding: Performing PCA on the outputs of L13H7 showed that the first principal component (PC1) perfectly separates singular and plural subjects for both English and Spanish datasets.
Figure 5: Projections of L13H7 outputs onto the top 2 PCs on English (left) and Spanish (right) dataset.
  • Causal Activation Steering: Adding or subtracting the English PC1 vector to the Spanish forward pass successfully flipped the predicted Spanish verb number (e.g., changing the top prediction from era to eran), proving the cross-lingual causal relevance of this direction.
Spanish logit difference before and after steering with English PC1
  • Family-Wide Replication: The authors successfully replicated these findings in larger and newer models. In Gemma 7B, attention head L22H6 plays the identical role, while in Gemma 2 2B, head L19H3 performs the exact same function.

Limitations and Future Work

  • Model Family Constraints: The study focused exclusively on the Gemma family. Gemma was chosen because its massive vocabulary size (256k tokens) minimizes cross-lingual tokenization discrepancies. It remains to be seen if these compact, language-agnostic circuits appear in other model families like Llama or Mistral.
  • Linguistic Proximity: The evaluation was limited to English and Spanish, both Indo-European languages that share similar subject-verb-object typologies. Future work is required to determine if this language-independent circuit holds true for typologically distant languages, such as Mandarin, Arabic, or Basque.

Summary updated

BibTeX
@inproceedings{ferrando2024similarity,
  author = {Javier Ferrando and Marta R. Costa-jussà},
  title = {{On the Similarity of Circuits across Languages: a Case Study on the Subject-verb Agreement Task}},
  booktitle = {MI @ ICML},
  year = {2024},
  url = {https://openreview.net/forum?id=uS8YXfnsqC},
}
Figure