1 of 60

Machine Translation

W266: Natural Language Processing

2 of 60

The plan...

  • Announcements
  • Classical MT
  • Noisy-Channel model
  • Word-based MT / IBM models
  • Phrase-based MT
  • MT Evaluation
  • Neural MT
  • Word alignments beyond MT

3 of 60

Back in the old days...

4 of 60

Classical MT

  1. Direct translation model
    1. Some local reordering included
    2. i.e. I am eating the apple. -> Je mange la pomme.
  2. Transfer model
    • Transform the parse tree
    • i.e. English to Spanish; NP -> Adjective Noun to NP -> Noun Adjective
    • i.e. The green witch -> La bruja verde
  3. Interlingua model
    • Extract meaning
    • Event-based representation

5 of 60

Vauquois Triangle

(Vauquois, 1968)

6 of 60

MT is *really* hard

  • Why?

7 of 60

MT is *really* hard

  • Division of words (i.e. Eskimo)
  • Syntax differences
    • SVO (like English) vs. SOV (like Japanese)
    • Placement of adjectives
  • Head marking
    • The man's house vs. "the man house-his" (in Hungarian)
  • Referential density
    • Lack of vs presence of pronouns
  • Homonyms
    • bass (the fish? the instrument?)

8 of 60

MT is *really* hard

  • Polysemy
    • I know vs. Je connais or Je sais (in French)
  • Gender
    • La pomme
  • Lack of similar context
    • Brother vs "older/younger brother" (in Chinese/Japanese)

9 of 60

Which one seems best?

  • Japanese: "fukaku hansei shite orimasu"
  • English:
    • "I'm sorry"
    • "We are deeply reflecting (on our past behavior, and what we did wrong, and how to avoid the problem next time)"
  • Hebrew: "adonai roi" (the Lord is my shepherd)
  • Suppose a culture has no sheep...
    • "the Lord will look after me"
    • "the Lord is for me like somebody who looks after animals with cotton-like hair"
  • Faithfulness vs. Fluency

10 of 60

Statistical MT

End goal: evaluate P(hello | bonjour)

11 of 60

The Noisy Channel Model

For Machine Translation, translate f → e

P(e) : source (language model)

P(f|e) : channel (translation model)

“...one naturally wonders if the problem of translation could conceivably be treated as a problem in cryptography. When I look at an article in Russian, I say: ‘This is really written in English, but it has been coded in some strange symbols. I will now proceed to decode.’ ”

  • Warren Weaver, 1947

12 of 60

IBM Alignment Models

Generative process e → f with P(f | e)

Latent variable model for P(f | e)

  • P(f | e) = P(f | a, e) P(a | e)
  • Hidden variable: alignment ai
  • Parameters: t(f | eai)

Use Bayes’ rule to compute P(e | f)

Decode using beam search over P(f | e) P(e)

p(a | e)

t(f | e)

P(f | a, e)

P(a | e)

P(e)

Generation

(never used)

13 of 60

IBM Alignment Models: Inference

Generative process e → f with P(f | e)

Latent variable model for P(f | e)

  • P(f | e) = P(f | a, e) P(a | e)
  • Hidden variable: alignment ai
  • Parameters: t(f | eai)

Use Bayes’ rule to compute P(e | f)

Decode using beam search over P(f | e) P(e)

P(f | a, e)

P(a | e)

P(e)

f

P(a | f, e)

P(e | f)

Generation

(never used)

Inference

p(a | e)

t(f | e)

14 of 60

What is P(f | e) ?

15 of 60

IBM Model 1

Noisy-channel translation f → e

Model: generative process e → f with P(f | e)

  1. Sample a length m ∼ Q(m)
    • Distribution Q(m) doesn’t matter!
  2. Sample an alignment {ai} for i = 1,...,m
  3. Sample a word fi from t(f | eai)

the

blue

house

NULL

m = 3

16 of 60

IBM Model 1

Noisy-channel translation f → e

