Source-linked AI summary
The Hidden Space of Transformer Language Adapters
Jesujoba O. Alabi, Marius Mosbach, Matan Eyal, Dietrich Klakow, Mor Geva
TL;DR
The internal operation of language adapters remains poorly understood, although understanding it could inform language selection and adaptation design. The paper analyzes adapted predictions, adapter updates, and representation structure, finding that predictions largely evolve in source-language distributions before shifting toward target languages late in computation.
Problem
How language adapters alter pretrained language-model predictions internally remains largely unknown, despite its relevance to language selection and adaptation design.
Source: §1 · p. 1Method
The paper analyzes layerwise prediction changes, adapter contributions, feature interventions, and principal components across adapted language models.
Source: §1 · pp. 1–2Results
Adapted predictions mostly evolve in pretrained source-language distributions before shifting toward target languages late, while representation analyses indicate preserved structure.
Source: §1 · pp. 1–2, §7 · p. 9Takeaways & Limitations
Adapters operate on the pretrained representation structure, and gradual updates can allow small adapter groups to be skipped without reducing adaptation performance.
Source: §1 · pp. 1–2Most experiments use relatively small-corpus models trained from scratch; extending the analyses to existing multilingual models such as mGPT is left for future work.
Source: Limitations · p. 9
Abstract
from arXiv · showhide
We analyze the operation of transformer language adapters, which are small modules trained on top of a frozen language model to adapt its predictions to new target languages. We show that adapted predictions mostly evolve in the source language the model was trained on, while the target language becomes pronounced only in the very last layers of the model. Moreover, the adaptation process is gradual and distributed across layers, where it is possible to skip small groups of adapters without decreasing adaptation performance. Last, we show that adapters operate on top of the model's frozen representation space while largely preserving its structure, rather than on an 'isolated' subspace. Our findings provide a deeper view into the adaptation process of language models to new languages, showcasing the constraints imposed on it by the underlying model and introduces practical implications to enhance its efficiency.
1 Introduction
How language adapters alter predictions internally remains largely unknown, despite their value for language selection and adaptation design. The paper finds that adaptation shifts predictions gradually from source-language representations toward target languages while largely preserving the existing representation structure.
1 Introduction
- The study examines adapters across monolingual, bilingual, and multilingual pretrained models, adapting an English-trained decoder-only model to four target languages.The target languages are German, French, Hebrew, and Arabic; mBERT is included to test generality.Source: §1 · p. 1
- The target-language shift is concentrated in the final layers, while earlier adapter updates are gradual and some small groups can be skipped without performance loss.The last few adapter layers are critical for adaptation success.Source: §1 · p. 1
- Intervening on both the most-changed and random features substantially lowers adaptation performance, refuting the hypothesis that adapters use an isolated, prediction-unused subspace.The paper identifies the most-changed features with sparse probing classifiers.Source: §1 · pp. 1–2
- Principal components for properties including part of speech, number, and tense show strong alignment between the original and adapted representation spaces.Source: §1 · p. 2
- Across layers, adapted predictions evolve mostly in the source-language distribution and shift toward the target language only at the end of computation.The paper examines this pattern alongside adapter contributions and representation-space structure.Source: §1 · pp. 1–2
2 Experimental setup
The experiments adapt pretrained language models by training adapters while keeping most pretrained weights frozen. The setup combines controlled models trained from scratch with additional analyses of LoRA and mBERT.
2 Experimental setup
- The base decoder-only model follows GPT-NeoX, with 24 layers, 16 attention heads per layer, hidden size 1024, and a 250K-token vocabulary.Source: §2 · p. 2
- The study uses an English-trained decoder-only model and adapts it separately to Arabic, English, French, German, and Hebrew.A bilingual English–German model is also trained for analyses in Section 3.Source: §2 · p. 2
- Pfeiffer adapters are placed after each decoder block’s feed-forward network and add an update to each hidden state through a residual connection.The adapter is a low-dimensional-bottleneck feed-forward network.Source: §2 · pp. 2–3
- The analysis also applies LoRA to feed-forward layers and evaluates language data from Wikipedia, FLORES-101, and selected Universal Dependencies and morphosyntactic datasets.The setup additionally notes that invertible adapters require tied input and output embeddings, which this model does not have.Source: §2 · p. 3
- During adaptation, pretrained weights are frozen except for the input and output embeddings, which are trained alongside adapters.Training embeddings is necessary for the English-only base model and improves adaptation performance.Source: §2 · p. 3
3 Adapted predictions evolve in the source language
Layerwise vocabulary projections show that adapted predictions remain mostly in the source-language distribution through much of inference. Target-language tokens rise sharply near the final layers, with the timing of earlier increases varying by model.
3 Adapted predictions evolve in the source language
- The layerwise analysis projects hidden representations to vocabulary space and classifies top-k predicted tokens by language.Language identification uses script for Arabic and Hebrew and token statistics for English, German, and French.Source: §3 · p. 3
- For English-only models adapted to each target language, target-language tokens remain limited from the second layer through the penultimate layers, then rise dramatically in the final two layers.The same trend appears with LoRA; the figure plots the fraction of target-language tokens among the top 10 predicted tokens.Source: §3 · p. 4
- With 1% German data added to English pretraining, German tokens are more frequent in middle layers, but most predictions remain in the source language until the final two layers.Source: §3 · p. 4
- For mBERT, target-language tokens reach up to 60% of top projected tokens in middle layers, followed by a dramatic increase at the final layer.The authors attribute the earlier middle-layer increase potentially to mBERT’s multilingual representation space.Source: §3 · p. 4
4 The adaptation process is distributed across layers
The section examines how adapter updates build across layers and how much adaptation performance depends on particular adapters. Updates are generally gradual, but the final adapters and removals of larger groups—especially for more distant target languages—matter more.
4.1 Adapters gradually steer the prediction
- Adapter outputs are smaller than residual-stream representations, similar in magnitude to FFN outputs, and larger in the final layers for Arabic and Hebrew than for German and French.The larger late-layer norms for Arabic and Hebrew suggest that larger updates are needed for these more distant languages.Source: §4.1 · p. 4, Figure 2 · p. 5
4.2 Adapters often can be removed with only a small effect on perplexity
- Removing individual adapters usually has little effect on perplexity, except that removing either of the last two raises it above 100 across languages.The sensitivity of the last two layers aligns with the largest increase in target-language tokens occurring at the final layer.Source: §4.2 · p. 5, Figure 3 · p. 5
- For most layers, removing three consecutive adapters increases perplexity by up to 25 points for Arabic and Hebrew, versus less than 10 points for German and French.Perplexity increases further with more removed adapters and more distant target languages; the authors hypothesize that adapters for more distant languages have a more profound impact.Source: §4.2 · p. 5
5 Two adaptation hypotheses
The authors test whether adapters use an isolated residual-stream subspace or modify the pretrained model’s existing representation structure. Their results reject an adapter-exclusive subspace and indicate that the existing structure is largely preserved.
5 Two adaptation hypotheses
- Across source-to-target adaptation, predictions remain strongly shaped by the source-language distribution through most layers, while target-language tokens become pronounced in the final layers; adaptation is harder for Hebrew and Arabic than for German and French.The authors associate the latter difference with English’s linguistic and etymological connections to German and French, and with the linguistic and orthographic differences of Arabic and Hebrew.Source: §5 · pp. 5–6
5.1 Do adapters operate in an isolated subspace of the residual stream?
- Sparse probes predict whether representations have been adapted, with higher accuracy for Hebrew and Arabic than for German and French.This supports the finding that adaptation is more pronounced in the underlying representations for Hebrew and Arabic.Source: §5.1 · p. 6, Figure 4 · p. 6
- Intervening on important, least-important, or random adapter-output features substantially increases perplexity, contradicting an isolated subspace used uniquely by adapters.The intervention results do not rule out a subspace; they show that it is not uniquely used by adapters.Source: §5.1 · pp. 6–7, Figure 5 · p. 7
5.2 Adapters largely preserve the structure of the underlying model
- English-derived projections reveal similar part-of-speech structure in German and French representations, and principal components align across languages with absolute cosine similarity of about 0.6.The authors conclude that adapters modify the pretrained representation structure and are constrained by it; more drastic changes require more adaptation.Source: §5.2 · p. 7
6 Related work
Prior work studies language adaptation, transformer prediction formation, multilingual representations, and adapters, but leaves the internal operation of language adapters comparatively underexplored. This paper situates its analysis at the intersection of those topics.
Language adaptation and adapters
- Language adaptation has shifted from continued or adaptive pretraining toward parameter-efficient approaches, while prior adapter studies address dropping, representation deviation, and downstream transfer.The paper frames its work as investigating the adaptation process through adapters.Source: §6 · pp. 7–8
How transformer-based LMs build predictions
- Prior transformer studies examine prediction evolution, including how FFN layers gradually promote vocabulary-interpretable concepts; this paper instead analyzes how adapters steer frozen-model predictions.Geva et al. (2021, 2022b) showed that FFN layers gradually build predictions by promoting interpretable concepts.Source: §6 · pp. 7–8
Analyzing multilingual language models
- Research on multilingual LMs has found language-agnostic representations for cross-lingual transfer, while few studies have examined adapters’ specific role during adaptation.The cited language-agnostic representation findings include Pires et al. (2019), Libovický et al. (2020), Muller et al. (2021), Zhao et al. (2021), Xie et al. (2022), Chang et al. (2022), and Abdullah et al. (2023).Source: §6 · p. 8
7 Conclusion and Discussion
The paper concludes that language adaptation with adapters is gradual and builds on pretrained representation structure. It presents these findings as a basis for future work on adaptation efficiency and language transfer.
Conclusion and Discussion
- Across monolingual, bilingual, and multilingual pretrained LMs, adaptation occurs gradually on top of the underlying representation structure.The authors describe this as a perspective on the inner workings of language adaptation and an avenue for future work.Source: §7 · p. 9
- Adapted predictions are mostly evolved in the distribution of the source language or languages seen during pretraining.Source: §7 · p. 9
- Future work could use the relationship between adaptation ease and source-target similarity to reduce inference-time adapters or study transfer across languages.The authors also propose examining how representation-space alignment constrains adaptation and whether less constrained approaches could improve performance on languages more distant from the source.Source: §7 · p. 9
Limitations
The analysis is bounded by its training setup, an approximate probe of intermediate representations, and coverage of eight target languages.
Limitations
- Most experiments use models trained from scratch on a relatively small corpus, leaving extension to existing multilingual models such as mGPT for future work.The authors describe that extension as a valuable, non-trivial effort.Source: Limitations · p. 9
- Hidden-state projections to vocabulary space approximate the information in intermediate representations, although this alone is unlikely to explain the low rate of target-language tokens.The authors note that the rate is also low in middle-upper layers, where the approximation is better.Source: Limitations · p. 9
- The experiments cover eight specific target languages, with analysis beyond those languages left for future work.Source: Limitations · p. 9
A Details on model training
The training pipeline uses Wikipedia-derived multilingual data and a shared BPE tokenizer, then selects adapters by validation perplexity.
A Details on model training
- Wikipedia data was extracted with WikiExtractor, filtered using OpenLID, and used to train a shared 250K-vocabulary BPE tokenizer from 4M sentences per language.The resulting tokenizer was trained on 20M sentences total.Source: A Details on model training · p. 13
- Pretraining and adaptation data were sampled uniformly by token count across languages using the shared tokenizer.Source: A Details on model training · p. 13
- Adapters were trained for 150K steps, with the checkpoint chosen for lowest validation perplexity among evaluations every 5,000 steps.Source: A Details on model training · p. 13
B Details on pre-training and adaptation token statistics
The token-statistics setup equalizes sampled training data across languages and reserves separate development portions for the main and mBERT experiments.
B Details on pre-training and adaptation token statistics
- Approximately 145M Hebrew tokens set the equal-token sampling target for other languages; 2% of data was reserved for development.The remaining data was used for training or adaptation.Source: B Details on pre-training and… · p. 13
- For the mBERT experiment, 4 million tokens were sampled from all languages, with 5% reserved as the development set for each language.Source: B Details on pre-training and… · p. 13
C Details of language token identification
These appendix sections detail language identification, mBERT language selection, and LoRA setup, then report adapter-removal and feature-intervention results. They also describe sparse probing used to identify adaptation-related features.
C Details of language token identification
- For French and German token identification, the predominant language is selected by token frequency, with a token assigned to it when the English-to-language occurrence ratio is at most 0.7.The threshold was set through manual inspection.Source: C Details of language token… · p. 13
D Details on mBERT’s language converge
- For mBERT, Amharic and Santali have the highest UNK rates among the four selected languages whose scripts are not adequately represented.The languages were selected from FLORES based on scripts distinct from those covered by mBERT.Source: D Details on mBERT’s language converge · p. 13, Table 2 · p. 13
E.2 Details on identifying features critical for adaptation
- Sparse probing classifiers detect adaptation with high accuracy using layer-output examples and features ranked by their differences between adapted and non-adapted representations.The experiments use two cases for constructing negative examples and select top-k features for logistic-regression probes.Source: Figure 8 · p. 14, §E.2 · pp. 14–15
D.1 LoRA Adapters
- LoRA adapters are added to decoder-block FFN sublayers; adaptation updates LoRA and embedding parameters while keeping the other model parameters frozen.LoRA uses rank-decomposition matrices without a nonlinearity between them.Source: §D.1 · p. 14
E.1 Effect of removing adapters on perplexity
- Removing individual adapters has little perplexity impact, while removing larger consecutive chunks affects perplexity considerably in both mBERT and LoRA settings.For mBERT, the increase is generally less dramatic than in Figure 3, which the authors attribute to its optimization and the relative ease of masked language modeling.Source: §E.1 · p. 14, Figure 9 · p. 15, Figure 10 · p. 15
E.3 More results on intervening on critical features increases perplexity
- Intervening on the most important features causes the largest perplexity increase, but least-important and randomly selected features also cause considerable increases.The alternative intervention replaces selected features with average values of the remaining features.Source: §E.3 · p. 15
E.4 More results on adapters largely preserve the structure of the underlying model
The section compares linguistic structure in English representations with German and French representations using English-derived PCA projections. It reports alignment across part of speech, tense, and number features.
Tense and number
- English and target-language principal components also show large alignment for noun number and verb tense, supporting the hypothesis that adapters mostly operate on the pre-trained model’s existing structure.The English-derived PCA projection is applied to German and French representations for number and tense comparisons.Source: Figure 14 · p. 16, §E.4 · p. 16, Figure 17 · p. 19
Part of speech
- The first two principal components show high alignment between English and target-language representations for part-of-speech structure, with absolute cosine similarity ≈0.6 for LoRA.The projection matrix is computed from English representations and applied to German and French representations; LoRA projections show results similar to classical adapters.Source: §E.4 · pp. 15–16, Figure 15 · p. 17, Figure 16 · p. 18