Lecture 03 · N-grams
المحاضرة 03 · نماذج N-grams
Smoothing: Add-One and Add-k
التنعيم (Smoothing): Add-One وAdd-k
P1 MUSTP1 ضروريThe formulas you will most likely be asked to compute by hand, plus the one detail everyone forgets: the V in the denominator.
المعادلات التي يُرجَّح جداً أن يُطلب منك حسابها بيدك، مع التفصيل الوحيد الذي ينساه الجميع: الـ V في المقام.
This page has arithmetic that is very likely to appear on the exam. Do not just read it. Cover the right-hand side of every worked example and compute it yourself.
هذه الصفحة فيها حسابات يُرجَّح جداً ظهورها في الامتحان. لا تقرأها قراءة فقط: غطِّ جانب النتائج في كل مثال محلول واحسبه بنفسك أولاً.
The intuition: move mass, do not create it
الفكرة الحدسية: انقل الكتلة الاحتمالية ولا تخلقها
Slide 59 states the idea in one sentence: shave a bit of probability mass from frequent events and give it to unseen events.
تلخّص الشريحة 59 الفكرة في جملة واحدة: اقتطع جزءاً صغيراً من كتلة الاحتمال (probability mass) من الأحداث المتكررة، وأعطه للأحداث التي لم تُشاهَد.
Probability must still sum to 1. You are not inventing mass, you are redistributing it. Every gram that the unseen events receive is a gram that the seen events lost.
مجموع الاحتمالات يجب أن يبقى 1. أنت لا تخترع كتلة احتمال جديدة، بل تعيد توزيع الموجودة. كل ذرة تحصل عليها الأحداث غير المشاهَدة هي ذرة خسرتها الأحداث المشاهَدة.
The "denied the" example, slide 60
مثال "denied the"، الشريحة 60
Suppose after the context denied the you observed 7 tokens total:
افترض أنك بعد السياق denied the شاهدت 7 tokens في المجموع:
| Continuationالكلمة التالية (continuation) | Raw countالعدّ الخام | Smoothed countالعدّ بعد التنعيم | Changeالتغيّر |
|---|---|---|---|
| allegations | 3 | 2.5 | −0.5 |
| reports | 2 | 1.5 | −0.5 |
| claims | 1 | 0.5 | −0.5 |
| request | 1 | 0.5 | −0.5 |
| other (everything unseen)أخرى (كل ما لم يُرَ) | 0 | 2 | +2.0 |
| totalالمجموع | 7 | 7 | 0 |
يعرض الجدول مثال الشريحة 60: لكل تكملة عددها الخام، ثم عددها بعد smoothing، ثم مقدار التغيّر. الذي يجب ملاحظته: كل تكملة مشاهَدة فقدت 0.5 بالضبط، ومجموع ما فُقد (2.0) هو بالضبط ما حصلت عليه خلية الأحداث غير المشاهَدة، والمجموع الكلي بقي 7 قبل وبعد. هذا كل ما يفعله smoothing: نقل كتلة الاحتمال، لا إنشاؤها.
Four seen events each gave up 0.5, which is 2.0 in total, and that 2.0 went to the pool of unseen continuations. The total is still 7. That is smoothing in one table.
أربعة أحداث مشاهَدة تنازل كل منها عن 0.5، أي 2.0 في المجموع، وهذه الـ 2.0 انتقلت إلى مجموعة التكملات غير المشاهَدة. المجموع ما زال 7. هذا هو smoothing في جدول واحد.
Laplace (add-one) smoothing: unigrams
تنعيم Laplace (add-one): نماذج unigrams
Slide 61. The simplest possible smoothing: add 1 to every count before normalizing.
الشريحة 61. أبسط smoothing ممكن: أضف 1 إلى كل عدّة قبل التطبيع (normalizing).
- ci is the raw count of word wi.
ci هي العدّة الخام (raw count) للكلمة wi.
- N is the total number of word tokens.
N هو العدد الكلي لـ word tokens في المتن، أي كل مرات الورود.
- V is the vocabulary size, that is the number of word types.
V هو حجم vocabulary، أي عدد الأنواع (types) من الكلمات، وليس عدد مرات ورودها.
You added 1 to each of the V types. That injects V extra pseudo-observations into the corpus, so the denominator must grow from N to N + V. If you leave the denominator at N the "probabilities" sum to more than 1 and the whole thing stops being a distribution.
أنت أضفت 1 إلى كل نوع من الأنواع الـ V، أي أنك أدخلت V مشاهدة وهمية إضافية إلى المتن، ولهذا يجب أن يكبر المقام من N إلى N + V. وإذا تركت المقام N فإن مجموع "الاحتمالات" سيزيد على 1، ويتوقف الأمر كله عن كونه distribution صحيحاً.
Slide 61 is blunt about the status of this method: simple, but generally poor for language modelling.
الشريحة 61 صريحة في تقييم هذه الطريقة: بسيطة، لكنها ضعيفة عموماً في language modelling.
Laplace (add-one) smoothing: bigrams
تنعيم Laplace (add-one): نماذج bigrams
Slide 62. This is the formula to memorize.
الشريحة 62. هذه هي المعادلة التي يجب حفظها حفظاً تاماً.
Why V, and not 1, goes in the denominator
لماذا نضع V في المقام وليس 1
This is the single most important line on the page.
هذا أهم سطر في الصفحة كلها.
C(wn−1) is not some abstract constant. It is literally the sum of all the bigram counts in that row:
الـ C(wn−1) ليست ثابتاً مجرداً، بل هي حرفياً مجموع كل أعداد bigram في ذلك الصف:
There are V possible next words, so that row has V cells. Add-one adds 1 to every single one of those V cells. So the row total grows by 1 × V = V:
هناك V كلمة تالية محتملة، إذن الصف فيه V خلية. وadd-one يضيف 1 إلى كل خلية من هذه الخلايا الـ V دون استثناء، فيكبر مجموع الصف بمقدار 1 × V = V:
The numerator gains 1 because you touched one cell. The denominator gains V because you touched all V cells. The asymmetry is the entire point.
البسط يكسب 1 لأنك لمست خلية واحدة، والمقام يكسب V لأنك لمست الخلايا الـ V كلها. هذا اللاتناظر بين البسط والمقام هو الفكرة بأكملها.
One cell up top, V cells down below. The +1 in the numerator is for the one bigram you are asking about. The +V in the denominator is for the V bigrams you secretly incremented, all of them, including the one in the numerator.
خلية واحدة في الأعلى، وV خلية في الأسفل. الـ +1 في البسط من أجل الـ bigram الواحد الذي تسأل عنه، والـ +V في المقام من أجل الـ V من bigrams التي زدتها في الخفاء، كلها، بما فيها تلك التي في البسط.
Sanity check that takes two seconds: an add-one smoothed probability must be smaller than the MLE probability whenever the count was high. If your answer came out bigger, you forgot V.
فحص سريع لا يأخذ ثانيتين: احتمال add-one يجب أن يكون أصغر من احتمال MLE كلما كانت العدّة كبيرة. فإذا خرجت نتيجتك أكبر، فأنت نسيت الـ V في المقام.
Three errors that cost marks, in order of frequency:
ثلاثة أخطاء تُفقدك درجات، مرتبة من الأكثر شيوعاً إلى الأقل:
- Forgetting V entirely and writing (C + 1) / C(wn−1). Your row now sums to more than 1.
نسيان V تماماً وكتابة (C + 1) / C(wn−1). النتيجة أن مجموع صفك صار أكبر من 1، فلم يبقَ احتمالاً.
- Adding V to the numerator and writing (C + V) / (C(wn−1) + V). V is not a count of anything in the numerator. The numerator gets +1 and only +1.
إضافة V إلى البسط وكتابة (C + V) / (C(wn−1) + V). الـ V ليست عدّة لأي شيء في البسط، لأن البسط يخص خلية واحدة فقط: يأخذ +1 ولا شيء غير +1.
- Using N instead of C(wn−1) in the bigram denominator. N is for unigrams. Bigrams normalize by the row total, which is the unigram count of the context word.
استخدام N بدلاً من C(wn−1) في مقام الـ bigram. الـ N خاصة بـ unigrams، أما bigrams فتُطبَّع بمجموع الصف، وهو عدد unigram لكلمة السياق.
The BERP numbers
أرقام BERP
The Berkeley Restaurant Project corpus, 9332 sentences, V = 1446. These are the values used on slides 63 and 64.
متن Berkeley Restaurant Project، وفيه 9332 جملة، وحجم vocabulary فيه V = 1446. هذه هي القيم المستخدمة في الشريحتين 63 و64.
| Quantityالكمية | Valueالقيمة |
|---|---|
| C(want, to) | 608 |
| C(want), the unigram count of the context wordC(want)، عدّ الـ unigram لكلمة السياق | 927 |
| V, vocabulary sizeV، حجم المفردات | 1446 |
| C(want) + V, the smoothed denominator for row wantC(want) + V، المقام بعد التنعيم للصف want | 2373 |
| C(chinese, food) | 82 |
| C(chinese) | 158 |
| C(i) | 2533 |
يجمع الجدول كل الأرقام التي ستحتاجها في حسابات هذه الصفحة. أهم سطر فيه هو C(want) + V = 2373، فهو المقام بعد smoothing لصف want. والذي يجب أن تلاحظه: V = 1446 أكبر من C(want) = 927، وهذه المقارنة وحدها تفسّر لماذا ينهار الاحتمال بعد add-one.
Unsmoothed MLE
P(to|want) = C(want, to) / C(want)
= 608 / 927
= 0.6559
= 0.66
Add-one (Laplace)
P(to|want) = ( C(want, to) + 1 ) / ( C(want) + V )
= ( 608 + 1 ) / ( 927 + 1446 )
= 609 / 2373
= 0.25664
= 0.26
Collapse: 0.66 -> 0.26
Discount ratio d = 0.26 / 0.66 = 0.39
A bigram seen 608 times, one of the strongest signals in the entire corpus, lost about 61 percent of its probability. Nothing about want to changed. The only thing that happened is that 1445 other cells in that row each demanded a pseudo-count.
هذا bigram شوهد 608 مرات، وهو من أقوى الإشارات في المتن كله، ومع ذلك خسر نحو 61 بالمئة من احتماله. لم يتغير شيء في want to نفسها، والشيء الوحيد الذي حدث أن 1445 خلية أخرى في الصف نفسه طالبت كل واحدة منها بعدّة وهمية.
Reconstituted (smoothed) counts
العدّات المُعاد بناؤها (بعد التنعيم)
Slide 63. To see how much smoothing moved, convert the smoothed probability back into a count that would produce it under the original denominator.
الشريحة 63. لترى مقدار ما نقله smoothing فعلياً، أعِد تحويل الاحتمال بعد smoothing إلى عدّة تنتج هذا الاحتمال لو قُسمت على المقام الأصلي.
Where this comes from: a smoothed probability can be written two ways, and you set them equal.
من أين جاءت هذه المعادلة: الاحتمال بعد smoothing يمكن كتابته بطريقتين، ثم تساوي بين الطريقتين وتحل.
c* is the count that, divided by the original unsmoothed denominator, gives the smoothed probability. It is directly comparable with the raw counts, which is what makes it a useful diagnostic.
الـ c* هي العدّة التي إذا قُسمت على المقام الأصلي قبل smoothing أعطتك الاحتمال بعد smoothing. وهي قابلة للمقارنة المباشرة مع الأعداد الخام، وهذا ما يجعلها أداة تشخيص مفيدة.
c*(want to) = ( 608 + 1 ) x 927 / ( 927 + 1446 ) = 609 x 927 / 2373 = 564,543 / 2373 = 237.90 = 238 Check: 238 / 927 = 0.257 which is the smoothed probability. Correct. Discount d for want to = 238 / 608 = 0.39 c*(chinese food) = ( 82 + 1 ) x 158 / ( 158 + 1446 ) = 83 x 158 / 1604 = 13,114 / 1604 = 8.18 = 8.2 Discount d for chinese food = 8.2 / 82 = 0.10 A previously-zero cell, C(i, to) = 0 c*(i to) = ( 0 + 1 ) x 2533 / ( 2533 + 1446 ) = 2533 / 3979 = 0.64
Read the two discounts against each other. want to kept 39 percent of its count. chinese food kept 10 percent. A factor of ten difference between two perfectly ordinary bigrams, produced by nothing but the difference in their context-word counts. Add-one is not applying a consistent correction, it is applying a wildly uneven one.
اقرأ قيمتي discount إحداهما في مقابل الأخرى. want to حافظت على 39 بالمئة من عدّتها، وchinese food حافظت على 10 بالمئة فقط: فرق بعشرة أضعاف بين bigram عاديين تماماً، سببه الوحيد اختلاف عدد كلمة السياق. إذن add-one لا يطبّق تصحيحاً منتظماً، بل تصحيحاً متفاوتاً بشكل جامح.
Before and after: row want of the BERP table
قبل وبعد: الصف want في جدول BERP
Slides 63 and 64 show the smoothed counts and the smoothed probabilities. Here is one row of each, side by side.
تعرض الشريحتان 63 و64 الأعداد بعد smoothing والاحتمالات بعده. وهنا صف واحد من كل منهما، جنباً إلى جنب.
| Next word after wantالكلمة التالية بعد want | Raw CC الخام | C + 1 | MLE P (÷ 927)P بطريقة MLE (÷ 927) |
Add-one P (÷ 2373)P بطريقة add-one (÷ 2373) |
c* |
|---|---|---|---|---|---|
| i | 2 | 3 | 0.0022 | 0.0013 | 1.2 |
| want | 0 | 1 | 0 | 0.00042 | 0.39 |
| to | 608 | 609 | 0.66 | 0.26 | 238 |
| eat | 1 | 2 | 0.0011 | 0.00084 | 0.78 |
| chinese | 6 | 7 | 0.0065 | 0.0029 | 2.7 |
| food | 6 | 7 | 0.0065 | 0.0029 | 2.7 |
| lunch | 5 | 6 | 0.0054 | 0.0025 | 2.3 |
| spend | 1 | 2 | 0.0011 | 0.00084 | 0.78 |
الجدول هو صف want كاملاً: العدّة الخام، ثم C + 1، ثم احتمال MLE بالقسمة على 927، ثم احتمال add-one بالقسمة على 2373، ثم العدّة المعاد بناؤها c*. انظر إلى سطرين فقط: الخلية الصفرية want want صارت 0.00042 بدلاً من صفر مستحيل، وفي المقابل هبطت want to من 0.66 إلى 0.26. الربح حقيقي، لكن الثمن فادح.
Two readings of that table:
قراءتان لهذا الجدول:
- The zero cell want want went from an impossible 0 to 0.00042. That is the goal, and it worked.
الخلية الصفرية want want انتقلت من صفر مستحيل إلى 0.00042. هذا هو الهدف من smoothing، وقد تحقق.
- Every other cell shrank, and want to shrank by 61 percent. That is the price, and it is far too high.
وفي المقابل تقلّصت كل خلية أخرى، وتقلّصت want to بنسبة 61 بالمئة. هذا هو الثمن، وهو أعلى من المقبول بكثير.
Why add-one is problematic
لماذا add-one إشكالي
Slide 65 gives three bullets. All three come from the same root cause.
تعطي الشريحة 65 ثلاث نقاط، وكلها ترجع إلى السبب الجذري نفسه.
- It moves too much probability mass to unseen events.
ينقل كتلة احتمال أكبر من اللازم بكثير إلى الأحداث غير المشاهَدة.
- It overly discounts frequent n-grams, changing common probabilities drastically.
يُنقص احتمالات n-grams المتكررة بشكل مبالغ فيه، فيغيّر الاحتمالات الشائعة تغييراً جذرياً.
- It is better as a pedagogical baseline than a production method.
هو أصلح كـ مرجع تعليمي (pedagogical baseline) منه كطريقة تُستخدم في التطبيق الفعلي.
The root cause, in numbers
السبب الجذري بالأرقام
The problem is that a real bigram matrix is overwhelmingly empty, so "add 1 to every cell" means "add 1 to a colossal number of cells".
المشكلة أن مصفوفة bigram الحقيقية فارغة في معظمها الساحق، فعبارة "أضف 1 إلى كل خلية" تعني فعلياً "أضف 1 إلى عدد هائل من الخلايا".
BERP vocabulary V = 1446 V^2 = 1446 x 1446 = 2,090,916 bigram cells Almost every one of those 2.09 million cells is zero. Add-one gives a pseudo-count of 1 to each of them. Now look at the single row for the context word "want". real observations in that row C(want) = 927 pseudo-counts added to that row V = 1446 new row total = 2373 Fraction of the row's probability mass held by pseudo-counts = 1446 / 2373 = 0.609 = 61 percent
Sixty-one percent of the probability after the word want is now assigned to things that were never observed. The 927 real observations are outvoted by 1446 invented ones. That is why P(to | want) fell off a cliff: the real evidence is a minority shareholder in its own row.
واحد وستون بالمئة من الاحتمال بعد كلمة want صار مخصصاً لأشياء لم تُشاهَد قط. الـ 927 مشاهدة الحقيقية تغلبها 1446 مشاهدة مخترعة بالأغلبية. ولهذا سقط P(to | want) سقوطاً حراً: الدليل الحقيقي صار مساهماً أقلية داخل صفه نفسه.
V versus C(context). Add-one is acceptable only when V is small relative to C(wn−1). In BERP, V = 1446 and C(want) = 927, so V is larger than the evidence it is diluting. That inequality, V > C(context), is the fastest way to say why add-one fails here. It is also why add-one is still fine for text classification, where the per-class token count is enormous compared with V.
الـ V في مقابل C(context). لا يكون add-one مقبولاً إلا إذا كانت V صغيرة نسبةً إلى C(wn−1). وفي BERP لدينا V = 1446 وC(want) = 927، أي أن V أكبر من الدليل الذي تخفّفه. هذه المتباينة، V > C(context)، هي أسرع صيغة لقول سبب فشل add-one هنا. وهي أيضاً سبب بقائه مقبولاً في text classification، حيث يكون عدد tokens لكل فئة ضخماً بالمقارنة مع V.
Add-k smoothing
تنعيم add-k
Slide 66. Same idea, smaller dose. Instead of adding a full 1, add a fractional count k.
الشريحة 66. الفكرة نفسها لكن بجرعة أصغر: بدلاً من إضافة 1 كاملة، أضف عدّة كسرية k.
The denominator term is kV, not V. The logic has not changed: you added k to each of the V cells in the row, so the row total grew by k × V. Add-one is just add-k with k = 1.
الحد المضاف في المقام هو kV وليس V. والمنطق لم يتغير: أنت أضفت k إلى كل خلية من خلايا الصف الـ V، فكبر مجموع الصف بمقدار k × V. وadd-one ليس إلا add-k عند k = 1.
k = 0.1
numerator = 608 + 0.1 = 608.1
kV = 0.1 x 1446 = 144.6
denominator = 927 + 144.6 = 1071.6
P(to|want) = 608.1 / 1071.6 = 0.5675
= 0.567
k = 0.01
numerator = 608 + 0.01 = 608.01
kV = 0.01 x 1446 = 14.46
denominator = 927 + 14.46 = 941.46
P(to|want) = 608.01 / 941.46 = 0.6458
And the previously-zero cell still gets something, k = 0.1
P(want|want) = 0.1 / 1071.6 = 0.0000933
Side by side
MLE 0.6559 zeros stay 0 unusable
add-k 0.01 0.6458 zeros become tiny gentle
add-k 0.1 0.5675 zeros become small moderate
add-one 0.2566 zeros become large destructive
Smaller k means less mass stolen from the seen events and less given to the unseen ones. k is a dial between "pure MLE" at k → 0 and "full Laplace" at k = 1.
كلما صغرت k قلّت الكتلة المسروقة من الأحداث المشاهَدة، وقلّ ما يُعطى للأحداث غير المشاهَدة. فالـ k مقبض تدريج بين MLE الخالص عند k → 0 وLaplace الكامل عند k = 1.
Explicit comparison: add-one versus add-k
مقارنة صريحة: add-one مقابل add-k
| Dimensionالبُعد | Add-one (Laplace)Add-one (Laplace) | Add-k |
|---|---|---|
| Amount added per cellالمقدار المضاف لكل خلية | 1 | k, typically 0.1 or 0.01k، عادة 0.1 أو 0.01 |
| Denominator termحدّ المقام | + V | + kV |
| P(to | want) on BERPP(to | want) على BERP | 0.257 | 0.567 at k = 0.10.567 عند k = 0.1 |
| Mass shifted to zerosالكتلة المنقولة إلى الأصفار | Far too muchكثيرة جداً | Tunable, much lessقابلة للضبط، وأقل بكثير |
| Free parameterالمعامل الحر | Noneلا يوجد | k, chosen on a dev setk، يُختار على dev set |
| Status per slides 65 and 66الحالة حسب الشريحتين 65 و66 | Pedagogical baseline onlyخط أساس تعليمي فقط | Still not great for language modellingما زال غير جيد لنمذجة اللغة |
| Where it is genuinely usefulأين يفيد فعلاً | Text classificationتصنيف النصوص | Text classification and some other tasksتصنيف النصوص وبعض المهام الأخرى |
يقارن الجدول add-one بـ add-k على سبعة أبعاد. أهم سطرين للامتحان: الحد المضاف في المقام (+ V في مقابل + kV)، وقيمة P(to | want) التي ترتفع من 0.257 إلى 0.567 عند k = 0.1. ولاحظ أيضاً أن add-k يملك معاملاً حراً واحداً يُضبَط على dev set، وأن كلتا الطريقتين تبقى مفيدة فعلياً في text classification لا في language modelling.
k is tuned, not guessed. Slide 66 says to choose a small k on a dev set. k is a hyperparameter. You pick the k that minimizes perplexity on held-out development data, and only then do you touch the test set. Saying "use k = 0.1 because it is small" is not the answer the slide wants.
الـ k تُضبَط، ولا تُخمَّن. تقول الشريحة 66 إنك تختار k صغيرة على dev set. الـ k هي hyperparameter: تختار القيمة التي تُصغّر perplexity على بيانات تطوير محجوزة، وبعد ذلك فقط تقترب من test set. أما قول "استخدم k = 0.1 لأنها صغيرة" فليس الجواب الذي تريده الشريحة.
Add-k is not the fix. Slide 66 ends with "still not great for language modelling in practice": it produces counts with poor variance and inappropriate discounts. Shrinking k reduces the damage but does not change the underlying strategy of spreading mass uniformly across every unseen cell, which is wrong because unseen bigrams are not all equally plausible. The real fixes are interpolation and backoff, which use lower-order n-gram evidence instead of a flat constant. That is the next page.
الـ add-k ليس الحل. تنتهي الشريحة 66 بعبارة "still not great for language modelling in practice": فهو يُنتج أعداداً ذات تشتت سيئ وقيم discount غير مناسبة. وتصغير k يقلّل الضرر لكنه لا يغيّر الاستراتيجية الأساسية، وهي توزيع الكتلة بالتساوي على كل خلية غير مشاهَدة. وهذا خطأ لأن الـ bigrams غير المشاهَدة ليست متساوية في معقوليتها. الحلول الحقيقية هي interpolation وbackoff، وهما يستعينان بدليل n-gram من رتبة أدنى بدلاً من ثابت مسطّح، وهذا موضوع الصفحة التالية.
One-minute recall sheet
ورقة استذكار في دقيقة
Formulas
الصيغ
Unigram add-one (c_i + 1) / (N + V) Bigram add-one (C(w_n-1, w_n) + 1) / (C(w_n-1) + V) Bigram add-k (C(w_n-1, w_n) + k) / (C(w_n-1) + kV) Reconstituted count c* = (C + 1) x C(w_n-1) / (C(w_n-1) + V)
BERP numbers
أرقام BERP
V = 1446 V^2 = 2,090,916 C(want) = 927 C(want to) = 608 C(want) + V = 2373 P(to|want) MLE = 608/927 = 0.66 P(to|want) +1 = 609/2373 = 0.26 P(to|want) k=.1 = 608.1/1071.6 = 0.567 c*(want to) = 238 discount d = 0.39
Check yourself
اختبر نفسك
In add-one bigram smoothing, why is V added to the denominator?
في add-one smoothing على مستوى bigram، لماذا تُضاف V إلى المقام؟
C. C(wn−1) is the sum of the whole row of bigram counts. That row has V cells, one per possible continuation, and add-one incremented every one, so the sum grows by 1 × V = V. D is the classic error: the numerator gains only 1, for the single cell you are asking about. B is backwards, smoothing makes a frequent bigram's probability smaller.
C. الـ C(wn−1) هي مجموع صف أعداد bigram كله. وهذا الصف فيه V خلية، خلية واحدة لكل تكملة ممكنة، وadd-one زاد كل واحدة منها بمقدار 1، فكبر المجموع بمقدار 1 × V = V. والخيار D هو الخطأ الكلاسيكي: البسط يكسب 1 فقط، من أجل الخلية الواحدة التي تسأل عنها. والخيار B معكوس تماماً، لأن smoothing يجعل احتمال bigram متكرر أصغر لا أكبر.
C(want to) = 608, C(want) = 927, V = 1446. What is the add-one smoothed P(to | want)?
إذا كان C(want to) = 608 وC(want) = 927 وV = 1446، فما قيمة P(to | want) بعد add-one smoothing؟
B. (608 + 1) / (927 + 1446) = 609 / 2373 = 0.257. A is the unsmoothed MLE. C is the forget-V error, which leaves the row summing to more than 1. D is the add-V-to-the-numerator error: 608 + 1446 = 2054, which treats V as if it were a count of something in the numerator.
B. الحساب: (608 + 1) / (927 + 1446) = 609 / 2373 = 0.257. الخيار A هو MLE بدون smoothing. والخيار C هو خطأ نسيان V، وهو يجعل مجموع الصف أكبر من 1. والخيار D هو خطأ إضافة V إلى البسط: 608 + 1446 = 2054، وكأن V عدّة لشيء ما في البسط، وهي ليست كذلك.
What is the reconstituted count c*(want to) under add-one smoothing?
ما قيمة العدّة المعاد بناؤها c*(want to) في add-one smoothing؟
D. c* = (608 + 1) × 927 / (927 + 1446) = 609 × 927 / 2373 = 564,543 / 2373 = 237.9, which rounds to 238. Check it: 238 / 927 = 0.257, the smoothed probability. A is just the incremented count, which is not yet rescaled. C is the probability, not a count.
D. الحساب: c* = (608 + 1) × 927 / (927 + 1446) = 609 × 927 / 2373 = 564,543 / 2373 = 237.9، وتُقرَّب إلى 238. وتحقَّق منها بالقسمة: 238 / 927 = 0.257، وهو الاحتمال بعد smoothing. الخيار A مجرد العدّة بعد الزيادة قبل إعادة التحجيم، والخيار C احتمال لا عدّة.
Why does add-one smoothing move so much probability mass to unseen bigrams?
لماذا ينقل add-one smoothing كل هذا القدر من كتلة الاحتمال إلى الـ bigrams غير المشاهَدة؟
A. With V = 1446, BERP has 14462 = 2,090,916 cells and almost all are zero. In the row for want alone, V = 1446 pseudo-counts are added against only C(want) = 927 real observations, so 1446 / 2373 = 61 percent of that row's mass goes to unobserved events. D states the opposite of the real condition: the problem is precisely that V is large relative to C(wn−1).
A. عند V = 1446 يكون في BERP عدد 14462 = 2,090,916 خلية، وأغلبها المطلق أصفار. وفي صف want وحده تُضاف V = 1446 عدّة وهمية في مقابل C(want) = 927 مشاهدة حقيقية فقط، فتذهب 1446 / 2373 = 61 بالمئة من كتلة ذلك الصف إلى أحداث لم تُشاهَد أصلاً. والخيار D يقول عكس الشرط الحقيقي: المشكلة بالضبط أن V كبيرة نسبةً إلى C(wn−1).
Using add-k with k = 0.1, what is P(to | want)?
باستخدام add-k مع k = 0.1، ما قيمة P(to | want)؟
C. The denominator is C(want) + kV = 927 + (0.1 × 1446) = 927 + 144.6 = 1071.6, giving 608.1 / 1071.6 = 0.567. B is the half-applied error: k was scaled in the numerator but the denominator still used the full V instead of kV. A dropped the smoothing term from the denominator entirely.
C. المقام هو C(want) + kV = 927 + (0.1 × 1446) = 927 + 144.6 = 1071.6، فيكون الناتج 608.1 / 1071.6 = 0.567. الخيار B هو خطأ التطبيق النصفي: استُخدمت k في البسط لكن المقام ظل يستخدم V كاملة بدلاً من kV. والخيار A أسقط حد smoothing من المقام تماماً.
How should the value of k in add-k smoothing be chosen?
كيف ينبغي اختيار قيمة k في add-k smoothing؟
B. Slide 66 says to choose a small k on a dev set. k is a hyperparameter, so it is fit on held-out development data. C is the dangerous distractor: tuning on the test set leaks test information into the model and makes the reported perplexity meaningless. D is false, since different k values change the probabilities and therefore the perplexity.
B. تقول الشريحة 66 إنك تختار k صغيرة على dev set. الـ k هي hyperparameter، فتُضبَط على بيانات تطوير محجوزة. والخيار C هو الفخ الخطير: الضبط على test set يُسرّب معلومات الاختبار إلى النموذج ويجعل perplexity المُعلَنة بلا معنى. والخيار D خاطئ، لأن اختلاف قيم k يغيّر الاحتمالات، وبالتالي يغيّر perplexity.