Model: generative process e → f with P(f | e)

  • Sample a length m ∼ Q(m)
    • Distribution Q(m) doesn’t matter!
  • Sample an alignment {ai} for i = 1,...,m
    • ai ∼ Uniform(0, ℓ + 1)
    • ai independent
  • Sample a word fi from t(f | eai)

m = 3

the

blue

house

NULL

a1 = 1

17 of 60

IBM Model 1

Noisy-channel translation f → e

Model: generative process e → f with P(f | e)

  • Sample a length m ∼ Q(m)
    • Distribution Q(m) doesn’t matter!
  • Sample an alignment {ai} for i = 1,...,m
    • ai ∼ Uniform(0, ℓ + 1)
    • ai independent
  • Sample a word fi from t(f | eai)

m = 3

the

blue

house

NULL

a1 = 1

a2 = 3

18 of 60

IBM Model 1

Noisy-channel translation f → e

Model: generative process e → f with P(f | e)

  • Sample a length m ∼ Q(m)
    • Distribution Q(m) doesn’t matter!
  • Sample an alignment {ai} for i = 1,...,m
    • ai ∼ Uniform(0, ℓ + 1)
    • ai independent
  • Sample a word fi from t(f | eai)

m = 3

the

blue

house

NULL

a1 = 1

a2 = 3

a3 = 2

19 of 60

IBM Model 1

Noisy-channel translation f → e

Model: generative process e → f with P(f | e)

  • Sample a length m ∼ Q(m)
    • Distribution Q(m) doesn’t matter!
  • Sample an alignment {ai} for i = 1,...,m
    • ai ∼ Uniform(0, ℓ + 1)
    • ai independent
  • Sample a word fi from t(f | eai)
    • t(f | e) tabulated

the

blue

house

la

NULL

m = 3

t(la | the)

20 of 60

IBM Model 1

Noisy-channel translation f → e

Model: generative process e → f with P(f | e)

  • Sample a length m ∼ Q(m)
    • Distribution Q(m) doesn’t matter!
  • Sample an alignment {ai} for i = 1,...,m
    • ai ∼ Uniform(0, ℓ + 1)
    • ai independent
  • Sample a word fi from t(f | eai)
    • t(f | e) tabulated

the

blue

house

la

maison

NULL

m = 3

t(maison | house)

21 of 60

IBM Model 1

Noisy-channel translation f → e

Model: generative process e → f with P(f | e)

  • Sample a length m ∼ Q(m)
    • Distribution Q(m) doesn’t matter!
  • Sample an alignment {ai} for i = 1,...,m
    • ai ∼ Uniform(0, ℓ + 1)
    • ai independent
  • Sample a word fi from t(f | eai)
    • t(f | e) tabulated

the

blue

house

la

maison

bleue

NULL

m = 3

t(bleue | blue)

22 of 60

IBM Model 1

Noisy-channel translation f → e

Model: generative process e → f with P(f | e)

  • Sample a length m ∼ Q(m)
    • Distribution Q(m) doesn’t matter!
  • Sample an alignment {ai} for i = 1,...,m
    • ai ∼ Uniform(0, ℓ + 1)
    • ai independent
  • Sample a word fi from t(f | eai)
    • t(f | e) tabulated

the

blue

house

la

maison

bleue

NULL

23 of 60

IBM Model 1

Noisy-channel translation f → e

Model: generative process e → f with P(f | e)

  • Sample a length m ∼ Q(m)
    • Distribution Q(m) doesn’t matter!
  • Marginalize alignment {ai} for i = 1,...,m
    • ai ∼ Uniform(0, ℓ + 1)
    • ai independent
  • Sample a word fi from t(f | eai)
    • t(f | e) tabulated

the

blue

house

la

maison

bleue

NULL

24 of 60

IBM Model 1: Inference

Noisy-channel translation f → e

Model: generative process e → f with P(f | e)

  • Closed-form expression for P(f | e)
    • As long as t(f | e) known
  • Alignments are implicit (summed out)

