LegoNN: Building Modular Encoder-Decoder Models

Siddharth Dalmia, Dmytro Okhonko, Mike Lewis, Sergey Edunov, Shinji Watanabe, Florian Metze, Luke Zettlemoyer, Abdelrahman Mohamed

TL;DR

LegoNN is a framework for building modular encoder-decoder architectures where components—like a high-resource English decoder—can be reused across different tasks (e.g., from Machine Translation to Speech Recognition) without mandatory fine-tuning. By grounding module interfaces in discrete vocabularies and using novel length-control mechanisms, LegoNN enables "plug-and-play" reusability and significant compute savings.

What Problem Does This Paper Address?

Current state-of-the-art models for tasks like Automatic Speech Recognition (ASR) and Machine Translation (MT) are typically monolithic. The encoder and decoder are trained as a single atomic unit, resulting in hidden representations that are "tightly coupled." These representations have no physical meaning and vary across different random seeds, architectures, and modalities.

This lack of modularity means you cannot easily take a decoder trained on a massive German-English translation dataset and plug it into a low-resource Romanian-English system or a speech-to-text system. Practitioners are forced to retrain large components from scratch for every new task, wasting compute and missing opportunities to leverage high-resource modules for low-resource domains.

Methods

The authors introduce three core innovations to enable "Lego-like" modularity:

  1. Interpretable Interfaces: Instead of passing abstract hidden vectors, the LegoNN encoder outputs a sequence of marginal distributions over a pre-defined discrete vocabulary (e.g., BPE tokens or phonemes). This interface is enforced during training using Connectionist Temporal Classification (CTC) loss, which acts as a "contract" ensuring the output remains interpretable and stable.
  2. Output Length Controller (OLC): Modalities have different natural lengths (e.g., audio frames are much denser than text tokens). The OLC uses a cross-attention mechanism to dynamically adapt the encoder's output length to match the expected input length of the subsequent module, making the encoder modality-agnostic.
  3. Ingestor Layers: To consume these probability distributions, the authors propose two types of "Ingestors" for the decoder:
  4. Weighted Embedding (WEmb): A differentiable approach that computes an expected embedding vector, allowing gradients to flow through the entire system.
  5. Beam Convolution (BeamConv): A gradient-isolating approach that uses only the top-p hypotheses, creating a robust information bottleneck.
LegoNN Architecture Schematics

Datasets

The framework was evaluated across several standard benchmarks:

  • Machine Translation: WMT En-De (4.5M pairs) for high-resource training; WMT16 Ro-En and WMT19 De-En for modularity tests.
  • Speech Recognition: Switchboard (300h) and HUB5 Eval2000 for performance benchmarks; Europarl-ST (70h) and TED-LIUM for cross-domain and modularity experiments.
  • Vocabularies: Shared 32K BPE for MT; 100 and 2000 SentencePiece units for ASR; and phonemes for multi-module ASR experiments.

Key Insights and Ideas

  • Grounding as a Contract: The use of CTC loss at the interface is crucial. Without it, the "modular" components fail to work when swapped, as they revert to the tight coupling seen in traditional models.
  • Zero-Shot Reusability: A decoder trained for German-to-English translation can be plugged into a Romanian-to-English encoder without any fine-tuning and still perform well, sometimes even outperforming a baseline trained from scratch because it leverages the superior language generation capabilities of the high-resource decoder.
  • Multi-Point Modularity: LegoNN isn't limited to just one encoder and one decoder. The authors successfully built an ASR system by chaining three independent modules: a phoneme recognizer, a pronunciation model, and a language generation decoder.
Modular Training vs Traditional Framework

Key Results

  • Competitive Performance: LegoNN models perform within 0.8 BLEU points of strong monolithic MT baselines and match baseline performance in ASR.
  • Effective Transfer: Reusing a De-En MT decoder for a Ro-En MT task improved performance by 1.5 BLEU points after fine-tuning.
  • Cross-Modality Success: An English ASR model using a reused MT decoder achieved a 12.5% relative Word Error Rate (WER) reduction over the baseline.
  • Efficiency: Training only the encoder for a new task (while reusing a decoder) significantly reduces GPU hours—for example, 13 hours vs. 22 hours for the Europarl ASR task.

Limitations and Future Work

  • Performance Gap: While competitive, there is still a small performance gap in MT compared to the absolute best monolithic models, likely due to the information bottleneck at the interface.
  • Vocabulary Sensitivity: The choice of interface vocabulary (size and units) is critical. A vocabulary that is too task-specific can hurt the reusability of the module in other domains.
  • Future Directions: The authors suggest combining LegoNN with large-scale pre-trained encoders (like BERT) and exploring zero-shot speech translation by composing ASR encoders with MT decoders.

Summary updated

BibTeX
@article{dalmia2023legonn,
  author = {Siddharth Dalmia and Dmytro Okhonko and Mike Lewis and Sergey Edunov and Shinji Watanabe and Florian Metze and Luke Zettlemoyer and Abdelrahman Mohamed},
  title = {{LegoNN: Building Modular Encoder-Decoder Models}},
  journal = {IEEE ACM Trans. Audio Speech Lang. Process.},
  year = {2023},
  doi = {10.1109/taslp.2023.3296019},
}
Figure