4 language modeling v2 - georgia institute of technology · 2020-04-21 · logistics ¡hw 1 due...

60
CS 4650/7650: Natural Language Processing Language Modeling Diyi Yang 1 Some slides borrowed from Yulia Tsvetkov at CMU and Kai-Wei Chang at UCLA

Upload: others

Post on 15-Aug-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

CS 4650/7650: Natural Language Processing

Language Modeling

Diyi Yang

1Some slides borrowed from Yulia Tsvetkov at CMU and Kai-Wei Chang at UCLA

Page 2: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Logistics

¡ HW 1 Due

¡ HW 2 Out: Feb 3rd, 2020, 3:00pm

2

Page 3: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Piazza & Office Hours

¡ ~ 11 mins response time

3

Page 4: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Review

¡ L2: Text classification

¡ L3: Neural network for text classification

4

Page 5: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

This Lecture

¡ Language Models¡ What are N-gram models

¡ How to use probabilities

5

Page 6: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

This Lecture

¡ What is the probability of “I like Georgia Tech at Atlanta”?

¡ What is the probability of “like I Atlanta at Georgia Tech”?

6

Page 7: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Language Models Play the Role of …

¡ A judge of grammaticality

¡ A judge of semantic plausibility

¡ An enforcer of stylistic consistency

¡ A repository of knowledge (?)

7

Page 8: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

The Language Modeling Problem

¡ Assign a probability to every sentence (or any string of words)¡ Finite vocabulary (e.g., words or characters) {the, a, telescope, …}

¡ Infinite set of sequences¡ A telescope STOP

¡ A STOP

¡ The the the STOP

¡ I saw a woman with a telescope STOP

¡ STOP

¡ …8

Page 9: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Example

¡ P(disseminating so much currency STOP) = 10#$%¡ P(spending so much currency STOP) = 10#&

9

Page 10: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

What Is A Language Model?

¡ Probability distributions over sentences (i.e., word sequences )

P(W) = P(!"!#!$!% …!')

¡ Can use them to generate strings

P(!' ∣ !#!$!% …!')")

¡ Rank possible sentences

¡ P(“Today is Tuesday”) > P(“Tuesday Today is”)

¡ P(“Today is Tuesday”) > P(“Today is Atlanta”)

10

Page 11: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Language Model Applications

¡ Machine Translation

¡ p(strong winds) > p(large winds)

¡ Spell Correction

¡ The office is about 15 minutes from my house

¡ p(15 minutes from my house) > p(15 minuets from my house)

¡ Speech Recognition

¡ p(I saw a van) >> p(eyes awe of an)

¡ Summarization, question-answering, handwriting recognition, etc.. 11

Page 12: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Language Model Applications

12

Page 13: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Language Model Applications

Language generationhttps://pdos.csail.mit.edu/archive/scigen/

13

Page 14: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Bag-of-Words with N-grams

¡ N-grams: a contiguous sequence of n tokens from a given piece of text

http://recognize-speech.com/language-model/n-gram-model/comparison14

Page 15: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

N-grams Models

¡ Unigram model: ! "# ! "$ ! "% …!("()

¡ Bigram model: ! "# ! "$|"# ! "%|"$ …!("(|"(+#)

¡ Trigram model:

! "# ! "$|"# ! "%|"$, "# …!("(|"(+#"(+$)

¡ N-gram model:

! "# ! "$|"# … !("(|"(+#"(+$ …"(+-)15

Page 16: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

The Language Modeling Problem

¡ Assign a probability to every sentence (or any string of words)¡ Finite vocabulary (e.g., words or characters)

¡ Infinite set of sequences

!"∈$∗

&'( ) = 1

&'( ) ≥ 0, ∀ ) ∈ Σ∗

16

Page 17: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

A Trivial Model

¡ Assume we have ! training sentences

¡ Let "#, "%, … , "' be a sentence, and c("#, "%, … , "') be the number of times it appeared in the training data.

¡ Define a language model + "#, "%, … "' = -(./,.0,… ,.1)2

¡ No generalization!

17

Page 18: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Markov Processes

¡ Markov Processes:¡ Given a sequence of ! random variables

¡ We want a sequence probability model

¡ "#, "%, … , "', (). +. , ! = 100), "0 ∈ 2¡ 3("# = 4#, "% = 4%, …"' = 4')

18

Page 19: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Markov Processes

¡ Markov Processes:¡ Given a sequence of ! random variables

¡ We want a sequence probability model

¡ "#, "%, … , "', "( ∈ *¡ +("# = .#, "% = .%, …"' = .')

¡ There are * ' possible sequences19

Page 20: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

First-order Markov Processes

¡ Chain Rule:¡ ! "# = %#, "' = %',…") = %)

= * "# = %# +,-'

)!(", = %,|"# = %#,… , ",0# = %,0#)

20

Page 21: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

First-order Markov Processes

¡ Chain Rule:

¡ ! "# = %#, "' = %', …") = %)

= * "# = %# +,-'

)!(", = %,|"# = %#, … , ",0# = %,0#)

= * "# = %# +,-'

)!(", = %,|",0# = %,0#) Markov Assumption

21

Page 22: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

First-order Markov Processes

¡ Chain Rule:

¡ ! "# = %#, "' = %', …") = %)

= * "# = %# +,-'

)!(", = %,|"# = %#, … , ",0# = %,0#)

= * "# = %# +,-'

)!(", = %,|",0# = %,0#) Markov Assumption

22

Page 23: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

First-order Markov Processes

23

Page 24: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Second-order Markov Processes

¡ ! "# = %#, "' = %', …") = %)= ! "# = %# ×! "' = %'|"# = %# ∏-./

) !("- = %-|"-1' = %-1', "-1# = %-1#)

¡ Simplify notation: %3 = %1# = ∗

24

Page 25: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Details: Variable Length

¡ We want probability distribution over sequences of any length

25

Page 26: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Details: Variable Length

¡ Define always !" = $%&', where STOP is a special symbol

¡ Then use a Markov process as before:

¡ We now have probability distribution over all sequences

¡ Intuition: at every step you have probability (" to stop and 1 − (" to keep going

+ ,- = !-, ,/ = !/, … , ," = !" =123-

"+(,2 = !2|,26/ = !26/, ,26- = !26-)

26

Page 27: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Step 1: Initialize ! = 1 and $% = $&' = ∗Step 2: Generate $) from the distribution

* +) = $)|+)&- = $)&-, +)&' = $)&'

Step 3: If x0 = 1234 then return the sequence $' ⋯$). Otherwise, set ! = ! + 1 and return to step 2.

27

The Process of Generating Sentences

Page 28: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

¡ A trigram language model contains¡ A vocabulary V

¡ A non negative parameter ! " #, % for every trigram, such that" ∈ ' ∪ STOP , #, % ∈ ' ∪ {∗}

¡ The probability of a sentence 01, 02, … , 04, where 04 = STOP is

3-gram LMs

6 01,… , 04 =7891

4! 08 08:1, 08:2)

28

Page 29: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

¡ A trigram language model contains¡ A vocabulary V

¡ A non negative parameter ! " #, % for every trigram, such that" ∈ ' ∪ STOP , #, % ∈ ' ∪ {∗}

¡ The probability of a sentence 01, 02, … , 04, where 04 = STOP is

3-gram LMs

6 01,… , 04 =7891

4! 08 08:1, 08:2)

29

Page 30: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

3-gram LMs: Example

! the dog barks STOP = 2 the ∗,∗) ×

