﻿# MAD-X: swapping language adapters while retaining a learned task adapter

Understand MAD-X language and task modules, invertible embedding transformations and what zero-shot cross-lingual transfer must actually evaluate.

Author: Retrivium editorial team
Updated: 2026-11-03
Canonical URL: https://retrivium.ai/journal/guide-madx-language-task-adapter-stack/
Language: en

MAD-X is a modular framework for cross-lingual transfer that separates language adapters from task adapters. A language module learns from language-modeling data, while a task module learns a supervised problem. At transfer time, the language adapter can be replaced while retaining the task adapter, aiming to reuse task knowledge across languages.

## Follow the training sequence

Language adaptation and task adaptation have different supervision. Preserve which language corpus trains the language module and which labeled dataset trains the task module. The source-language task stage uses a particular stack, so changing that stack is part of the experiment rather than an incidental inference setting. Record the exact module order.

## Understand the invertible component

The framework includes language-specific invertible transformations near the embedding interface, alongside bottleneck language adapters. AdapterHub describes using the transformation in the forward direction before transformer layers and its inverse at the corresponding output side. This architectural relationship differs from attaching an unrelated multilingual text prompt or changing the tokenizer vocabulary.

## Keep tokenization compatibility explicit

Swapping language modules does not automatically give the frozen base adequate vocabulary coverage or fix every segmentation problem. Inspect representative target-language inputs and their tokenization. For an illustrative entity-recognition transfer, keep label definitions and span reconstruction consistent; a boundary mismatch can damage evaluation independently of the adapter's ability to represent the language.

## Evaluate the zero-shot claim precisely

Zero-shot cross-lingual transfer concerns the absence of labeled target-task training in the stated setting. It does not mean that the target language was absent from all pretraining or language-adapter training. Report these exposures separately. Compare a source-language stack, the target-language stack and an appropriate multilingual baseline on genuinely held-out target-language examples.

## Save the stack as a deployable object

Retain language and task adapter weights, invertible component, active order, prediction head, tokenizer and base revision. A collection of files without the composition rule is incomplete. Test a fresh load for each intended language and measure the added modules in the actual runtime. MAD-X is useful when this separation supports reproducible language transfer, rather than when modular names merely suggest that components should combine.

## Primary references

[MAD-X original paper](https://arxiv.org/abs/2005.00052).

[AdapterHub method architectures](https://docs.adapterhub.ml/methods.html).

[AdapterHub library](https://github.com/adapter-hub/adapters).

Related explanations: [task identity and adapter stacks](/journal/adapter-composition-task-identity/); [tokenization and vocabulary](/journal/tokenizer-artifact-release-manifest/).
