wikillm

Paper · 2021-06-09 · cs.CL, cs.LG

Low-Dimensional Structure in the Space of Language Representations is Reflected in Brain Responses

Maps 100 language feature spaces (word embeddings, LM and MT layers, taggers) by how well each transfers to the others, using linear encoder-decoder pairs and a pairwise tournament. The leading dimension runs from word embeddings to the next-word embedding. The embedding predicts which feature spaces fit fMRI responses to stories (author-reported: matched over 90% of the time).

Transfer learningLinear probingWord embeddingfMRI encoding modelrepresentation-analysisencoding-modelstransfer-learningneuroscience

arXivPDFCodeMarkdown11 min read

AI-compiled by claude-haiku-5-5 on 2026-11-05, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.

In plain words

Language models, translation systems and simple tagging tools all turn words into internal numbers. People usually describe those numbers with loose labels such as "syntactic", "semantic" or "low-level". This paper asks whether the set of such internal representations has a measurable shape, and it answers yes.

The method compares representations by how well one can be used to predict another. Each representation is squeezed through a small linear bottleneck, and then every pair is tested as a predictor of the other. Scores from those tests place all 100 representations on a shared map. On that map the representations form a trail that runs from plain word embeddings to the embedding of the next word, passing through the middle layers of language models.

The same map helps explain brain recordings. When people listen to stories while their brains are scanned, some representations predict the scans better than others. The paper finds that the map can match each representation to its pattern of brain fit. This suggests that the map picks up something real about how language is represented, though the authors state that this is a suggestion, not a proof.

TL;DR

  • Builds a "language representation embedding" for 100 feature spaces by measuring how well each one's bottleneck latent predicts each other representation §3 app. F.
  • The first principal dimension runs from word embeddings and early layers to the next-word embedding, and the second shows a middle-layer peak §4.1 fig. 2.
  • The embedding predicts which feature spaces fit fMRI encoding models, with author-reported matching above 90% for every representation §4.2.4 fig. 4.
  • Code is partial: the official repo has only the analysis notebook (GPL-3.0). The encoder and decoder training and the encoding-model code are not released.

Problem

Qualitative labels for representations are common, but the paper argues they assume an unstated low-dimensional structure §1. The authors want a quantitative map of how representations relate, so that the labels can be checked against it §1 §2.

The method needs a set of feature spaces that all come from the same stimuli, so that each can be paired with each other §3. It also needs one encoder and one decoder per pair, which for n representations means n² decoders §3.2. The paper uses n = 100, so 10,000 decoders §3.2 §4.1.

Method

Prose overview. Each representation t is a function from a stimulus to one feature vector per word §3. The method runs in three parts §3 fig. 1:

  1. Encoders §3.1. Map a shared universal input U(S) to a 20-dimensional linear latent space, one encoder per representation. The paper uses GloVe word embeddings for U(S). The decoder half of the training network is then dropped, and only the encoder half is kept. Latent size 20 is chosen as small, and the authors report that size changes do not matter much §3.1.
  2. Decoders §3.2. For each ordered pair of representations (source, target), train a linear decoder from the source's frozen latent space to the target. All n² pairs are trained, including source equal to target app. E.
  3. Tournament and ranking §3.3 app. F. For each target t, compare the decoders that point at t on a held-out test story. For each ordered pair (i, j), count the test samples where decoder i has lower error than decoder j, and divide by the count where it does not. Use this ratio matrix W_t. Its principal eigenvector, normalised to sum to 1, scores each source's transfer to t. Store that score vector as one row of the embedding matrix R, and set the entry at the target's own position to 0.1 §3.3 fig. 2.

The embedding matrix R (n × n) has one row per target and one column per source fig. 2. The main diagonal is fixed to 0.1 after normalisation, so row sums are only approximately 1 §3.3 Representation_Embeddings_Tutorial.ipynb.

Mapping step §4.1.1. Rows of R are weighted so that each full model counts equally, then multidimensional scaling is applied §4.1.1 fig. 2. The paper does not name the distance; see Paper vs code. The paper reports the first two MDS dimensions and an eigenvalue scree plot fig. 2 §4.1.1.

Brain step §4.2. Ridge encoding models predict each voxel's fMRI response from each representation, with time delays §4.2.2. The vector of encoding-model correlations for each voxel is z-scored across the 100 representations §4.2.3. Each voxel is projected on the first MDS dimension §4.2.3 fig. 3.

Matching test §4.2.4. For each pair of representations (i, j), a linear regression is trained on the embedding rows of the other 98 representations, as a map from embedding row to correlation vector. Each held-out row is then used to predict the held-out correlation vectors. A discriminability score is positive when the correct pairs match better than the swapped pairs §4.2.4 fig. 4.

Equations. The paper states its equations inline or as unnumbered displays, so this card cites them by section: the transfer mapping and the encoder objective §3, the tournament ratio §3.3, the encoding model and its correlation criterion §4.2.2, and the discriminability score §4.2.4. The paper has no numbered equations to cite.

Pseudocode
# Language representation embedding  [§3] [fig. 1]
# Input:  representations (n), universal inputs U(S), stimuli S
# Output: embedding matrix R (n x n)

def build_embedding(reps, U):
    # One bottlenecked linear encoder per representation  [§3.1]
    latents = {}
    for t in reps:
        encoder = train_linear_bottleneck(U, target=t, latent_dim=20)
        latents[t] = encoder(U)

    # One linear decoder per ordered pair, including same-task pairs  [§3.2] [app. E]
    errors = {}
    for source in reps:
        for target in reps:
            decoder = train_linear_decoder(latents[source], target)
            errors[source, target] = squared_error(decoder, held_out)

    # Tournament per target, then principal eigenvector  [§3.3] [app. F]
    R = zeros(n, n)
    for target in reps:
        wins = tournament_ratio(errors, target)      # (n, n) with zero diagonal
        scores = principal_eigenvector(wins)         # normalised to sum 1
        R[row_of(target)] = scores
        R[row_of(target), col_of(target)] = 0.1      # main diagonal  [§3.3]
    return R

Hyperparameters

Values stated in the paper are given with their location. Values that appear only in the code or are missing are marked.

NameValueWhereNotes
universal input U(S)GloVe word embeddings§3.1 fig. 1300-dim per app. A; one-hot or word vectors are alternatives the paper mentions
latent dimension20§3.1search set 10, 20, 50 in app. E; results "did not vary significantly" app. E
optimiserstochastic gradient descent§3.2 app. Emomentum, weight decay: not stated
encoder learning rate1e-4§3.2search set in app. E
decoder learning rate2e-5§3.2search set in app. E
batch size1024§3.2search set 256, 512, 1024 app. E
encoder lossnegative correlation coefficientapp. Enot stated in the main text
decoder lossmean squared errorapp. E §3.3decoders are retrained after encoders
early stopping1000 batches, or the first batch where loss fails to improveapp. E"whichever comes first" is ambiguous, see Pitfalls
hyperparameter searchcoordinate descentapp. Eexact stopping rule for the search: not stated
context window for extraction64 words, slidingapp. A
tournament diagonal0app. Fcode uses 0.0001 for the target's own column, see Paper vs code
tournament epsilonnot stated—code adds 0.0001 to the denominator L204
affinity main diagonal0.1§3.3 fig. 2
encoding delays2, 4, 6, 8 s§4.2.2with TR 2.00 s these are 1 to 4 TRs (derived)
repetition time (TR)2.00 s§4.2.1
ridge parameter αchosen per voxel by 50-fold Monte Carlo CV§4.2.220% validation split; α grid not stated
voxel selectionwithin 8 mm of mid-cortical surface§4.2.1about 90,000 voxels per subject
noise-ceiling filtermean-explainable variance ≥ 0.05§4.2.1
encoding training dataabout 5 h, 9,189 datapoints per voxel§4.2.1five subjects
test storyone story, 1,839 wordsapp. B §4.2.1
leave-two-out training pairs98§4.2.4r_k is 196-dim: two rows and columns of 100, less 4
z-scoringacross the 100 representations§4.2.3
MDS weightingeach full model weighted equally§4.1.1 fig. 2
extraction corpusabout 54,000 words, The Moth stories§4.1
computeabout one week on 53 GPUs and 64 CPU servers§4.1

Representation families app. A:

FamilyCountDim per layerNote
word embeddings: GloVe, BERT-E, FLAIR3300, 3072, 4096
tagger logits: POS, CHUNK, NER, FRAME453, 45, 76, 5196pre-softmax logits
next-word GloVe (NWE)1300GloVe shifted one word ahead
GPT-2 Small12768
GPT-2 Medium241024
Transformer-XL181024
BERT13768includes the input encoding
ALBERT13768includes the input encoding
Eng→Zh and Eng→De MT encoders6 + 6512

Results

Author-reported. Setup: 100 feature spaces, five subjects who listened to English podcast stories while being scanned with fMRI §4.2.1. Baseline: none reported, because the comparisons are between representations; the matching test is a two-way choice §4.2.4.