Use Bayes’ rule to compute P(e | f)

Decode using beam search over P(f | e) P(e)

?

?

?

la

maison

bleue

NULL

25 of 60

Training Model 1

26 of 60

IBM Alignment Models: Training

Generative process e → f with P(f | e)

Latent variable model for P(f | e)

  • P(f | e) = P(f | a, e) P(a | e)
  • Hidden variable: alignment ai
  • Parameters: t(f | eai)

Observe (f, e). Need to infer parameters!

But, ai unobserved: use EM

  • E-step: infer p(ai | f, e)
  • M-step: estimate t(f | eai)

P(f | a, e)

P(a | e)

P(e)

f

P(a | f, e)

e

Generation

(never used)

Training

p(a | e)

t(f | e)

27 of 60

IBM Model 1: Training

Observe (f, e). Need to infer parameters!

But, ai unobserved: use EM

  • E-step: infer p(ai | f, e)
  • M-step: estimate t(f | eai)

f

P(a | f, e)

e

Training

p(a | e)

t(f | e)

28 of 60

IBM Model 1: Training

Observe (f, e). Need to infer parameters!

But, ai unobserved: use EM

  • E-step: infer p(ai | f, e)
  • M-step: estimate t(f | eai)

f

P(a | f, e)

e

Training

p(a | e)

t(f | e)

29 of 60

IBM Model 1: Training

Observe (f, e). Need to infer parameters!

But, ai unobserved: use EM

  • E-step: infer p(ai | f, e)
  • M-step: estimate t(f | eai)

t(wf | we) = count(wf, we) / count(we)

f

P(a | f, e)

e

Training

p(a | e)

t(f | e)

30 of 60

Better models?

31 of 60

Model 1 Limitations

Bag-of-words model! (yuck)

  • P(f | e) doesn’t depend sequence e
  • Thus, P(e | f) relies on LM P(e) for fluency
  • Problems?

Alignments all independent

No many-to-one alignments, or many-to-many

  • Problems?

Word-factored - problems?

32 of 60

Model 1 vs. Model 2

Model 1: “bag of words”

Generative process e → f with P(f | e)

  1. Sample a length m ∼ Q(m)
    • Distribution Q(m) doesn’t matter!
  2. Sample an alignment {ai} for i = 1,...,m
    • ai ∼ Uniform(0, ℓ + 1)
    • ai independent
  3. Sample a word fi from t(f | eai)
    • t(f | e) tabulated

Model 2: distortion probabilities

Generative process e → f with P(f | e)

  1. Sample a length m ∼ Q(m)
    • Distribution Q(m) doesn’t matter!
  2. Sample an alignment {ai} for i = 1,...,m
    • ai ∼ a(ai| i, ℓ, m)
    • ai independent
  3. Sample a word fi from t(f | eai)
    • t(f | e) tabulated

33 of 60

HMM Model

HMM: sequence model over alignments

Generative process e → f with P(f | e)

  1. Sample a length m ∼ Q(m)
    • Distribution Q(m) doesn’t matter!
  2. Sample an alignment {ai} for i = 1,...,m
    • ai ∼ a(ai| ai-1)
    • ai form Markov chain
  3. Sample a word fi from t(f | eai)
    • t(f | e) tabulated

Model 2: distortion probabilities

Generative process e → f with P(f | e)

  • Sample a length m ∼ Q(m)
    • Distribution Q(m) doesn’t matter!
  • Sample an alignment {ai} for i = 1,...,m
    • ai ∼ a(ai| i, ℓ, m)
    • ai independent
  • Sample a word fi from t(f | eai)
    • t(f | e) tabulated

34 of 60

Phrase-Based MT

Problem: words are not independent!

  • Common patterns: [eat apples] ↔ [manger des pommes]
  • Idiomatic or non-compositional: [kick the bucket] ↔ [casser sa pipe]

