Natural Language Processing · TEE · read
Class-style count-table questions and partial-table traps
From a corpus to sentence probabilities
Unit 3, pages 97–120 and appendix
Question. Train a bigram model on “I am Sam”, “Sam I am”, and “I do not like green eggs and ham”. Include sentence boundaries. Find P(I|<s>), P(Sam|<s>), P(am|I), P(do|I), P(Sam|am) and P(</s>|Sam).
Given
Three sentences; one <s> and </s> per sentence; preserve capital I and Sam.
To find
Six bigram estimates.
Formula and why it applies
P(w\mid h)=C(h,w)/C(h)Count all matching histories, including repeated words in different sentence positions.
Solution
Step 1. Count the histories
START occurs 3 times; I occurs 3 times; am occurs 2 times; Sam occurs 2 times.
Step 2. Count the requested pairs
| Pair | Pair count | History count |
|---|---|---|
| START I | 2 | 3 |
| START Sam | 1 | 3 |
| I am | 2 | 3 |
| I do | 1 | 3 |
| am Sam | 1 | 2 |
| Sam END | 1 | 2 |
Step 3. Divide pair by history
| Requested probability | Result |
|---|---|
| P(I|START) | 2/3 |
| P(Sam|START) | 1/3 |
| P(am|I) | 2/3 |
| P(do|I) | 1/3 |
| P(Sam|am) | 1/2 |
| P(END|Sam) | 1/2 |
Question. A bigram table gives P(i|<s>)=0.25, P(want|i)=0.33, P(english|want)=0.0011, P(food|english)=0.5 and P(</s>|food)=0.68. Score “i want english food” using these supplied rounded values.
Given
All five transition probabilities are explicitly given. Include the end marker.
To find
The sentence probability from the supplied table.
Formula and why it applies
P=P(i\mid START)P(want\mid i)P(english\mid want)P(food\mid english)P(END\mid food)A table-based question uses the provided values; slight differences can arise if exact corpus fractions are used instead.
Solution
Step 1. First two events
0.25(0.33)=0.0825Step 2. Add english
0.0825(0.0011)=0.00009075Step 3. Add food
0.00009075(0.5)=0.000045375Step 4. End the sentence
0.000045375(0.68)=0.000030855Question. A corpus has vocabulary size 1446, C(i)=2533 and C(i,want)=827. Compute the unsmoothed and add-one-smoothed P(want|i). The displayed bigram table contains only eight vocabulary columns.
Given
Full history count C(i)=2533; pair count 827; complete vocabulary size V=1446. The displayed table is only a subset.
To find
Both conditional probabilities.
Formula and why it applies
P(want\mid i)=827/2533,\qquad P_L(want\mid i)=\frac{827+1}{2533+1446}Use the supplied full history total. Summing only the eight displayed columns would wrongly ignore all other possible continuations.
Solution
Step 1. Calculate the unsmoothed ratio
P=827/2533\approx0.326490Step 2. Add one to the pair count
827+1=828Step 3. Add V to the history count
2533+1446=3979Step 4. Divide
P_L=828/3979\approx0.208092Yaad rakho: Partial table ka visible row-sum, full history total nahi hota.
Bigram & Trigram Probs
- id
- nlp-m2-04-bigram-trigram-tables
- title
- Bigram & Trigram Probs
- title_confirmed
- true
- topic_title
- Build bigram and trigram probabilities from a corpus
- mode
- m2
- kind
- focused
- status
- available
- duration
- 10:05
- reviewed
- false
- notebook_url
- https://notebook.google.com/notebook/a270ef1e-c285-4d31-9db1-302090c5f8b1
- youtube_url
- corrected_visuals
- false
- upload_pending_correction
- false
- correction_note
- related_topic_ids
These are recorded generation statuses, not a live service check. Private YouTube and signed-in NotebookLM links require the owner's account. This export publishes existing catalog metadata, not private video files or an invented transcript.
NLP M2 — N-grams and Laplace | Reviewed worked numericals
- id
- overview-ngrams-laplace
- title
- NLP M2 — N-grams and Laplace | Reviewed worked numericals
- title_confirmed
- true
- topic_title
- NLP M2: N-Grams & Laplace
- mode
- m2
- kind
- supplemental
- status
- available
- duration
- 7:41
- reviewed
- true
- notebook_url
- https://notebook.google.com/notebook/a270ef1e-c285-4d31-9db1-302090c5f8b1
- youtube_url
- https://www.youtube.com/watch?v=RyPi8xq8ugU
- corrected_visuals
- true
- upload_pending_correction
- false
- correction_note
- Complete counts and four Laplace factors; corrected formulas, conditional-factor wording and rounding. Full transcript and detected slides checked; short voice corrections included.
- related_topic_ids
- nlp-m2-03-ngrams-language-models
- nlp-m2-04-bigram-trigram-tables
- nlp-m2-05-laplace-smoothing-discount
These are recorded generation statuses, not a live service check. Private YouTube and signed-in NotebookLM links require the owner's account. This export publishes existing catalog metadata, not private video files or an invented transcript.