Cross-Lingual Transfer and Alignment › Adapters and Parameter-Efficient Cross-Lingual Transfer

Michael BrenndoerferNovember 26, 20264 min read
Language AI HandbookAll chapters
Part 26 of 67Multilingual Language Models and Cross-Lingual Transfer
Chapter 186Cross-Lingual Transfer and Alignment › Adapters and Parameter-Efficient Cross-Lingual Transfer
Reading section 5 of 11 · Adapters and Parameter-Efficient Cross-Lingual Transfer · 4 minSection 5 of 11 · 4 min

Section 5 of 11 · 4 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

Full fine-tuning of a 500M-parameter multilingual model for each language and each task is expensive and awkward. The cost is paid in storage, deployment, and engineering. If every language requires its own full copy of the model, a deployment serving 50 languages needs 50 full-sized files, and updates have to be repeated everywhere. Adapters solve this by inserting small trainable modules while keeping the base model frozen.

The adapter idea

The bottleneck adapter considered here is a small residual module that can be added alongside a transformer sublayer.

Bottleneck Adapter

For hidden state x∈Rdx \in \mathbb{R}^{d}, a bottleneck adapter computes:

Adapter(x)=x+Wup σ(Wdownx)\text{Adapter}(x) = x + W_{\text{up}} \, \sigma(W_{\text{down}} x)

where Wdown∈Rdb×dW_{\text{down}} \in \mathbb{R}^{d_b \times d} projects down to a chosen bottleneck width dbd_b, σ\sigma is a nonlinearity, and WupW_{\text{up}} projects back up. The example below uses GELU and db=64d_b=64.

Houlsby et al. use task-specific adapters with a largely frozen pretrained model. The number of trainable parameters depends on bottleneck width, placement, and which other parameters are trained. The example below counts the weights and biases for its two projections. Report training time and memory separately. Houlsby et al. (2019)

MAD-X

MAD-X (Pfeiffer et al. 2020) separates language adapters from task adapters so that the same task adapter can be reused across languages. MAD-X, §§4.1–4.3

  • Language adapters. Train a language adapter with masked prediction on monolingual text. Measure the usable text available for each language.
  • Task adapters. One per task, trained with the task loss on source-language (typically English) data. They capture task-specific features.

During task training, MAD-X freezes the source language’s layer-wise adapters and invertible embedding adapter while learning the task adapter. At target inference, it switches both language-specific components and keeps the task adapter. The same task adapter can then serve languages with their own trained adapters.

Invertibility

MAD-X also learns a reversible transform at the embedding layer. Split an embedding into (e1,e2)(e_1,e_2) and compute o1=e1+F(e2)o_1=e_1+F(e_2) and o2=e2+G(o1)o_2=e_2+G(o_1). To recover the input, subtract in reverse order: e2=o2−G(o1)e_2=o_2-G(o_1) and e1=o1−F(e2)e_1=o_1-F(e_2). The same functions FF and GG serve in both directions. In masked language modeling, the forward transform follows the input embeddings and its inverse precedes the tied output embeddings. For zero-shot task inference, the target language supplies this input transform as well as the layer-wise adapters.

MAD-X keeps its language and task modules separate. For this kind of modular design, specify which modules to insert, where they go, and how they run together.

Language-agnostic and language-specific

Not every deployment has a language adapter per language. When a language is not covered, you have three options.

  • Try the adapter for another language and validate it on the target task. Choose candidates using lexical overlap, training coverage, or other measured criteria.
  • Apply the task adapter directly as a comparison. Report how that differs from the setup in which the task adapter was trained.
  • Train a new language adapter from available monolingual data. Compare the result and training cost with your other baselines.

Run the comparison on the actual target language. Script or morphology can help choose which to test. The measured result determines whether that adapter is suitable.

LoRA and modern alternatives

LoRA (Hu et al., 2022) freezes an existing weight matrix and fits a low-rank update. With their scaling convention for rank r,

W′=W+αrBAW' = W + \frac{\alpha}{r} B A

For a square d×dd\times d projection, A∈Rr×dA \in \mathbb{R}^{r \times d} and B∈Rd×rB \in \mathbb{R}^{d \times r} have 2dr2dr parameters, excluding any other trained parameters. The fixed scale is α/r\alpha/r. At inference, the update can be folded into the existing weight matrix. Hu et al. (2022), §4.1

Train and evaluate any language or task updates under the composition rule you intend to use. A sum of two weight updates is a different operation from stacking independently trained nonlinear bottleneck adapters.

Composition and adapter fusion

The reason modular adapters are interesting beyond parameter cost is composability. If you have:

  • Language adapters for French, German, and Japanese.
  • Task adapters for NER, sentiment, and QA.

You have nine cross-lingual task systems, from six trainable modules. Adding a new language or task costs one adapter, not one full model. The savings compound: adding a fourth language takes the system from nine to twelve combinations with a single new module, whereas a full-fine-tuning deployment would require three new full models.

AdapterFusion trains a composition layer over separately trained task adapters. It learns input-dependent weights over the adapter features in the original task-composition setting. Treat using language adapters this way as a separate experiment. Pfeiffer et al. (2021), §3

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy