Formal Models of Language. Slide 1 Language Models A language model an abstract representation of a (natural) language phenomenon. an approximation to.

Slides:



Advertisements
Similar presentations
Language Models & Smoothing Shallow Processing Techniques for NLP Ling570 October 19, 2011.
Advertisements

1 CS 388: Natural Language Processing: N-Gram Language Models Raymond J. Mooney University of Texas at Austin.
N-Grams and Corpus Linguistics 6 July Linguistics vs. Engineering “But it must be recognized that the notion of “probability of a sentence” is an.
N-gram model limitations Important question was asked in class: what do we do about N-grams which were not in our training corpus? Answer given: we distribute.
SI485i : NLP Set 4 Smoothing Language Models Fall 2012 : Chambers.
LIN3022 Natural Language Processing Lecture 4 Albert Gatt LIN Natural Language Processing.
CMSC 723 / LING 645: Intro to Computational Linguistics February 25, 2004 Lecture 5 (Dorr): Intro to Probabilistic NLP and N-grams (chap ) Prof.
CS 4705 N-Grams and Corpus Linguistics Julia Hirschberg CS 4705.
CSC 9010: Special Topics, Natural Language Processing. Spring, Matuszek & Papalaskari 1 N-Grams CSC 9010: Special Topics. Natural Language Processing.
1 N-Grams and Corpus Linguistics September 2009 Lecture #5.
N-Grams and Corpus Linguistics.  Regular expressions for asking questions about the stock market from stock reports  Due midnight, Sept. 29 th  Use.
1 I256: Applied Natural Language Processing Marti Hearst Sept 13, 2006.
Part II. Statistical NLP Advanced Artificial Intelligence N-Gramms Wolfram Burgard, Luc De Raedt, Bernhard Nebel, Lars Schmidt-Thieme Most slides taken.
Part II. Statistical NLP Advanced Artificial Intelligence Markov Models and N-gramms Wolfram Burgard, Luc De Raedt, Bernhard Nebel, Kristian Kersting Some.
Morphology & FSTs Shallow Processing Techniques for NLP Ling570 October 17, 2011.
N-Grams and Corpus Linguistics
September BASIC TECHNIQUES IN STATISTICAL NLP Word prediction n-grams smoothing.
CS 4705 Lecture 13 Corpus Linguistics I. From Knowledge-Based to Corpus-Based Linguistics A Paradigm Shift begins in the 1980s –Seeds planted in the 1950s.
Texture This isn’t described in Trucco and Verri Parts are described in: – Computer Vision, a Modern Approach by Forsyth and Ponce –“Texture Synthesis.
Page 1 Language Modeling. Page 2 Next Word Prediction From a NY Times story... Stocks... Stocks plunged this …. Stocks plunged this morning, despite a.
CS 4705 Lecture 6 N-Grams and Corpus Linguistics.
N-gram model limitations Q: What do we do about N-grams which were not in our training corpus? A: We distribute some probability mass from seen N-grams.
1 Language Model (LM) LING 570 Fei Xia Week 4: 10/21/2009 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AAAAAA A A.
N-Grams and Language Modeling
February 3, 2010Harvard QR481 Coding and Entropy.
Part 5 Language Model CSE717, SPRING 2008 CUBS, Univ at Buffalo.
CS 4705 Lecture 15 Corpus Linguistics III. Training and Testing Probabilities come from a training corpus, which is used to design the model. –overly.
Language Model. Major role: Language Models help a speech recognizer figure out how likely a word sequence is, independent of the acoustics. A lot of.
I256 Applied Natural Language Processing Fall 2009 Lecture 7 Practical examples of Graphical Models Language models Sparse data & smoothing Barbara Rosario.
Introduction to Language Models Evaluation in information retrieval Lecture 4.
CS 4705 N-Grams and Corpus Linguistics. Homework Use Perl or Java reg-ex package HW focus is on writing the “grammar” or FSA for dates and times The date.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 18: 10/26.
CS 4705 N-Grams and Corpus Linguistics. Spelling Correction, revisited M$ suggests: –ngram: NorAm –unigrams: anagrams, enigmas –bigrams: begrimes –trigrams:
CS 4705 Lecture 14 Corpus Linguistics II. Relating Conditionals and Priors P(A | B) = P(A ^ B) / P(B) –Or, P(A ^ B) = P(A | B) P(B) Bayes Theorem lets.
LIN3022 Natural Language Processing Lecture 5 Albert Gatt LIN Natural Language Processing.
Language Models Instructor: Paul Tarau, based on Rada Mihalcea’s original slides Note: some of the material in this slide set was adapted from an NLP course.
SI485i : NLP Set 3 Language Models Fall 2012 : Chambers.
1 Advanced Smoothing, Evaluation of Language Models.
8/27/2015CPSC503 Winter CPSC 503 Computational Linguistics Lecture 5 Giuseppe Carenini.
Natural Language Processing Lecture 6—9/17/2013 Jim Martin.
Machine Translation Course 3 Diana Trandab ă ț Academic year:
NGrams 09/16/2004 Instructor: Rada Mihalcea Note: some of the material in this slide set was adapted from an NLP course taught by Bonnie Dorr at Univ.
Natural Language Processing Language Model. Language Models Formal grammars (e.g. regular, context free) give a hard “binary” model of the legal sentences.
1 LIN6932 Spring 2007 LIN6932: Topics in Computational Linguistics Hana Filip Lecture 5: N-grams.
Lecture 1, 7/21/2005Natural Language Processing1 CS60057 Speech &Natural Language Processing Autumn 2007 Lecture 7 8 August 2007.
6. N-GRAMs 부산대학교 인공지능연구실 최성자. 2 Word prediction “I’d like to make a collect …” Call, telephone, or person-to-person -Spelling error detection -Augmentative.
1 COMP 791A: Statistical Language Processing n-gram Models over Sparse Data Chap. 6.
Chapter 6: Statistical Inference: n-gram Models over Sparse Data
Resolving Word Ambiguities Description: After determining word boundaries, the speech recognition process matches an array of possible word sequences from.
Information Theory Ying Nian Wu UCLA Department of Statistics July 9, 2007 IPAM Summer School.
N-gram Models CMSC Artificial Intelligence February 24, 2005.
Ngram models and the Sparcity problem. The task Find a probability distribution for the current word in a text (utterance, etc.), given what the last.
1 Introduction to Natural Language Processing ( ) Language Modeling (and the Noisy Channel) AI-lab
Estimating N-gram Probabilities Language Modeling.
A COMPARISON OF HAND-CRAFTED SEMANTIC GRAMMARS VERSUS STATISTICAL NATURAL LANGUAGE PARSING IN DOMAIN-SPECIFIC VOICE TRANSCRIPTION Curry Guinn Dave Crist.
Natural Language Processing Statistical Inference: n-grams
2/29/2016CPSC503 Winter CPSC 503 Computational Linguistics Lecture 5 Giuseppe Carenini.
Learning, Uncertainty, and Information: Evaluating Models Big Ideas November 12, 2004.
Statistical Methods for NLP Diana Trandab ă ț
Computerlinguistik II / Sprachtechnologie Vorlesung im SS 2010 (M-GSW-10) Prof. Dr. Udo Hahn Lehrstuhl für Computerlinguistik Institut für Germanistische.
Tasneem Ghnaimat. Language Model An abstract representation of a (natural) language. An approximation to real language Assume we have a set of sentences,
Introduction to N-grams Language Modeling IP disclosure: Content borrowed from J&M 3 rd edition and Raymond Mooney.
Language Model for Machine Translation Jang, HaYoung.
Statistical Methods for NLP
N-Grams Chapter 4 Part 2.
CSC 594 Topics in AI – Natural Language Processing
N-Grams and Corpus Linguistics
N-Grams and Corpus Linguistics
Lecture 13 Corpus Linguistics I CS 4705.
Presentation transcript:

