Majid Al-RaimiThe prior and the channel modelالاحتمال المسبق (Prior) ونموذج القناة

ICS 582Lecture 05المحاضرة 05Part 04الجزء 04

The prior and the channel modelالاحتمال المسبق (Prior) ونموذج القناة

Estimating the two factors: P(w) from corpus counts, and P(x|w) from the Kernighan, Church and Gale confusion matrices for deletion, insertion, substitution and transposition.تقدير العاملين: P(w) من عدّ المدونة، وP(x|w) من مصفوفات الالتباس لـ Kernighan وChurch وGale للحذف والإدراج والاستبدال والتبديل (transposition).

Conceptsالمفاهيم
3
Slidesالشرائح
17-24
Readingمدة القراءة
18 min18 دقيقة
Understoodما فهمته
0/3 conceptsمفاهيم

Why this part mattersلماذا يهمّ هذا الجزء

The Noisy channel model picks the candidate w that maximizes a product of two numbers, the prior P(w) and the channel probability P(x|w). Part 03 produced the candidates for acress. This part fills in both numbers for every one of them, using corpus counts for the prior and the Kernighan, Church and Gale confusion matrices for the channel. Expect an exam question that hands you a count and asks for one of these probabilities, and expect the hard part to be picking the right denominator.
يختار noisy channel model المرشح w الذي يعظّم حاصل ضرب عددين: الاحتمال المسبق P(w) واحتمال القناة P(x|w). أنتج الجزء 03 المرشحين للكلمة acress. وهذا الجزء يملأ العددين لكل واحد منهم، مستخدمًا عدّات المدوّنة للاحتمال المسبق، ومصفوفات الالتباس الخاصة بـ Kernighan وChurch وGale للقناة. توقّع في الامتحان سؤالًا يعطيك عدًّا ويطلب أحد هذين الاحتمالين، وتوقّع أن يكون الجزء الصعب هو اختيار المقام الصحيح.

By the end you canفي نهاية هذا الجزء ستستطيع

  1. Compute a unigram prior P(w) = C(w)/N from corpus counts and explain why any n-gram model can supply the prior.تحسب الاحتمال المسبق أحادي الكلمة P(w) = C(w)/N من عدّات المدوّنة، وتشرح لماذا يمكن لأي نموذج n-gram أن يوفّر هذا الاحتمال المسبق.
  2. State what each of the four confusion matrices del, ins, sub and trans counts, and read a cell of the substitution matrix in the right direction.تذكر ما تعدّه كل مصفوفة من مصفوفات الالتباس الأربع del وins وsub وtrans، وتقرأ خلية في مصفوفة الاستبدال بالاتجاه الصحيح.
  3. Write the Kernighan, Church and Gale formula for P(x|w) from memory, with the correct numerator and denominator for each edit type.تكتب صيغة Kernighan وChurch وGale للاحتمال P(x|w) من الذاكرة، مع البسط والمقام الصحيحين لكل نوع من أنواع التعديل.
  4. Map every acress candidate to its matrix cell and denominator, and explain why a zero count still gives a nonzero probability.تربط كل مرشح من مرشحي acress بخليته في المصفوفة وبمقامه، وتشرح لماذا يعطي العدّ الصفري مع ذلك احتمالًا غير صفري.

Before looking at how acress could have been mistyped, ask a simpler question: if you pick a random word from a large body of English, how likely is it to be actress? In the COCA sample of 404,253,213 words, actress appears 9,321 times, so about 23 words in every million are actress. Across appears 120,844 times, about 299 per million. Without knowing anything about the typo, across is roughly 13 times more likely to be the word the writer meant.

قبل أن ننظر في الطريقة التي ربما كُتبت بها acress خطأً، اطرح سؤالًا أبسط: لو اخترت كلمة عشوائية من نص إنجليزي ضخم، فما احتمال أن تكون actress؟ في عيّنة COCA المكوّنة من 404,253,213 كلمة، تظهر actress عدد 9,321 مرة، أي قرابة 23 كلمة من كل مليون. وتظهر across عدد 120,844 مرة، أي قرابة 299 في المليون. فمن دون معرفة أي شيء عن الخطأ الإملائي، تكون across أرجح بنحو 13 مرة لأن تكون الكلمة التي قصدها الكاتب.

