Docsity

Conditional Probability - Lecture Slides | LING 581, Assignments of Linguistics

Partial preview of the text

Download Conditional Probability - Lecture Slides | LING 581 and more Assignments Linguistics in PDF only on Docsity!

Homework

Read Jurafsky and Martin (2nd edition), Chapter 4

Conditional probability

Often the sample space Ω is too large to be interesting, or even known. Instead, we only care about a subset of possible outcomes that have some relevant property.

The conditional probability of an event B given event A is:

The joint probability P ( AB ) is the probability of events A and B occurring together: P ( A ∩ B )

P ( B | A ) =

P ( A ∩ B )

P ( A )

| A ∩ B |

| S |

×

| S |

| A |

| A ∩ B |

| A |

Conditional probability

Draw one card. What is the probability that it is the king of clubs?

If it is a club, what is the probability that it is the king of clubs?

P ( K ♣) =

P ( K ♣|♣)=

P ( K ♣ and ♣)

P (♣)

×

Conditional probability

Two events A and B are said to be independent if and only if: P ( B | A )= P ( B )

Recall the product rule: P ( ABC · · ·)= P ( A ) × P ( B | A ) × P ( C | AB ) × · · ·

For independent events A, B, C,.. ., we have: P ( ABC · · ·)= P ( A ) × P ( B ) × P ( C ) × · · ·

Probability so far

Sum rule: or, for mutually exclusive events:

Product rule: or, for independent events:

Bayes’ Theorem:

P ( A or B ) = P ( A ) + P ( B ) − P ( AB )

P ( A or B ) = P ( A ) + P ( B )

P ( A and B ) = P ( A ) × P ( B | A )

P ( A and B ) = P ( A ) × P ( B )

P ( A | B ) =

P ( A ) × P ( B | A )

P ( B )

Sequence models

Many NLP problems can be reduced to find the probability of a sequence (of words, phrases, etc)

Tokenization thetabledownthere theta bled own there the table down there

Real-word spelling error detection, speech recognition

A simple approach: treat a phrase like a poker hand drawn from a very large deck

Bag of words model

Independence

All statistical methods we looked at make the “i.i.d.” assumption

This is clearly false for language, though we can sometimes fake it (bag of words model)

Our simple language model assigns a probability to a text:

The bag of words assumption makes estimation of the model easy, but is also very unrealistic: Also assumption bag but easy estimation is makes model of of, the the unrealistic very P ( w 1 ,... , wn ) = n

i = P ( wi )

Independence

Instead, we could apply the chain rule:

The fully independent model is a multinomial distribution with one parameter per word (conservatively, 20,000 parameters)

The fully dependent model is a multinomial distribution with one parameter per word per context (something like 10 220 parameters)

By comparison, there are maybe 10 79 atoms in the universe P ( w 1 ,... , wn ) = P ( w 1 ) × P ( w 2 | w 1 ) × P ( w 3 | w 1 , w 2 ) × · · · × P ( wn | w 1 ,... , wn − 1 ) = n

i = P ( wi | w 1 ,... , wi − 1 )

Markov chains

A particularly simple way of forming equivalence classes treats language as a Markov chain

A Markov chain is a sequence of random variables in which, given the present, the future is conditionally independent of the past:

Only a fixed length previous history is relevant: Markov assumption, limited horizon

Plus language is stationary and ergodic (that is, i.i.d.) P ( wn | w 1 ,... , wn − 1 ) = P ( wn | wn − 1 )

Markov chains

Taking language as a Markov chain leads to n -gram models:

Bigrams = first order Markov model, trigram = second order, four-gram = third order, etc

Generally speaking, higher order models do a better job of predicting probabilities, but have more parameters (and so require more training data) P ( w 1 ,... , wn ) = n

i = P ( wi |φ ( w 1 ,... , wi − 1 )) = n

i = P ( wi | wi − 2 , wi − 1 )