Idea: translate in larger chunks - phrase units

  • Pre-segment input(s)
  • Translate each segment
  • (inference) beam decode

35 of 60

Phrase-Based MT

Generate phrases by heuristics or ML

  • Variable length
  • No linguistic constraints

Koehn (2009) Statistical Machine Translation

36 of 60

Evaluation Metrics: BLEU

37 of 60

BLEU motivation

Why is an automated eval important for machine translation?

What makes automated evaluation hard?

What makes us think that evaluation is possible?

38 of 60

BLEU motivation

Why is an automated eval important for machine translation?

  • Quick turn around
  • Cheap
  • Consistency

What makes automated evaluation hard?

What makes us think that evaluation is possible?

39 of 60

Evaluation seems possible!

40 of 60

BLEU formulation

Idea #1: Precision

How many of the words in the candidate translation occur in a reference?

41 of 60

BLEU formulation

Idea #1: Precision

How many of the words in the candidate translation occur in a reference?

Problem:

Candidate: the the the

Reference: the cow jumped over the moon

Precision?

42 of 60

BLEU formulation

Idea #2: Max credit

How many of the words in the candidate translation occur in a reference?

(Cap numerator of precision by # of times word seen in reference.)

Better:

Candidate: the the the the the the

Reference: the cow jumped over the moon

Precision?

43 of 60

BLEU formulation

Idea #3: Unigrams are too small of a unit

How many of the words in the candidate translation occur in a reference?

(Cap numerator of precision by # of times word seen in reference.)

(<= 4-grams)

Smaller n-grams stop correlating with monolingual judgements on fluency.

44 of 60

BLEU formulation

Idea #4: Brevity Penalty

How many of the words in the candidate translation occur in a reference?

(Cap numerator of precision by # of times word seen in reference.)

(<= 4-grams)

(Trivial translations are likely bad)

Penalty = e^(min(0, 1 - ref_len / mt_len))

45 of 60

BLEU formulation

Extensions:

  • Corpus level
  • Multiple reference sentences

How long to optimize for?

  • Compare references against one another is a good measure of benchmark usefulness

46 of 60

Evaluation seems possible!

47 of 60

The Future: Neural MT

48 of 60

Or maybe the present?

Google’s GNMT system serves 16 language pairs: https://translate.google.com/

End-to-End Sequence-to-Sequence models:

  • Input: source language sentence
  • Output: target language sentence

la

maison

bleue

</s>

<s>

the

blue

the

blue

house

house

</s>

49 of 60

Attention Models

Problem: fixed-length vector representation

  • Bad for long sentences!

Idea: allow model to look back at input sequence during decoding

  • Acts as a sort of “memory”
  • Cognitively plausible?
  • Bonus: get alignments! (or something like them)

50 of 60

Attention Models: Example

51 of 60

Attention Demo

-> go here

52 of 60

Convolutional Neural Networks

53 of 60

https://developer.apple.com/library/content/documentation/Performance/Conceptual/vImage/ConvolutionOperations/ConvolutionOperations.html

54 of 60

55 of 60

ByteNet: Convolution over characters

Neural Machine Translation in Linear* Time, Kalchbrenner et al, March 2017

56 of 60

ByteNet: Language Model

57 of 60

ByteNet: Translation Model

58 of 60

Word Alignments: Cross-Lingual Parsing

59 of 60

Cross-Lingual Parsing

Neural MT doesn’t need explicit alignment model.

But: alignments useful for domain transfer!

Input: English parser

Input: parallel sentences (f, e)

Output: parsed foreign sentences

Source: “Bootstrapping Parsers via Syntactic Projection across Parallel Texts” (Hwa et al. 2005)

60 of 60

Cross-Lingual Parsing

(almost) Equivalent to matrix multiplication:

If interested in typed edges, can treat E as 3rd-rank tensor

Normalize columns of Et, then DMST to decode

Source: Multilingual Projection for Parsing Truly Low-Resource Languages (Agic, et al. 2016)