That number is the Prior probability, P(w): how plausible a candidate is as a piece of text before the typed string is taken into account. The noisy channel does not care where it comes from. Any language model from lecture 03 can provide it: a unigram, a Bigram language model that looks at the previous word, or a trigram that looks at two. The simplest choice, used on this slide, is the Unigram prior: the relative frequency of the word in a corpus.

هذا العدد هو prior probability أي الاحتمال المسبق P(w): مدى معقولية المرشح بوصفه قطعة من نص قبل أخذ السلسلة المكتوبة في الحسبان. ولا تهتم القناة الصاخبة بمصدره. فأي نموذج لغوي من المحاضرة 03 يمكنه توفيره: نموذج unigram، أو bigram language model الذي ينظر إلى الكلمة السابقة، أو نموذج trigram الذي ينظر إلى كلمتين. وأبسط خيار، وهو المستخدم في هذه الشريحة، هو unigram prior: التكرار النسبي للكلمة في مدوّنة.

P(w)=C(w)NP(w) = \frac{C(w)}{N}
Unigram prior: corpus count of w over the total number of word tokens Nالاحتمال المسبق بنموذج unigram: عدّ w في المدونة مقسومًا على إجمالي رموز الكلمات N

Worked exampleمثال محلول

Verify P(actress) from the COCA countsتحقّق من P(actress) باستخدام عدّات COCA

  1. Read the countsاقرأ العدّات

    C(actress) = 9,321 and N = 404,253,213 word tokens.
    C(actress) = 9,321 وN = 404,253,213 وحدة كلمة (word tokens).
  2. Divideاقسم

    9,321 / 404,253,213 = 0.0000230573, which is 2.31 × 10⁻⁵.
    9,321 / 404,253,213 = 0.0000230573، أي 2.31 × 10⁻⁵.
  3. Sanity check against a neighborتحقّق منطقي بالمقارنة مع مرشح مجاور

    120,844 / 404,253,213 = 0.000298931 for across, and the ratio 120,844 / 9,321 ≈ 12.96 matches the ratio of the two probabilities, as it must, because they share N.
    120,844 / 404,253,213 = 0.000298931 للكلمة across، والنسبة 120,844 / 9,321 ≈ 12.96 تطابق النسبة بين الاحتمالين، وهذا لا بد منه لأنهما يشتركان في N.
  4. Resultالنتيجة

    P(actress) = 2.31 × 10⁻⁵, the first row of the table below.
    P(actress) = 2.31 × 10⁻⁵، وهو الصف الأول في الجدول أدناه.
Bars proportional to each candidate's COCA count: across dwarfs the others, and cress and caress barely registerأعمدة تتناسب مع عدّ كل مرشح في COCA: تتضاءل أمام across بقية المرشحين، ولا تكاد cress وcaress تظهران

The full table of priors for the six candidates of acress:

الجدول الكامل للاحتمالات المسبقة لمرشحي acress الستة:

Candidate wالمرشح wC(w)C(w)P(w)P(w)
actressactress9,3219,321.0000230573.0000230573
cresscress220220.0000005442.0000005442
caresscaress686686.0000016969.0000016969
accessaccess37,03837,038.0000916207.0000916207
acrossacross120,844120,844.0002989314.0002989314
acresacres12,87412,874.0000318463.0000318463
Unigram priors from 404,253,213 COCA words (slide 18)الاحتمالات المسبقة أحادية الكلمة من 404,253,213 كلمة في COCA (الشريحة 18)

Notice what this table cannot know. The original sentence was about a stellar and versatile acress, and any human reads actress at once. A unigram prior has no access to that sentence, so it ranks the candidates purely by how common they are in general. That is the weakness part 05 fixes by swapping in a bigram prior, which is exactly the flexibility slide 17 promises: the channel stays the same and only the language model changes.

لاحظ ما لا يستطيع هذا الجدول معرفته. كانت الجملة الأصلية عن acress «متألقة ومتعددة المواهب»، وأي إنسان يقرؤها actress فورًا. أما الاحتمال المسبق أحادي الكلمة فلا يصل إلى تلك الجملة، لذا يرتّب المرشحين فقط بحسب مدى شيوعهم عمومًا. وهذا هو الضعف الذي يعالجه الجزء 05 باستبدال احتمال مسبق من نوع bigram به، وهي بالضبط المرونة التي تعد بها الشريحة 17: تبقى القناة كما هي ويتغير النموذج اللغوي وحده.

Priors at web scaleالاحتمالات المسبقة على نطاق الويب