Formal Models of Language

Slide 1 Language Models A language model an abstract representation of a (natural) language phenomenon. an approximation to real language Statistical models predictive explicative

Slide 2 Claim A useful part of the knowledge needed to allow letter/word predictions can be captured using simple statistical techniques. Compute: probability of a sequence likelihood of letters/words co-occurring Why would we want to do this? Rank the likelihood of sequences containing various alternative hypotheses Assess the likelihood of a hypothesis

Slide 3 Outline Applications of language models Approximating natural language The chain rule Learning N-gram models Smoothing for language models Distribution of words in language: Zipf’s law and Heaps law

Slide 4 Why is This Useful? Speech recognition Handwriting recognition Spelling correction Machine translation systems Optical character recognizers

Slide 5 Handwriting Recognition Assume a note is given to a bank teller, which the teller reads as I have a gub. (cf. Woody Allen) NLP to the rescue …. gub is not a word gun, gum, Gus, and gull are words, but gun has a higher probability in the context of a bank

Slide 6 Real Word Spelling Errors They are leaving in about fifteen minuets to go to her house. The study was conducted mainly be John Black. Hopefully, all with continue smoothly in my absence. Can they lave him my messages? I need to notified the bank of…. He is trying to fine out.

Slide 7 For Spell Checkers Collect list of commonly substituted words piece/peace, whether/weather, their/there... Example: “On Tuesday, the whether …’’ “On Tuesday, the weather …”

Slide 8 Other Applications Machine translation Text summarization Optical character recognition

Slide 9 Outline Applications of language models Approximating natural language The chain rule Learning N-gram models

