CS474 Natural Language Processing N-Gram Approximations Bigram

CS474 Natural Language Processing N-Gram Approximations Bigram

CS474 Natural Language Processing N-gram approximations Last class Bigram model – Introduction to generative models of language » What are they? » Why they’re important » Issues for counting words Trigram model » Statistics of natural language – Conditions on the two preceding words » Unsmoothed n-gram models N-gram approximation Today – Training n-gram models – Smoothing Markov assumption: probability of some future event (next word) depends only on a limited history of preceding events (previous words) Bigram grammar fragment Training N-gram models Berkeley Restaurant Project N-gram models can be trained by counting and normalizing – Bigrams n−1 C(wn−1wn ) P(wn | w1 ) = C(wn−1) – General case C(wn−1 w ) P(w | wn−1 ) = n−N +1 n n n−N +1 C(wn−1 ) Can compute the probability of a complete string n−N +1 – An example of Maximum Likelihood Estimation (MLE) – P (I want to eat British food) = P(I|<s>) P(want|I) » Resulting parameter set is one in which the likelihood of the P(to|want) P(eat|to) P(British|eat) P(food|British) training set T given the model M (i.e. P(T|M)) is maximized. Bigram counts Bigram probabilities Problem for the maximum likelihood estimates: sparse data Note the number of 0’s… Accuracy of N-gram models Strong dependency on training data Accuracy increases as N increases Trigram model from WSJ corpus – Train various N-gram models and then use each to – They also point to ninety nine point six billion dollars generate random sentences. from two hundred four oh six three percent of the rates – Corpus: Complete works of Shakespeare of interest stores as Mexico and Brazil on market » Unigram: Will rash been and by I the me loves gentle me not slavish page, the and hour; ill let conditions » Bigram: What means, sir. I confess she? Then all sorts, he is trim, captain. » Trigram: Fly, and will rid me these news of price. Therefore the sadness of parting, as they say, ‘tis done. » Quadrigram: They say all lovers swear more performance than they are wont to keep obliged faith unforfeited! Smoothing Add-one smoothing Need better estimators for rare events Add one to all of the counts before normalizing into probabilities Approach Normal unigram probabilities – Somewhat decrease the probability of C(wx ) previously seen events, so that there is a little P(wx ) = N bit of probability mass left over for previously Smoothed unigram probabilities unseen events C(w ) +1 » Smoothing x P(wx ) = » Discounting methods N +V Adjusted counts N c* = (c +1) i i N +V Adjusted bigram counts Too much probability mass is moved Discount d Estimated bigram frequencies c AP data, 44million words r = fMLE femp fadd-1 c* Church and Gale (1991) 0 0.000027 0.000137 dc = In general, add-one smoothing 1 0.448 0.000274 c is a poor method of smoothing 2 1.25 0.000411 Much worse than other Ratio of the methods in predicting the 3 2.24 0.000548 actual probability for unseen 4 3.23 0.000685 discounted bigrams counts to the Variances of the counts are 5 4.21 0.000822 worse than those from the 6 5.23 0.000959 unsmoothed MLE method original 7 6.21 0.00109 counts 8 7.21 0.00123 9 8.26 0.00137 Methodology Cardinal sin: Testing on the training corpus Divide data into training set and test set – Train the statistical parameters on the training set; use them to compute probabilities on the test set – Test set: 5-10% of the total data, but large enough for reliable results Divide training into training and validation/held out set » Obtain counts from training » Tune smoothing parameters on the validation set Divide test set into development and final test set – Do all algorithm development by testing on the dev set, save the final test set for the very end….

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    4 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us