A search engine correcting queries has n-gram counts over hundreds of billions of words. Properly smoothed models such as Kneser-Ney are expensive to estimate at that size, so the slide points to Stupid backoff: use the relative frequency of the longest n-gram that was seen, and multiply by a fixed 0.4 each time you back off to a shorter one. The result is a score rather than a true probability, but the decoder only compares candidates, so a consistent score is enough. The full recipe and a worked example are in lecture 03, backoff and stupid backoff.

محرك البحث الذي يصحّح الاستعلامات يملك عدّات n-gram على مئات المليارات من الكلمات. والنماذج المنعّمة تنعيمًا سليمًا مثل Kneser-Ney مكلفة التقدير عند هذا الحجم، لذلك تشير الشريحة إلى stupid backoff: استخدم التكرار النسبي لأطول n-gram شوهد، واضرب في قيمة ثابتة 0.4 في كل مرة تتراجع فيها إلى n-gram أقصر. والنتيجة درجة وليست احتمالًا حقيقيًا، لكن المفكّك (decoder) يقارن المرشحين فقط، فتكفي درجة متّسقة. والوصفة الكاملة مع مثال محلول موجودة في المحاضرة 03، backoff وstupid backoff.

Recall

Why can the noisy channel corrector use a unigram, bigram or trigram prior without any other change?لماذا يستطيع مصحّح القناة الصاخبة استخدام احتمال مسبق من نوع unigram أو bigram أو trigram دون أي تغيير آخر؟

The prior and channel are separate factors in P(x|w) P(w). The prior only has to score how plausible w is as text, so any language model that assigns a score to w (in context or not) can be plugged in while the channel model stays the same.
لأن الاحتمال المسبق والقناة عاملان منفصلان في P(x|w) P(w). فالاحتمال المسبق عليه فقط أن يقدّر مدى معقولية w بوصفها نصًّا، لذا يمكن تركيب أي نموذج لغوي يعطي w درجة (ضمن سياق أو من دونه) بينما يبقى نموذج القناة كما هو.

Take the candidate across. To get acress from it, the writer must have typed e where o was intended. How often does that happen? Kernighan, Church and Gale counted it over a large set of real typos from newswire text: e was typed for o 93 times. That single number, divided by how often o occurs at all, is the probability of the edit. This is the whole idea of the Channel model, also called the error model or edit probability.

خذ المرشح across. لكي نحصل منه على acress، لا بد أن الكاتب كتب e حيث كان يقصد o. فكم مرة يحدث ذلك؟ عدّه Kernighan وChurch وGale على مجموعة كبيرة من الأخطاء الإملائية الحقيقية في نصوص الأخبار: كُتب e بدلًا من o عدد 93 مرة. هذا العدد الواحد، مقسومًا على عدد مرات ظهور o أصلًا، هو احتمال التعديل. وهذه هي الفكرة الكاملة لـ channel model، ويُسمّى أيضًا نموذج الخطأ (error model) أو احتمال التعديل (edit probability).

Fix the notation from slide 19. The typed, misspelled word is x = x₁ x₂ … xₘ and the intended, correct word is w = w₁ w₂ … wₙ, both as sequences of letters. Every candidate from part 03 differs from the typo by a single edit, so P(x|w) is just the probability of that one edit: a Deletion, an Insertion, a Substitution or a Transposition. A perfect error model would condition on the typist, the keyboard and the time of day. This one conditions only on the letters involved and, for insertion and deletion, the letter just before, which is local enough to estimate from data.

ثبّت الرموز من الشريحة 19. الكلمة المكتوبة الخاطئة هي x = x₁ x₂ … xₘ والكلمة المقصودة الصحيحة هي w = w₁ w₂ … wₙ، وكلتاهما متتالية من الحروف. كل مرشح من الجزء 03 يختلف عن الخطأ الإملائي بتعديل واحد، لذا فإن P(x|w) هو ببساطة احتمال ذلك التعديل الواحد: حذف deletion، أو إدراج insertion، أو استبدال substitution، أو تبديل transposition. نموذج الخطأ المثالي كان سيشترط على الكاتب ولوحة المفاتيح ووقت اليوم. أما هذا النموذج فيشترط فقط على الحروف المعنية، وفي حالتي الإدراج والحذف على الحرف السابق مباشرة، وهذا محلي بما يكفي لتقديره من البيانات.