Slide 10 Letter-based Language Models Shannon’s Game Guess the next letter:

Slide 11 Letter-based Language Models Shannon’s Game Guess the next letter: W

Slide 12 Letter-based Language Models Shannon’s Game Guess the next letter: Wh

Slide 13 Shannon’s Game Guess the next letter: Wha Letter-based Language Models

Slide 14 Shannon’s Game Guess the next letter: What Letter-based Language Models

Slide 15 Shannon’s Game Guess the next letter: What d Letter-based Language Models

Slide 16 Shannon’s Game Guess the next letter: What do Letter-based Language Models

Slide 17 Shannon’s Game Guess the next letter: What do you think the next letter is? Letter-based Language Models

Slide 18 Shannon’s Game Guess the next letter: What do you think the next letter is? Guess the next word: Letter-based Language Models

Slide 19 Shannon’s Game Guess the next letter: What do you think the next letter is? Guess the next word: What Letter-based Language Models

Slide 20 Shannon’s Game Guess the next letter: What do you think the next letter is? Guess the next word: What do Letter-based Language Models

Slide 21 Shannon’s Game Guess the next letter: What do you think the next letter is? Guess the next word: What do you Letter-based Language Models

Slide 22 Shannon’s Game Guess the next letter: What do you think the next letter is? Guess the next word: What do you think Letter-based Language Models

Slide 23 Shannon’s Game Guess the next letter: What do you think the next letter is? Guess the next word: What do you think the Letter-based Language Models

Slide 24 Shannon’s Game Guess the next letter: What do you think the next letter is? Guess the next word: What do you think the next Letter-based Language Models

Slide 25 Shannon’s Game Guess the next letter: What do you think the next letter is? Guess the next word: What do you think the next word is? Letter-based Language Models

Slide 26 Approximating Natural Language Words zero-order approximation: letter sequences are independent of each other and all equally probable: xfoml rxkhrjffjuj zlpwcwkcy ffjeyvkcqsghyd

Slide 27 Approximating Natural Language Words first-order approximation: letters are independent, but occur with the frequencies of English text: ocro hli rgwr nmielwis eu ll nbnesebya th eei alhenhtppa oobttva nah

Slide 28 second-order approximation: the probability that a letter appears depends on the previous letter on ie antsoutinys are t inctore st bes deamy achin d ilonasive tucoowe at teasonare fuzo tizin andy tobe seace ctisbe Approximating Natural Language Words

Slide 29 third-order approximation: the probability that a certain letter appears depends on the two previous letters in no ist lat whey cratict froure birs grocid pondenome of demonstures of the reptagin is regoactiona of cre Approximating Natural Language Words

Slide 30 Higher frequency trigrams for different languages: English: THE, ING, ENT, ION German: EIN, ICH, DEN, DER French: ENT, QUE, LES, ION Italian:CHE, ERE, ZIO, DEL Spanish:QUE, EST, ARA, ADO Approximating Natural Language Words

Slide 31 Outline Applications of language models Approximating natural language The chain rule Learning N-gram models

Slide 32 Terminology Sentence: unit of written language Utterance: unit of spoken language Word Form: the inflected form that appears in the corpus Lemma: lexical forms having the same stem, part of speech, and word sense Types (V): number of distinct words that might appear in a corpus (vocabulary size) Tokens (N T ): total number of words in a corpus Types seen so far (T): number of distinct words seen so far in corpus (smaller than V and N T )

Slide 33 Word-based Language Models A model that enables one to compute the probability, or likelihood, of a sentence S, P(S). Simple: Every word follows every other word w/ equal probability (0-gram) Assume |V| is the size of the vocabulary V Likelihood of sentence S of length n is = 1/|V| × 1/|V| … × 1/|V| If English has 100,000 words, probability of each next word is 1/ =.00001

Slide 34 Word Prediction: Simple vs. Smart Smarter: probability of each next word is related to word frequency (unigram) – Likelihood of sentence S = P(w 1 ) × P(w 2 ) × … × P(w n ) – Assumes probability of each word is independent of probabilities of other words. Even smarter: Look at probability given previous words (N-gram) – Likelihood of sentence S = P(w 1 ) × P(w 2 |w 1 ) × … × P(w n |w n-1 ) – Assumes probability of each word is dependent on probabilities of other words.

Slide 35 Chain Rule Conditional Probability P(w 1,w 2 ) = P(w 1 ) · P(w 2 |w 1 ) The Chain Rule generalizes to multiple events P(w 1, …,w n ) = P(w 1 ) P(w 2 |w 1 ) P(w 3 |w 1,w 2 )…P(w n |w 1 …w n-1 ) Examples: P(the dog) = P(the) P(dog | the) P(the dog barks) = P(the) P(dog | the) P(barks| the dog)