30

Page 31: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

3-gram LMs: Example

! the dog barks STOP = 2 the ∗,∗) ×= 2 dog ∗, the) ×= 2 barks the, dog) ×= 2 STOP dog, barks)

31

Page 32: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Limitations

¡ Markovian assumption is false

He is from France, so it makes sense that his first language is …

¡ We want to model longer dependencies

32

Page 33: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

N-gram model

33

Page 34: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

More Examples

34

¡ Yoav’s blog post:

¡ http://nbviewer.jupyter.org/gist/yoavg/d76121dfde2618422139

¡ 10-gram character-level LM

First Citizen: Nay, then, that was hers, It speaks against your other service: But since the youth of the circumstance be spoken: Your uncle and one Baptista'sdaughter.

SEBASTIAN: Do I stand till the break off.

Page 35: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Maximum Likelihood Estimation

35

¡ “Best” means “data likelihood reaches maximum”

!" = $%&'$(")(+|")

Page 36: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Maximum Likelihood Estimation

36

Unigram Language Model qp(w| q)=?

Document

text 10mining 5association 3database 3algorithm 2…query 1efficient 1

…text ?mining ?association ?database ?…query ?…

10/1005/1003/1003/100

1/100

Estimation

A paper (total #words=100)

Page 37: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Which Bag of Words More Likely to be Generated

37

aaaDaaaKoaaaa

aE

Kaa

aD a

a

a oab

KaD

E

PF

n

o

Page 38: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Parameter Estimation

38

¡ General setting:¡ Given a (hypothesized & probabilistic) model that governs the random experiment

¡ The model gives a probability of any data !(#|%) that depends on the parameter %¡ Now, given actual sample data X={x1,…,xn}, what can we say about the value of %?

¡ Intuitively, take our best guess of %¡ “best” means “best explaining/fitting the data”

¡ Generally an optimization problem

Page 39: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Maximum Likelihood Estimation

39

¡ Data: a collection of words, !",!$, … ,!&¡ Model: multinomial distribution p()) with parameters +, = .(!,)¡ Maximum likelihood estimator: /+ = 0123045∈7.()|+)

Page 40: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Maximum Likelihood Estimation

40

! " # = %& '( ,… , &(',) .

/0(

,#/1(23) ∝.

/0(

,#/1(23)

⇒ log ! " # =9/0(

,& '/ log #/ + &;<=>

?# = @ABC@DE∈G9/0(

,& '/ log #/

Page 41: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Maximum Likelihood Estimation

41

!" = $%&'$()∈+,-./

01 2- log "-

6 7, " =,-./

01 2- log "- + : ,

-./

0"- − 1

=6="-

= 1 2-"-

+ : → "- = − 1 2-:

∑-./0 "- =1 : = −,-./

01 2-Since we have

"- =1 2-

∑-./0 1 2-

Lagrange multiplier

Set partial derivatives to zero

Requirement from probability

ML estimate

Page 42: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Maximum Likelihood Estimation

42

¡ For N-gram language models

¡ ! "# "#$%, … , "#$()% = +(-.,-./0,…,-./120)+(-./0,…,-./120)

Page 43: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Practical Issues

43

¡ We do everything in the log space

¡ Avoid underflow

¡ Adding is faster than multiplying

log $%×$' = log $% + log $'

Page 44: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

More Resources

44

¡ Google n-gram¡ https://research.googleblog.com/2006/08/all-our-n-gram-are-belong-to-you.html

File sizes: approx. 24 GB compressed (gzip'ed) text files

Number of tokens: 1,024,908,267,229Number of sentences: 95,119,665,584Number of unigrams: 13,588,391Number of bigrams: 314,843,401Number of trigrams: 977,069,902Number of fourgrams: 1,313,818,354Number of fivegrams: 1,176,470,663

Page 45: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

More Resources

45

¡ Google n-gram viewer

https://books.google.com/ngrams/

Data: http://storage.googleapis.com/books/ngrams/books/datasetsv2.html

Page 46: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

46

Page 47: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

47

Page 48: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

48

Page 49: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

49

Page 50: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

How about Unseen Words/Phrases

50

¡ Example: Shakespeare corpus consists of N=884,647 word tokens and a vocabulary of V=29,066 word types

¡ Only 30,000 word types occurred

¡ Words not in the training data ⇒0 probability

¡ Only 0.04% of all possible bigrams occurred

Page 51: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

How to Estimate Parameters from Training Data

¡ How do we known ! " ℎ$%&'()) ?

¡ Use statistics from data (examples using Google N-Grams)

¡ E.g., what is p(door | the) ?

51

Page 52: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Increasing N-Gram Order

¡ High orders capture more dependencies

52

Page 53: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Berkeley Restaurant Project Sentences

¡ can you tell me about any good cantonese restaurants close by

¡ mid priced that food is what i’m looking for

¡ tell me about chez pansies

¡ can you give me a listing of the kinds of food that are available

¡ i’m looking for a good place to eat breakfast

¡ when is cafe venezia open during the day

53

Page 54: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Bigram Counts (~10K Sentences)

54

Page 55: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Bigram Probabilities

55

Page 56: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

What Did We Learn

¡ p(English | want) < p(Chinese | want) – people like Chinese stuff more when it comes to this corpus

¡ English behaves in a certain way

¡ p(to | want) = 0.66

¡ p(eat | to) = 0.28

56

Page 57: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Sparseness

¡ Maximum likelihood for estimating q¡ Let !(#$, #&, … , #() be the number of times that n-gram appears in a corpus

* #+ #+,&, #+,$) =!(#+,&, #+,$, #+)!(#+,&, #+,$)

¡ If vocabulary has 20,000 words à number of parameters is 8 x 10$&!¡ Most n-grams will never be observed, even if they are linguistically plausible

¡ Most sentences will have zero or undefined probabilities

57

Page 58: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

How To Evaluate

¡ Extrinsic: build a new language model, use it for some task (MT, ASR, etc.)

¡ Intrinsic: measure how good we are at modeling language

58

Page 59: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Intrinsic Evaluation

¡ Intuitively, language models should assign high probability to real language they have not seen before

¡ Want to maximize likelihood on test, not training data

¡ Models derived from counts / sufficient statistics require generalization parameters to be tuned on held-out data to stimulate test generalization

¡ Set hyperparameters to maximize the likelihood of the held-out data (usually with grid search or EM)

59

Page 60: 4 language modeling v2 - Georgia Institute of Technology · 2020-04-21 · Logistics ¡HW 1 Due ¡HW 2 Out ... ¡Probability distributions over sentences ... ¡If vocabulary has 20,000

Intrinsic Evaluation

¡ Intuitively, language models should assign high probability to real language they have not seen before

60