SettingMetricBaselineThis paperSource
representation embedding, first dimension (EFA)variance explainednot stated22%§4.1.1 fig. 2
representation embedding, second dimensionvariance explainednot stated10%fig. 2
first MDS dimension, as stated in the brain figurevariance explainednot statedabout 20%fig. 3 (conflicts with 22%)
leading dimension orderingqualitative—word embeddings and early layers at one end; next-word embedding at the other§4.1.1 fig. 2
LM trajectoriesqualitative—layers of unidirectional LMs trace similar paths§4.1.1
encoding-model matchingshare of representations matched correctly on ≥3 of 5 subjectsnot statedover 90% for all representations; 100% for most§4.2.4 fig. 4
encoding-model fitqualitative ranking—intermediate layers of Transformer LMs work bestfig. 4
voxel projection on first MDS dimensionqualitative—AG and PrCu most positive; AC negative§4.2.3

Paper vs code

The official repository is HuthLab/rep_structure, at commit 5502d90897d3534bbf2b7af8e27ecf8c9785f8d0 §4.1 [code]. Alexander Huth is an author of the paper. The repository is licensed GPL-3.0. Code is cited by path and line only; no code is quoted.

The repository contains one notebook, Representation_Embeddings_Tutorial.ipynb, plus a README and an MDS plotting helper. It loads precomputed per-sample error data from a file that is not in the repository (Figshare), and it covers only the analysis from the tournament onward to the plot Representation_Embeddings_Tutorial.ipynb Representation_Embeddings_Tutorial.ipynb. The encoder and decoder training, the encoding-model fits and the matching test are not in the repository, so their hyperparameters can only be checked against the paper.

Discrepancies:

Pitfalls

  • Ridge grid and loss are unstated. The α grid for the ridge regressions and the exact correlation criterion used during fitting are not stated §4.2.2.
  • Early stopping is ambiguous. The paper caps training at 1000 batches and also stops at the first batch with no loss improvement app. E. Reading the second rule as patience of one is one option; the paper does not define a patience value.
  • Learning-rate search set. The stated search includes 1e-4 twice in the set of five values app. E. The main text uses 1e-4 for encoders and 2e-5 for decoders §3.2. Implementers should use the main-text values.
  • Two loss functions. The encoder-decoder pretraining uses a negative correlation coefficient loss, and the retrained decoders use MSE app. E. The main text (§3) does not mention the first loss, so an implementation following only the main text will differ.
  • Decoder retraining. All decoders are retrained after the encoder stage, including same-task decoders, so that comparisons are consistent app. E. Skipping that retraining changes the tournament.
  • Numerically sensitive ratio. The tournament entries are ratios of counts with a small epsilon in the denominator Representation_Embeddings_Tutorial.ipynb. When one side has zero count, the ratio is set by the epsilon and can be very large, and this feeds the eigenvector.
  • Eigenvector shortcut. The eigenvector step depends on the normalisation choice and not only on the paper's description Representation_Embeddings_Tutorial.ipynb.
  • Orientation of R. The paper's text says the vectors are stacked into R, while the figure and appendix caption say rows correspond to the target. The notebook puts each target's vector in its own row Representation_Embeddings_Tutorial.ipynb.
  • Inconsistent first-dimension variance. The text gives 22% for the first dimension §4.1.1, while the brain figure says about 20% fig. 3.
  • Choice of representations. The authors state that the embedding is only as good as the sampled set of 100 representations, and that unsampled parts of the space could change the picture §5.
  • Universal input is an approximation. GloVe stands in for a universal input, and the authors say it is not truly universal §5.
  • Linear limit. All encoders and decoders are linear, which the authors say may underestimate relatedness §5.
  • Cost. About one week on 53 GPUs and 64 CPU servers, with n² = 10,000 decoders §4.1 §3.2.
  • Temporal resolution. The authors attribute negative scores for GloVe next-word embedding to the coarse timing of BOLD responses, which makes it nearly identical to plain GloVe for brain data §4.2.4. This is the authors' explanation, not a tested result.
  • Small sample. Five subjects, one test story, and the brain analysis depends on the specific stimuli §4.2.1 app. B.

Lineage

  • Builds on: the encoder-decoder transfer method for vision tasks, from Zamir et al. (CVPR 2018), with the analytic hierarchy process for ranking §2 §3. No card in this wiki, so not linked.
  • Compared against: none. The paper compares feature spaces to each other and to brain data, not to other embedding methods §2.
  • Related encoding-model work the paper cites: Huth et al. 2016, Schrimpf et al. 2020, Jain & Huth 2018, and Jain et al. 2020 §2. No cards in this wiki, so not linked.

Source and license

Adapted from “Low-Dimensional Structure in the Space of Language Representations is Reflected in Brain Responses” by Richard Antonello, Javier Turek, Vy Vo, Alexander Huth (arXiv:2106.05426), used under CC BY 4.0. Changes: condensed and restructured for implementation, with tables, equations and algorithms taken from the paper and its code, each cited to its source. Not affiliated with or endorsed by the authors. Code citations refer to https://github.com/HuthLab/rep_structure at commit 5502d90897d3 (GPL-3.0). Any quoted code is shown under that license.