NLP & Transformers

Machine Translation

Translating text across human languages from phrase based statistical rules to neural Transformers.

🟡 intermediate5 min readnlp
Machine Translation (MT) converts source language text into target language text while preserving semantic meaning. Statistical Machine Translation (SMT) relied on phrase tables and language models. Neural Machine Translation (NMT) replaced hand-crafted rules with end-to-end sequence to sequence models (Encoder-Decoder LSTMs and Transformers). Evaluation relies on automatic overlap metrics (BLEU, chrF) and neural quality estimation models (COMET).

Evolution of Machine Translation

┌──────────────────────────┬──────────────────────────┬──────────────────────────┐
│ 1. STATISTICAL (SMT)     │ 2. RECURRENT NMT         │ 3. TRANSFORMER NMT       │
├──────────────────────────┼──────────────────────────┼──────────────────────────┤
│ Phrase tables +          │ Encoder-Decoder LSTM     │ Encoder-Decoder          │
│ Language models +        │ with Bahdanau Attention. │ Transformer (NLLB-200).  │
│ Alignment pipelines.     │ End-to-end continuous    │ Parallel GPU training,   │
│ Rigid word translations. │ representation learning. │ state of the art fluency.│
└──────────────────────────┴──────────────────────────┴──────────────────────────┘

1. Statistical Machine Translation (SMT)

Before deep learning, systems like early Google Translate used Noisy Channel Models:

$$\arg\max_Y P(Y \mid X) = \arg\max_Y P(X \mid Y) \cdot P(Y)$$

SMT required complex pipelines: sentence alignment, tokenization, phrase extraction, and reordering rules. Translations were often robotic and grammatically awkward.

2. Neural Machine Translation (NMT)

Neural NMT replaced multi-step pipelines with a single end-to-end neural network.

The Encoder-Decoder Framework

  Source (English): "The cat sat on the mat." ──► [ ENCODER ]
                                                      │
                                                      ▼ Cross Attention
  Target (French):  [SOS] ──► [ DECODER ] ──► "Le" ──► "chat" ──► "s'est" ──► "assis" ──► [EOS]

Modern NMT: No Language Left Behind (NLLB-200)

Meta's NLLB-200 model translates across 200 different languages using a single massive 54B parameter Encoder-Decoder Transformer with Mixture of Experts (MoE).

Key innovations in modern NMT:

  1. Multilingual Shared Vocabulary: A single subword BPE tokenizer covering 200+ languages.
  2. Language Tokens: Prepending target language tags (__fra_Latn__) to instruct the decoder which language to generate.

Evaluating Translation Quality

  1. BLEU Score: Measures exact n-gram precision overlap between model output and human reference translations.
  2. chrF Score: Measures character n-gram overlap, performing better on morphologically rich languages.
  3. COMET (Neural Metric): Uses a pre-trained cross-lingual Transformer (XLM-RoBERTa) to predict human quality ratings directly from source, target, and reference embeddings.

Say this out loud

Machine Translation evolved from phrase-based statistical pipelines to end-to-end Neural Machine Translation (NMT). Modern NMT uses Encoder-Decoder Transformers where the encoder reads source text and the decoder uses cross-attention to generate target translations token by token. Quality is evaluated using n-gram overlap metrics like BLEU and neural metrics like COMET.

Followups to expect

  1. What is Back-Translation? A data augmentation technique for low-resource languages: take monolingual target text, translate it back to source language using a temporary model, and use the synthetic pair for training.
  2. Why is Beam Search preferred over Greedy Decoding for MT? Greedy decoding picks the single highest probability word at step t, which can trap the decoder in bad sentence structures. Beam Search keeps top-K candidate translations alive in parallel.

Check yourself

Question 1 of 3

What primary advantage did Neural Machine Translation (NMT) demonstrate over Statistical Machine Translation (SMT)?

More in NLP & Transformers

See all →
The Attention Mechanism5 minTransformer Architecture5 minTokenization & BPE5 min