Four intended words reach the same typo acress through four different edits; each edit names the confusion-matrix cell that prices itأربع كلمات مقصودة تصل إلى الخطأ الإملائي نفسه acress عبر أربعة تعديلات مختلفة؛ وكل تعديل يسمّي خلية مصفوفة الالتباس التي تحدد احتماله

The four tablesالجداول الأربعة

A Confusion matrix is a table of counts of how often one thing was mistaken for another. The Kernighan, Church and Gale channel model uses four of them, one per edit type, each indexed by a pair of letters.

confusion matrix أو مصفوفة الالتباس هي جدول عدّات لعدد المرات التي أُخذ فيها شيء على أنه شيء آخر. ويستخدم Kernighan, Church and Gale channel model أربعًا منها، واحدة لكل نوع تعديل، وكل منها مفهرسة بزوج من الحروف.

The four confusion matrices (slide 20, read consistently with slides 21 and 23)مصفوفات الالتباس الأربع (الشريحة 20، مقروءة بما يتّسق مع الشريحتين 21 و23)

del[x,y]
count(xy typed as x): the y after an x was left outcount(xy كُتبت x): سقط الحرف y الذي يأتي بعد x
ins[x,y]
count(x typed as xy): an extra y was typed after an xcount(x كُتبت xy): كُتب حرف y زائد بعد x
sub[x,y]
count(y typed as x): x was typed where y was intended (see the errata below)count(y كُتبت x): كُتب x حيث كان المقصود y (انظر التصويب أدناه)
trans[x,y]
count(xy typed as yx): two adjacent letters were swappedcount(xy كُتبت yx): تبادل حرفان متجاوران موقعيهما

Insertion and deletion are conditioned on the previous character. Dropping the t in actress is recorded as del[c,t], a t lost after a c, not as a bare t lost anywhere. That matters, because some letters vanish far more easily in certain neighborhoods, such as one letter of a doubled pair. The same choice gives insertion its first index: the extra s in acress, read as acres plus an s, is ins[e,s] or ins[s,s] depending on which s you call the extra one, and both readings appear on slide 24.

الإدراج والحذف مشروطان بالحرف السابق. فإسقاط t من actress يُسجَّل على أنه del[c,t]، أي t ضاع بعد c، لا مجرد t ضاع في أي مكان. وهذا مهم، لأن بعض الحروف تختفي بسهولة أكبر بكثير في جوار معيّن، مثل أحد حرفي زوج مكرر. والاختيار نفسه يعطي الإدراج فهرسه الأول: فالحرف s الزائد في acress، إذا قرأناها acres مضافًا إليها s، يكون ins[e,s] أو ins[s,s] بحسب أي s تعدّه الزائد، والقراءتان كلتاهما تظهران في الشريحة 24.

Reading the substitution matrixقراءة مصفوفة الاستبدال

Slide 21 prints the substitution table from the original paper. Rows are X, the letter typed; columns are Y, the letter intended. So the cell in row e, column o is sub[e,o] = 93: e typed for o. The big numbers cluster among the vowels: sub[e,a] = 388, sub[a,e] = 342, sub[i,e] = 146, sub[o,e] = 116. Vowels sound alike in unstressed syllables, so writers who spell by ear confuse them constantly. Among consonants the standout is sub[m,n] = 180, two letters that are both similar in sound and adjacent on the keyboard.

تطبع الشريحة 21 جدول الاستبدال من الورقة الأصلية. الصفوف هي X، الحرف المكتوب؛ والأعمدة هي Y، الحرف المقصود. لذا فالخلية في الصف e والعمود o هي sub[e,o] = 93: كُتب e بدلًا من o. وتتجمع الأعداد الكبيرة بين حروف العلة: sub[e,a] = 388، sub[a,e] = 342، sub[i,e] = 146، sub[o,e] = 116. فحروف العلة تتشابه في النطق داخل المقاطع غير المنبورة، ولذلك يخلط بينها باستمرار من يكتبون بحسب السمع. ومن بين الحروف الساكنة يبرز sub[m,n] = 180، وهما حرفان متشابهان في الصوت ومتجاوران على لوحة المفاتيح معًا.

The vowel corner of the substitution matrix, shaded by count; the outlined cell is sub[e,o] = 93, the edit behind acrossركن حروف العلة في مصفوفة الاستبدال، مظلَّل بحسب العدّ؛ والخلية المحاطة بإطار هي sub[e,o] = 93، التعديل الذي يقف خلف across

Where the counts come fromمن أين تأتي العدّات

