Cross-Lingual Transfer and Alignment › Alignment Objectives
Language AI HandbookAll chapters Alignment objectives give the optimizer a direct signal about which representations or predictions should agree across languages. In the examples below, some objectives supply a paired translation as an extra source of context, and others train a model to rank translations ahead of mismatches. Compare these approaches on the language pair and task you intend to use.
Translation Language Modeling
XLM introduced translation language modeling (TLM) as a version of masked language modeling for parallel data. Join a sentence and its translation, mask tokens in both, and use the available context from either language to predict the masked tokens. XLM, §3.4
For example, pair "The cat [MASK] on the mat" with "Le chat s'est assis [MASK] le tapis." The French verb can help recover the missing English verb, and the English preposition can help recover the masked French preposition. XLM resets the position indices for the target sentence, and a token in either half can attend to the other half.
The loss is still cross-entropy over the vocabulary at each masked position. The difference is the context used to compute the logits. The masked English position can now draw on the French half, so improving those predictions rewards the model for using information in the translation.
Cross-lingual contrastive learning
Sentence-level contrastive learning scores whole sentences. Given a batch of pairs where is a sentence in one language and is its translation, the row-wise objective raises relative to for .
Given a batch of normalized anchor embeddings and target embeddings :
where is a temperature and is cosine similarity.
Each row compares the designated translation with the other candidates. With one candidate the loss is zero. With B>1, equal scores give log B. For example, when two targets in the batch are valid paraphrases of one anchor but only one is paired with it, the other still appears in the denominator as a competing candidate.
LaBSE uses a related contrastive recipe: bidirectional translation ranking with an additive-margin objective that subtracts the margin from the matched pair’s score during training. SONAR's text encoder uses a different recipe that combines translation, denoising autoencoding, and a mean squared error term between embeddings of paired translations. Both produce sentence embeddings for multilingual retrieval. LaBSE, §2 and SONAR, §5.5
Word alignment objectives
Sentence-level alignment supports retrieval and similarity. Word alignment is useful when the output needs to connect individual tokens across languages, for example when projecting NER tags through a parallel corpus. Statistical methods such as IBM Model 4, fast_align (Dyer et al. 2013), and eflomal fit alignment models to bitext and can return discrete links between words.
Embedding-based methods can score word correspondences before selecting discrete links. SimAlign uses pretrained multilingual embeddings and extracts links from token similarities without fitting an aligner on parallel training data. Awesome-align can fine-tune a multilingual encoder on parallel text. Its extraction code supports softmax and entmax thresholding. The paper also evaluated optimal transport, which was slower and performed worse in its comparison. SimAlign, §2.1, Awesome-align paper, §§2.1 and 4.2, and Awesome-align toolkit
Use word alignment diagnostics when the transfer task depends on projecting labels. Evaluate link quality and target-language tagging separately, and examine examples where the two results diverge.
Code-switching and mixed-language training
Code-switching augmentation mixes languages within a training example. Multilingual batch mixing changes which languages appear across the examples in a batch.
- Word substitution can produce a mixed sentence such as "Le chat sat on the mat."
- A batch can also combine complete monolingual sentences in different languages. If each example is a single sentence, each example in that batch can stay monolingual.
Use these as augmentation experiments at a named stage of training. A mixed example can still carry language cues. Measure convergence and task accuracy against a monolingual or unmixed control. Code-Switching and Mixed-Language Text develops these comparisons.
Sentence embedding alignment at scale
LASER, LaBSE, and SONAR all use parallel text, with different ways to make it useful. LASER learns sentence embeddings through multilingual translation. LaBSE ranks translations against other sentences in its batch. SONAR learns a fixed-size representation that its decoder can translate from, with an explicit distance penalty on translation pairs. For a retrieval task, compare how well each model ranks translations for the languages and domains you need. LASER
In a distillation setup, fit a student to approximate the teacher’s sentence embeddings on a chosen multilingual dataset. Validate which pairs the student preserves in the intended domain. In the implementation below, we specify the shared features directly so the downstream comparison has a controlled alignment mechanism.
When parallel text is available, compare TLM for token prediction with a contrastive objective for sentence retrieval. Both use paired sentences. With only monolingual text, shared multilingual pre-training is a starting point. Code-switching augmentation is another option if you have a source of cross-language substitutions, such as a bilingual lexicon.
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!