Slide 36 Relative Frequencies and Conditional Probabilities Relative word frequencies are better than equal probabilities for all words In a corpus with 10K word types, each word would have P(w) = 1/10K Does not match our intuitions that different words are more likely to occur (e.g. the) Conditional probability more useful than individual relative word frequencies dog may be relatively rare in a corpus But if we see barking, P(dog|barking) may be very large

Slide 37 For a Word String In general, the probability of a complete string of words w 1 n = w 1 …w n is P(w 1 n ) = P(w 1 )P(w 2 |w 1 )P(w 3 |w 1..w 2 ) … P(w n |w 1 … w n-1 ) = But this approach to determining the probability of a word sequence is not very helpful in general – gets to be computationally very expensive

Slide 38 Counting Words in Corpora What is a word? e.g., are cat and cats the same word? September and Sept? zero and oh? Is seventy-two one word or two? AT&T? Punctuation? How many words are there in English? Where do we find the things to count?

Slide 39 Outline Applications of language models Approximating natural language The chain rule Learning N-gram models

Slide 40 Simple N-Grams An N-gram model uses the previous N-1 words to predict the next one: P(w n | w n-N+1 w n-N+2… w n-1 ) unigrams: P(dog) bigrams: P(dog | big) trigrams: P(dog | the big) quadrigrams: P(dog | chasing the big)

Slide 41 Using N-Grams Recall that N-gram: P(w n |w 1 n-1 ) ≈ P(w n |w n-N+1 n-1 ) Bigram: P(w 1 n ) ≈ For a bigram grammar P(sentence) can be approximated by multiplying all the bigram probabilities in the sequence Example: P(I want to eat Chinese food) = P(I | ) P(want | I) P(to | want) P(eat | to) P(Chinese | eat) P(food | Chinese)

Slide 42 A Bigram Grammar Fragment Eat on.16Eat Thai.03 Eat some.06Eat breakfast.03 Eat lunch.06Eat in.02 Eat dinner.05Eat Chinese.02 Eat at.04Eat Mexican.02 Eat a.04Eat tomorrow.01 Eat Indian.04Eat dessert.007 Eat today.03Eat British.001

Slide 43 Additional Grammar I.25Want some.04 I’d.06Want Thai.01 Tell.04To eat.26 I’m.02To have.14 I want.32To spend.09 I would.29To be.02 I don’t.08British food.60 I have.04British restaurant.15 Want to.65British cuisine.01 Want a.05British lunch.01

Slide 44 Computing Sentence Probability P(I want to eat British food) = P(I| ) P(want|I) P(to|want) P(eat|to) P(British|eat) P(food|British) =.25×.32×.65×.26×.001×.60 = vs. P(I want to eat Chinese food) = Probabilities seem to capture “syntactic'' facts, “world knowledge'' eat is often followed by a NP British food is not too popular N-gram models can be trained by counting and normalization

Slide 45 N-grams Issues Sparse data Not all N-grams found in training data, need smoothing Change of domain Train on WSJ, attempt to identify Shakespeare – won’t work N-grams more reliable than (N-1)-grams But even more sparse Generating Shakespeare sentences with random unigrams... Every enter now severally so, let With bigrams... What means, sir. I confess she? then all sorts, he is trim, captain. Trigrams Sweet prince, Falstaff shall die.

Slide 46 N-grams Issues Determine reliable sentence probability estimates should have smoothing capabilities (avoid the zero-counts) apply back-off strategies: if N-grams are not possible, back-off to (N- 1) grams P(“And nothing but the truth”)  P(“And nuts sing on the roof”)  0

Slide 47 Bigram Counts IWantToEatChineseFoodlunch I Want To Eat Chinese Food Lunch

Slide 48 Bigram Probabilities: Use Unigram Count Normalization: divide bigram count by unigram count of first word. Computing the probability of I I P(I|I) = C(I I)/C(I) = 8 / 3437 =.0023 A bigram grammar is an VxV matrix of probabilities, where V is the vocabulary size IWantToEatChineseFoodLunch

Slide 49 Learning a Bigram Grammar The formula P(w n |w n-1 ) = C(w n-1 w n )/C(w n-1 ) is used for bigram “parameter estimation”

Slide 50 Training and Testing Probabilities come from a training corpus, which is used to design the model. overly narrow corpus: probabilities don't generalize overly general corpus: probabilities don't reflect task or domain A separate test corpus is used to evaluate the model, typically using standard metrics held out test set cross validation evaluation differences should be statistically significant

Slide 51 Outline Applications of language models Approximating natural language The chain rule Learning N-gram models Smoothing for language models Distribution of words in language: Zipf’s law and Heaps law

Slide 52 Outline Applications of language models Approximating natural language The chain rule Learning N-gram models