You need a list of real misspellings paired with their corrections, such as the Wikipedia list of common misspellings, Roger Mitton's Birkbeck corpus, or Peter Norvig's collection. Align each pair, find the single edit, and add one to the matching cell. Slide 22 points to Norvig's file of counts of single-edit errors, which already does this: it lists edits such as e|i with a count, ready to drop into the four tables. Kernighan, Church and Gale had no such list, so they bootstrapped: start with uniform matrices, correct a corpus of rejected words with the current model, recount the edits the corrections imply, and repeat. That loop is an instance of the EM algorithm.

تحتاج إلى قائمة بأخطاء إملائية حقيقية مقرونة بتصحيحاتها، مثل قائمة ويكيبيديا للأخطاء الإملائية الشائعة، أو مدوّنة Birkbeck الخاصة بـ Roger Mitton، أو مجموعة Peter Norvig. حاذِ كل زوج، وجد التعديل الواحد، وأضف واحدًا إلى الخلية المطابقة. وتشير الشريحة 22 إلى ملف Norvig لعدّات أخطاء التعديل الواحد، الذي يقوم بهذا مسبقًا: فهو يسرد تعديلات مثل e|i مع عدّها، جاهزة للإدخال في الجداول الأربعة. لم يكن لدى Kernighan وChurch وGale قائمة كهذه، فبدؤوا من الصفر بطريقة تمهيدية (bootstrapping): ابدأ بمصفوفات منتظمة، وصحّح مدوّنة من الكلمات المرفوضة بالنموذج الحالي، وأعد عدّ التعديلات التي تقتضيها التصحيحات، ثم كرّر. وهذه الحلقة مثال على خوارزمية EM.

Quick checkاختبار سريع

Which statement correctly reads the cell sub[e,o] = 93 on slide 21?أي عبارة تقرأ الخلية sub[e,o] = 93 في الشريحة 21 قراءة صحيحة؟

Recall

State what del[x,y], ins[x,y] and trans[x,y] count, and say what insertion and deletion are conditioned on.اذكر ما تعدّه del[x,y] وins[x,y] وtrans[x,y]، وقل على أي شيء يُشترط الإدراج والحذف.

del[x,y]: xy typed as x. ins[x,y]: x typed as xy. trans[x,y]: xy typed as yx. Insertion and deletion are conditioned on the previous character, x.
del[x,y]: xy كُتبت x. ins[x,y]: x كُتبت xy. trans[x,y]: xy كُتبت yx. والإدراج والحذف مشروطان بالحرف السابق، x.

Back to across. The count sub[e,o] = 93 on its own is not a probability: it would be large simply because o is a common letter. The fair question is: of all the times a writer meant to type o, how often did e come out? In the training text of Kernighan, Church and Gale, the letter o occurred roughly 10,000,000 times, so P(e|o) = 93 / 10,000,000 = .0000093, the across row of slide 24.

لنعد إلى across. العدّ sub[e,o] = 93 وحده ليس احتمالًا: فقد يكون كبيرًا لمجرد أن o حرف شائع. والسؤال المنصف هو: من بين كل المرات التي قصد فيها الكاتب كتابة o، كم مرة خرج e؟ في نص التدريب الخاص بـ Kernighan وChurch وGale، ظهر الحرف o قرابة 10,000,000 مرة، لذا P(e|o) = 93 / 10,000,000 = .0000093، وهو صف across في الشريحة 24.

The general rule repeats that move for each edit: divide the confusion count by the number of times the intended context occurred. The context is whatever the matrix was indexed on in the correct word, so the denominator always counts letters of w, never of x.

القاعدة العامة تكرر هذه الخطوة لكل تعديل: اقسم عدّ الالتباس على عدد مرات ظهور السياق المقصود. والسياق هو ما فُهرست عليه المصفوفة في الكلمة الصحيحة، لذا فإن المقام يعدّ دائمًا حروف w، ولا يعدّ أبدًا حروف x.

