Natural Language Processing · Advanced level

Advanced level · Module 7: Machine Translation · Lesson 1 of 3

How Neural Machine Translation Works

Learners connect the encoder-decoder and transformer modules to translation, and run a pretrained translation model on English sentences.

In this lesson you will

  • Explain neural MT as encoder-decoder translation
  • Run a pretrained translation model and inspect its licence

Key concepts

parallel corpusneural MTmultilingual modelslanguage codesmodel licences

The lesson

Neural machine translation uses encoder-decoder transformers trained on parallel corpora (the same sentences in two languages). Multilingual models share one network across many languages, which helps languages with little data by transferring from related ones.

Pretrained models are available on the Hugging Face Hub. Their licences differ. For example, the NLLB-200 distilled 600M model card states a CC-BY-NC-4.0 licence, which means non-commercial use only. Check the licence before any organisational use.

Run translations with transformers.pipeline('translation', model=..., src_lang=..., tgt_lang=...) using the language codes on the model card. Start with English-French or English-Swahili, where results can be checked by speakers.

Step by step

  1. Read the model card of a pretrained translation model and record its licence and languages.
  2. Translate ten English public-notice sentences into a language a classmate speaks well.
  3. Ask the speaker to mark each translation as good, acceptable or wrong.
  4. Record the model's typical errors.

Practice activity

Run and review a pretrained translation model on ten public-notice sentences with a speaker.

Expected result: A licence record and a speaker-reviewed error list.

Check your understanding

  1. What is a parallel corpus?

    Show answer

    The same sentences in two (or more) languages, aligned with each other.

  2. What does a CC-BY-NC-4.0 licence mean for an organisation?

    Show answer

    The model may only be used for non-commercial purposes, with attribution.

Further learning

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.