Gradient Vaccine: Investigating and Improving Multi-task Optimization in Massively Multilingual Models

Zirui Wang, Yulia Tsvetkov, Orhan Firat, Yuan Cao

In the world of Natural Language Processing, "massively multilingual" models are the current gold standard. Training one giant model to handle 100+ languages is more efficient than training 100 separate ones and, theoretically, allows knowledge to transfer from high-resource languages (like English) to low-resource ones (like Yoruba).

However, there is a catch: negative interference. When a model tries to learn many languages at once, the updates required for one language might directly contradict the updates needed for another. In their ICLR 2021 paper, researchers from Carnegie Mellon and Google AI propose a "Gradient Vaccine" to solve this optimization tug-of-war.

TL;DR

The authors discover that the similarity between task gradients in multilingual models closely mirrors linguistic proximity and correlates with final model performance. They introduce Gradient Vaccine (GradVac), an optimization strategy that adaptively aligns gradients between tasks to match their historical similarity, significantly reducing interference and boosting performance across translation and labeling tasks.

What Problem Does This Paper Address?

Multilingual training is essentially a Multi-Task Learning (MTL) problem where each language pair is a "task." The standard approach is "monolithic training"—shoving all data into one objective function. This often leads to a "black box" optimization process where different languages compete for model capacity.

Existing gradient-based MTL methods, like PCGrad (Project Conflicting Gradients), try to fix this by "surgery": if two gradients point in opposite directions (negative cosine similarity), they project one onto the normal plane of the other to stop them from fighting.

The authors argue this is too simplistic. PCGrad only acts when gradients are conflicting and sets a target similarity of zero. But what if two languages (like Spanish and Italian) should have highly similar gradients? Setting their target to zero actually ignores their natural linguistic relationship.

Methods

The authors first peek into the "black box" by measuring the cosine similarity of gradients across different languages during training. They find that loss function geometry isn't random—it follows linguistic patterns.

Gradient similarity across languages closely mirrors linguistic family trees.

The Gradient Vaccine (GradVac)

To leverage this, they propose GradVac. Unlike PCGrad, which is reactive, GradVac is preemptive.

  1. Tracking Similarity: The algorithm uses an Exponential Moving Average (EMA) to track the "normal" gradient similarity ($\phi_{ij}$) between any two tasks $i$ and $j$ at specific layers.
  2. Setting the Target: It sets an adaptive target similarity ($\phi^T_{ij}$). If the current gradients are less similar than the historical average, GradVac intervenes.
  3. The "Vaccination" Update: Using a derivation based on the Law of Sines, GradVac alters both the magnitude and direction of the gradients to nudge them toward the target similarity.

Essentially, if the model "forgets" how similar two related languages should be, GradVac "vaccinates" the update to restore that alignment.

Datasets

The researchers tested their method on three scales:

  • WMT (Small scale): 8 language pairs (e.g., English to/from French, Czech, Hindi, Turkish).
  • Massive Internal Dataset (Large scale): 25 languages (50 language pairs) across 10 diverse language families, totaling over 8 billion sentence pairs.
  • XTREME Benchmark: Evaluation on downstream tasks like Named Entity Recognition (NER) and Part-of-Speech (POS) tagging using a pretrained mBERT model.

Key Insights and Ideas

  • Gradients are Linguistically Aware: Gradient similarity is a proxy for language proximity. Slavic languages cluster together; Romance languages cluster together. This means the model's optimization path naturally "knows" about linguistics.
  • The Direction Matters: Gradients for "Any$\to$English" (many sources, one target) are much more similar than "English$\to$Any" (one source, many targets). This explains why the latter is traditionally much harder to train—the decoder has to handle vastly different label spaces, leading to more gradient conflict.
Gradient similarity is higher for Any-to-English than English-to-Any, and correlates strongly with BLEU scores.
  • Batch Size and Geometry: Larger batch sizes don't just provide more data; they actually produce "cleaner" loss geometries that better reflect language proximities, leading to better cross-lingual transfer.

Key Results

GradVac consistently outperformed monolithic training and other state-of-the-art MTL baselines (GradNorm, MGDA, PCGrad):

  • Machine Translation: On the WMT dataset, GradVac achieved an average gain of +1.41 BLEU over the multilingual baseline. On the massive 25-language dataset, it improved performance across the board, especially for high-resource languages where interference is most common.
  • Labeling Tasks: On the XTREME benchmark, GradVac improved the F1 score for NER and POS tasks across almost all tested languages compared to naive fine-tuning.
  • Ablation: The authors showed that applying GradVac layer-by-layer (fine-grained) is significantly better than applying it to the model as a whole (coarse-grained).

Limitations and Future Work

  • Computational Complexity: Calculating pairwise gradients for $N$ tasks can be expensive ($O(N^2)$). While the authors use sampling and layer-wise updates to mitigate this, scaling to hundreds of languages simultaneously remains a challenge.
  • Heuristic Targets: The current method relies on an EMA of past similarities to set targets. Future work could explore using external linguistic knowledge (like URIEL language features) to set these targets more explicitly.
  • Beyond Text: While focused on multilingual NLP, the authors suggest these "geometric alignment" principles could apply to any multi-task setting, such as multi-modal learning or multi-agent reinforcement learning.

Summary updated

BibTeX
@inproceedings{wang2021gradient,
  author = {Zirui Wang and Yulia Tsvetkov and Orhan Firat and Yuan Cao},
  title = {{Gradient Vaccine: Investigating and Improving Multi-task Optimization in Massively Multilingual Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2021},
}
Figure