P(x∣w)={del[wi−1,wi]count[wi−1wi]if deletionins[wi−1,xi]count[wi−1]if insertionsub[xi,wi]count[wi]if substitutiontrans[wi,wi+1]count[wiwi+1]if transpositionP(x \mid w) = \begin{cases} \dfrac{\text{del}[w_{i-1}, w_i]}{\text{count}[w_{i-1} w_i]} & \text{if deletion} \\[3mm] \dfrac{\text{ins}[w_{i-1}, x_i]}{\text{count}[w_{i-1}]} & \text{if insertion} \\[3mm] \dfrac{\text{sub}[x_i, w_i]}{\text{count}[w_i]} & \text{if substitution} \\[3mm] \dfrac{\text{trans}[w_i, w_{i+1}]}{\text{count}[w_i w_{i+1}]} & \text{if transposition} \end{cases}
Channel model of Kernighan, Church and Gale (1990), slide 23; wᵢ is the ith letter of the intended word, xᵢ of the typoنموذج القناة لـ Kernighan وChurch وGale (1990)، الشريحة 23؛ wᵢ هو الحرف رقم i في الكلمة المقصودة، وxᵢ في الكلمة الخاطئة
  • Deletion divides by count[wᵢ₋₁ wᵢ], the number of times the pair that was supposed to appear actually appears, because each occurrence was a chance to drop its second letter.الحذف يقسم على count[wᵢ₋₁ wᵢ]، أي عدد مرات ظهور الزوج الذي كان يُفترض أن يظهر، لأن كل ظهور له كان فرصة لإسقاط حرفه الثاني.
  • Insertion divides by count[wᵢ₋₁], a single letter, because each occurrence of it was a chance to type something extra afterwards. The numerator ins[wᵢ₋₁, xᵢ] names the extra typed letter xᵢ.الإدراج يقسم على count[wᵢ₋₁]، أي حرف واحد، لأن كل ظهور له كان فرصة لكتابة شيء زائد بعده. والبسط ins[wᵢ₋₁, xᵢ] يسمّي الحرف الزائد المكتوب xᵢ.
  • Substitution divides by count[wᵢ], the intended letter that got replaced.الاستبدال يقسم على count[wᵢ]، أي الحرف المقصود الذي استُبدل.
  • Transposition divides by count[wᵢ wᵢ₊₁], the intended pair that got swapped.التبديل يقسم على count[wᵢ wᵢ₊₁]، أي الزوج المقصود الذي تبادل حرفاه موقعيهما.

Mapping the acress table to the formulaربط جدول acress بالصيغة

Candidateالمرشحx|wx|wEditالتعديلCell / denominatorالخلية / المقامP(x|w)P(x|w)
actressactressc|ctc|ctdeletionحذفdel[c,t] / count[ct]del[c,t] / count[ct].000117.000117
cresscressa|#a|#insertionإدراجins[#,a] / count[#]ins[#,a] / count[#].00000144.00000144
caresscaressac|caac|catranspositionتبديلtrans[c,a] / count[ca]trans[c,a] / count[ca].00000164.00000164
accessaccessr|cr|csubstitutionاستبدالsub[r,c] / count[c]sub[r,c] / count[c].000000209.000000209
acrossacrosse|oe|osubstitutionاستبدالsub[e,o] / count[o]sub[e,o] / count[o].0000093.0000093
acresacreses|ees|einsertionإدراجins[e,s] / count[e]ins[e,s] / count[e].0000321.0000321
acresacresss|sss|sinsertionإدراجins[s,s] / count[s]ins[s,s] / count[s].0000342.0000342
Each row of slide 24 as a matrix cell over a denominatorكل صف من الشريحة 24 على شكل خلية مصفوفة مقسومة على مقام

Two rows need a closer look. For cress, the a at the start of acress is the extra letter, and there is no previous letter to condition on. The model uses a word-boundary symbol #, so the entry is a|#, priced as ins[#,a] / count[#], where count[#] is the number of word starts. Acres appears twice because there are two ways to read the extra s: inserted after e (es|e) or after the existing s (ss|s). Both are valid single edits, and in the original paper each row is scored as its own transformation; the two scores for acres are kept separate rather than merged.

صفّان يحتاجان إلى نظرة أدق. في cress، يكون الحرف a في بداية acress هو الحرف الزائد، ولا يوجد حرف سابق يُشترط عليه. فيستخدم النموذج رمز حدّ الكلمة #، فيصبح المدخل a|#، ويُحسب احتماله بـ ins[#,a] / count[#]، حيث count[#] هو عدد بدايات الكلمات. وتظهر acres مرتين لأن هناك طريقتين لقراءة s الزائد: مُدرج بعد e (es|e) أو بعد s الموجود أصلًا (ss|s). كلاهما تعديل واحد صالح، وفي الورقة الأصلية يُقيَّم كل صف بوصفه تحويلًا مستقلًا؛ فتبقى درجتا acres منفصلتين ولا تُدمجان.

Worked exampleمثال محلول

Compute P(x|w) for actress and acres from the paper's countsاحسب P(x|w) للكلمتين actress وacres من عدّات الورقة

  1. actress, deletion c|ctactress، حذف c|ct

    The t after c was dropped, so look up del[c,t] = 55. The pair ct occurred about 470,000 times. P(c|ct) = 55 / 470,000 = 1.17 × 10⁻⁴ = .000117.
    سقط الحرف t بعد c، فابحث عن del[c,t] = 55. ظهر الزوج ct قرابة 470,000 مرة. P(c|ct) = 55 / 470,000 = 1.17 × 10⁻⁴ = .000117.
  2. acres, insertion es|eacres، إدراج es|e

    An s was typed after e, so look up ins[e,s] = 417. The letter e occurred about 13,000,000 times. P(es|e) = 417 / 13,000,000 = 3.21 × 10⁻⁵ = .0000321.
    كُتب s بعد e، فابحث عن ins[e,s] = 417. ظهر الحرف e قرابة 13,000,000 مرة. P(es|e) = 417 / 13,000,000 = 3.21 × 10⁻⁵ = .0000321.
  3. acres, insertion ss|sacres، إدراج ss|s

    An s was typed after s: ins[s,s] = 205 over count[s] ≈ 6,000,000 gives 3.42 × 10⁻⁵ = .0000342.
    كُتب s بعد s: ins[s,s] = 205 مقسومًا على count[s] ≈ 6,000,000 يعطي 3.42 × 10⁻⁵ = .0000342.
  4. Resultالنتيجة

    The deletion for actress is about 3.4 to 3.6 times more probable than the acres insertions, and about 12.6 times more probable than the substitution for across.
    الحذف في actress أرجح بنحو 3.4 إلى 3.6 مرة من إدراجَي acres، وأرجح بنحو 12.6 مرة من الاستبدال في across.
InteractiveتفاعليConfusion-matrix lookup for acressالبحث في مصفوفة الالتباس لكلمة acress
Pick a candidate and its editاختر مرشحًا وتعديله

P(c|ct) = del[c,t] / count[ct] = 55 / 470,000

Editdeletion
Confusion count55del[c,t]
Letter count470,000count[ct]
P(x|w)1.17e-4slide .000117

actress: del[c,t] over count[ct] gives 1.17e-4

Counts are as printed by Kernighan, Church and Gale (1990). The letter counts are rounded in the paper, yet every quotient still reproduces the value on slide 24.الأعداد كما نشرها Kernighan وChurch وGale (1990). أعداد الحروف مقرّبة في الورقة، ومع ذلك يعيد كل ناتج قسمة القيمةَ نفسها الموجودة في الشريحة 24.

Zero counts are smoothedالعدّات الصفرية تُنعَّم

Look up sub[r,c] in slide 21: row r, column c is 0. Nobody in the training data typed r for c. Yet slide 24 gives access a channel probability of .000000209, not zero. The reason is that the matrices are smoothed before use; the paper uses Good-Turing, which turns the zero into a small fractional count, about .98, over count[c] ≈ 4,700,000. Caress shows the same pattern, with a fractional count of about .95 over count[ca] ≈ 580,000. Without smoothing, one unseen confusion would veto a candidate no matter how strong its prior, which is the same zero problem n-gram models had in lecture 03.

ابحث عن sub[r,c] في الشريحة 21: الصف r والعمود c قيمته 0. لم يكتب أحد في بيانات التدريب r بدلًا من c. ومع ذلك تعطي الشريحة 24 الكلمة access احتمال قناة قدره .000000209، لا صفرًا. والسبب أن المصفوفات تُنعَّم قبل استخدامها؛ إذ تستخدم الورقة Good-Turing، الذي يحوّل الصفر إلى عدّ كسري صغير، قرابة .98، مقسومًا على count[c] ≈ 4,700,000. وتُظهر caress النمط نفسه، بعدّ كسري يقارب .95 مقسومًا على count[ca] ≈ 580,000. ومن دون تنعيم، فإن التباسًا واحدًا لم يُشاهَد سيُسقط المرشح مهما كان احتماله المسبق قويًا، وهي مشكلة الصفر نفسها التي واجهتها نماذج n-gram في المحاضرة 03.

Quick checkاختبار سريع

For the candidate acres with x|w = ss|s, which denominator does the channel formula use?للمرشح acres حيث x|w = ss|s، ما المقام الذي تستخدمه صيغة القناة؟

Quick checkاختبار سريع

Why does slide 24 give access a nonzero P(r|c) when sub[r,c] is printed as 0?لماذا تعطي الشريحة 24 الكلمة access احتمالًا P(r|c) غير صفري مع أن sub[r,c] مطبوعة 0؟

Recall

Write the denominator for each of the four edit types in the Kernighan, Church and Gale formula.اكتب المقام لكل نوع من أنواع التعديل الأربعة في صيغة Kernighan وChurch وGale.

Deletion: count[wᵢ₋₁ wᵢ]. Insertion: count[wᵢ₋₁]. Substitution: count[wᵢ]. Transposition: count[wᵢ wᵢ₊₁]. All count letters of the intended word.
الحذف: count[wᵢ₋₁ wᵢ]. الإدراج: count[wᵢ₋₁]. الاستبدال: count[wᵢ]. التبديل: count[wᵢ wᵢ₊₁]. وكلها تعدّ حروف الكلمة المقصودة.

Recall

For cress, why is the entry written a|# and what is its denominator?في cress، لماذا يُكتب المدخل a|# وما مقامه؟

The extra a sits at the start of the word, so there is no previous letter; the word-boundary symbol # plays that role. It is an insertion, ins[#,a] / count[#], where count[#] is the number of word starts.
الحرف a الزائد يقع في بداية الكلمة، فلا يوجد حرف سابق؛ ويؤدي رمز حدّ الكلمة # هذا الدور. وهو إدراج، ins[#,a] / count[#]، حيث count[#] هو عدد بدايات الكلمات.

Recapالخلاصة

If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا

  • The prior P(w) comes from any language model; the unigram version is C(w)/N, for example P(actress) = 9,321 / 404,253,213 = .0000231.يأتي الاحتمال المسبق P(w) من أي نموذج لغوي؛ ونسخته أحادية الكلمة هي C(w)/N، فمثلًا P(actress) = 9,321 / 404,253,213 = .0000231.
  • Unigram priors ignore context, so across (120,844) beats actress (9,321) by a factor of about 13 before the typo is even considered.الاحتمالات المسبقة أحادية الكلمة تتجاهل السياق، لذلك تتفوق across (120,844) على actress (9,321) بعامل يقارب 13 قبل أن يُنظر إلى الخطأ الإملائي أصلًا.
  • The channel model P(x|w) is the probability of the single edit that turns the intended word w into the typed string x.نموذج القناة P(x|w) هو احتمال التعديل الواحد الذي يحوّل الكلمة المقصودة w إلى السلسلة المكتوبة x.
  • del[x,y] = count(xy typed as x), ins[x,y] = count(x typed as xy), trans[x,y] = count(xy typed as yx); insertion and deletion are conditioned on the previous character.del[x,y] = count(xy كُتبت x)، وins[x,y] = count(x كُتبت xy)، وtrans[x,y] = count(xy كُتبت yx)؛ والإدراج والحذف مشروطان بالحرف السابق.
  • sub[x,y] is indexed typed letter first, intended letter second: sub[e,o] = 93 means e was typed where o was meant.تُفهرس sub[x,y] بالحرف المكتوب أولًا ثم الحرف المقصود ثانيًا: sub[e,o] = 93 تعني أن e كُتب حيث كان المقصود o.
  • P(x|w) = confusion count / count of the intended context: count[w_{i-1} w_i] for deletion, count[w_{i-1}] for insertion, count[w_i] for substitution, count[w_i w_{i+1}] for transposition.P(x|w) = عدّ الالتباس / عدّ السياق المقصود: count[w_{i-1} w_i] للحذف، وcount[w_{i-1}] للإدراج، وcount[w_i] للاستبدال، وcount[w_i w_{i+1}] للتبديل.
  • Word start is the symbol #, so cress gives a|# = ins[#,a] / count[#].بداية الكلمة هي الرمز #، لذلك تعطي cress القيمة a|# = ins[#,a] / count[#].
  • Confusion counts are smoothed before use, which is why sub[r,c] = 0 in the matrix still yields P(r|c) = .000000209.تُنعَّم عدّات الالتباس قبل استخدامها، ولهذا فإن sub[r,c] = 0 في المصفوفة تعطي مع ذلك P(r|c) = .000000209.

Sourcesالمصادر