Majid Al-RaimiZipf and Heaps: the shape of vocabularyZipf وHeaps: شكل المفردات

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

Zipf and Heaps: the shape of vocabularyZipf وHeaps: شكل المفردات

Two empirical laws that explain why a few words are everywhere, most words are rare, and vocabulary never stops growing, and why that pushes NLP toward subword units.قانونان تجريبيان يفسران لماذا تنتشر كلمات قليلة في كل مكان بينما معظم الكلمات نادرة، ولماذا لا يتوقف نمو المفردات أبدا، ولماذا يدفع ذلك NLP نحو الوحدات الجزئية (subword units).

Conceptsالمفاهيم
4
Slidesالشرائح
11-16
Readingمدة القراءة
24 min24 دقيقة
Understoodما فهمته
0/4 conceptsمفاهيم

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

Every tokenizer, every n-gram smoother and every embedding table you will build for Arabic NLP is a response to two curves. One says that a handful of words carry most of any text while almost everything else is rare. The other says that no matter how much text you read, new words keep arriving.

Part 01 defined types and tokens and showed that corpora vary wildly in size. This part asks what the relationship between the two looks like, and the answer turns out to be the same for English, Arabic and undotted Arabic Wikipedia, with only the constants changing. Those constants are numbers you can quote in your own research on Arabic text, and the two formulas behind them are the kind of thing an exam asks you to compute with. By the end you should be able to look at a vocabulary size and say whether it is surprising, and to explain in one sentence why subword units exist.

كل tokenizer، وكل طريقة smoothing لنماذج الـ n-gram، وكل جدول embeddings ستبنيه لمعالجة اللغة العربية (Arabic NLP) هو استجابة لمنحنيين. الأول يقول إن حفنة من الكلمات تحمل معظم أي نص، بينما كل ما عداها تقريبًا نادر. والثاني يقول إنه مهما قرأت من نصوص فإن كلمات جديدة تستمر في الظهور.

عرّف الجزء 01 الأنواع (types) والـ tokens، وبيّن أن أحجام الـ corpora تتفاوت تفاوتًا كبيرًا. يسأل هذا الجزء كيف تبدو العلاقة بين الاثنين، ويتبيّن أن الجواب واحد لـ Wikipedia الإنجليزية والعربية والعربية غير المنقوطة، ولا يتغير إلا الثوابت. هذه الثوابت أرقام يمكنك الاستشهاد بها في بحثك الخاص على النصوص العربية، والصيغتان اللتان تقفان خلفها من النوع الذي يطلب منك الامتحان الحساب بهما. وفي النهاية يجب أن تستطيع النظر إلى حجم مفردات ما والحكم إن كان مفاجئًا، وأن تشرح في جملة واحدة لماذا توجد الوحدات الجزئية (subword units).

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

  1. State Zipf's law and compute f(R) from f(1) and α.أن تذكر قانون Zipf وتحسب f(R) من f(1) و α.
  2. Explain why a power law is a straight line on log-log axes, and diagnose the head and tail deviations on a real corpus.أن تشرح لماذا يظهر قانون القوة (power law) خطًا مستقيمًا على محورين لوغاريتميين (log-log)، وأن تشخّص انحرافات الرأس والذيل في corpus حقيقي.
  3. State Heaps' law, compute |V| for given k, β and N, and compare the English and Arabic Wikipedia fits.أن تذكر قانون Heaps، وتحسب |V| لقيم معطاة من k و β و N، وتقارن بين ملاءمتي Wikipedia الإنجليزية والعربية.
  4. Argue from Heaps' law why OOV words are unavoidable and why about half of all types are hapax legomena.أن تستنتج من قانون Heaps لماذا لا يمكن تجنّب الكلمات خارج المفردات (OOV)، ولماذا يكون نحو نصف الأنواع (types) من الـ hapax legomena.
  5. Connect sparsity and OOV to smoothing, backoff and subword tokenization.أن تربط الندرة (sparsity) والـ OOV بالـ smoothing والـ backoff والـ subword tokenization.

Take a novel, count every word, and sort the counts from largest to smallest. Manning and Schütze did exactly this for Mark Twain's Tom Sawyer: 71,370 tokens and 8,018 distinct types. The most frequent type is "the" with 3,332 occurrences, then "and" with 2,972, then "a" with 1,775. At the other end sit thousands of words like "applausive" that appear exactly once. The hundred most common types alone cover 50.9% of every token in the book.

خذ رواية، واحسب عدد مرات ظهور كل كلمة، ثم رتّب الأعداد من الأكبر إلى الأصغر. فعل Manning وSchütze ذلك بالضبط مع رواية Tom Sawyer لـ Mark Twain: 71,370 tokens و8,018 types مختلفة. أكثر الأنواع تكرارًا هو "the" بـ 3,332 مرة، ثم "and" بـ 2,972، ثم "a" بـ 1,775. وفي الطرف الآخر تقبع آلاف الكلمات مثل "applausive" التي تظهر مرة واحدة فقط. والأنواع المئة الأكثر شيوعًا وحدها تغطي 50.9% من كل الـ tokens في الكتاب.

Give each type a rank R, with R = 1 for the most frequent word. Now multiply frequency by rank. For most of the list the product hovers around a constant, roughly 8,000 to 10,000, a relationship Estoup noticed in 1916 and George Kingsley Zipf made famous in the 1930s and 1940s, so it carries Zipf's name. Zipf's law says that frequency falls off as a power of rank.

أعطِ كل نوع رتبة R، حيث R = 1 للكلمة الأكثر تكرارًا. ثم اضرب التكرار في الرتبة. في معظم القائمة يحوم حاصل الضرب حول قيمة ثابتة، تقريبًا من 8,000 إلى 10,000، وهي علاقة لاحظها Estoup عام 1916 وجعلها George Kingsley Zipf مشهورة في ثلاثينيات القرن العشرين وأربعينياته، فحملت اسم Zipf. ينص Zipf's law على أن التكرار يتناقص كقوة (power) للرتبة.

WordالكلمةFrequency fالتكرار fRank Rالرتبة Rf × Rf × R
thethe3,3323,332113,3323,332
andand2,9722,972225,9445,944
aa1,7751,775335,3255,325
hehe87787710108,7708,770
turnedturned515120020010,20010,200
applausiveapplausive118,0008,0008,0008,000
Tom Sawyer, from Manning and Schütze, Table 1.3 (the book prints 5,235 for "a", a transposition of 1,775 × 3 = 5,325)رواية Tom Sawyer، من Manning و Schütze، الجدول 1.3 (يطبع الكتاب 5,235 للكلمة "a"، وهو تبديل في ترتيب أرقام 1,775 × 3 = 5,325)
f(R)∝1Rα,α≈1f(R) \propto \frac{1}{R^{\alpha}}, \qquad \alpha \approx 1
Zipf's law: frequency as a power law in rankقانون Zipf: التكرار بوصفه قانون قوة في الرتبة

Because the law is a proportionality, the useful working form anchors it to the top word. If you know how often the most frequent word occurs, everything else follows from the rank alone.

لأن القانون علاقة تناسب، فالصيغة العملية المفيدة تربطه بالكلمة الأولى. إذا عرفت كم مرة تظهر الكلمة الأكثر تكرارًا، فكل ما عداها يُستنتج من الرتبة وحدها.

f(R)≈f(1)Rαf(R) \approx \frac{f(1)}{R^{\alpha}}
The form you compute withالصيغة التي تحسب بها

With α = 1 the arithmetic is nothing more than division. The word at rank 10 occurs about a tenth as often as the top word, the word at rank 1,000 about a thousandth as often. Slide 12 will show that natural language has α slightly below one, so the fall is a little gentler and the rare words a little less rare than the pure 1 / R rule predicts.

مع α = 1 لا يتعدى الحساب مجرد القسمة. الكلمة في الرتبة 10 تظهر بنحو عُشر تكرار الكلمة الأولى، والكلمة في الرتبة 1,000 بنحو جزء من ألف منه. وستبيّن الشريحة 12 أن اللغة الطبيعية لها α أقل من الواحد بقليل، فيكون الهبوط ألطف قليلًا والكلمات النادرة أقل ندرة قليلًا مما تتوقعه قاعدة 1 / R الصرفة.

Twenty bars shrinking by 1 / R, then a long tail of hairlines. The top three bars fall short of the teal curve fitted through the bulk: the head of a real corpus is flatter than the law.عشرون عمودًا تتقلص بنسبة 1 / R، ثم ذيل طويل من خطوط رفيعة جدًا. الأعمدة الثلاثة الأولى أقصر من المنحنى الأخضر المزرق (teal) الملائم لمعظم البيانات: رأس الـ corpus الحقيقي أكثر انبساطًا مما يقوله القانون.

Worked exampleمثال محلول

From f(1) to f(R)من f(1) إلى f(R)

  1. Fix the anchorثبّت نقطة الارتكاز

    Suppose the top word occurs f(1) = 1,000,000 times in a large Corpus.
    افترض أن الكلمة الأولى تظهر f(1) = 1,000,000 مرة في corpus كبير.
  2. Apply α = 1طبّق α = 1

    f(10) = 1,000,000 / 10 = 100,000 and f(1000) = 1,000,000 / 1000 = 1,000.
    f(10) = 1,000,000 / 10 = 100,000 وf(1000) = 1,000,000 / 1000 = 1,000.
  3. Apply the slide's α = 0.93طبّق قيمة الشريحة α = 0.93

    1000^0.93 = 10^(3 × 0.93) = 10^2.79 ≈ 617, so f(1000) ≈ 1,000,000 / 617 ≈ 1,622. At rank 10, 10^0.93 ≈ 8.51 gives f(10) ≈ 117,490.
    1000^0.93 = 10^(3 × 0.93) = 10^2.79 ≈ 617، لذا f(1000) ≈ 1,000,000 / 617 ≈ 1,622. وعند الرتبة 10، تعطي 10^0.93 ≈ 8.51 القيمة f(10) ≈ 117,490.
  4. Three exponents side by sideثلاثة أُسس جنبًا إلى جنب

    ααf(10)f(10)f(100)f(100)f(1000)f(1000)f(100,000)f(100,000)
    1.001.00100,000100,00010,00010,0001,0001,0001010
    0.930.93117,490117,49013,80413,8041,6221,6222222
    1.101.1079,43379,4336,3106,31050150133

Read the table across a row and you see the fall; read it down a column and you see what α does. A smaller exponent leaves more mass in the tail, which for a language model means more probability spread across rare words. A larger exponent concentrates the text in fewer types. The exponent is a property of the corpus, so it differs slightly between languages, genres and preprocessing choices such as case folding.

اقرأ الجدول عبر الصف فترى الهبوط، واقرأه نزولًا في العمود فترى أثر α. الأس الأصغر يترك كتلة أكبر في الذيل، وهذا يعني لنموذج اللغة احتمالًا أكبر موزعًا على الكلمات النادرة. والأس الأكبر يركّز النص في عدد أقل من الأنواع. الأس خاصية للـ corpus، لذا يختلف قليلًا بين اللغات والأنواع النصية (genres) وخيارات المعالجة المسبقة مثل توحيد حالة الأحرف (case folding).

Recall

The most frequent word in a corpus occurs 2,000,000 times. Under Zipf with α = 1, roughly how often does the rank 1,000 word occur? And with α = 0.9?الكلمة الأكثر تكرارًا في corpus تظهر 2,000,000 مرة. وفق Zipf مع α = 1، كم مرة تقريبًا تظهر الكلمة في الرتبة 1,000؟ وماذا لو كانت α = 0.9؟

With α = 1, about 2,000,000 / 1,000 = 2,000. With α = 0.9, 1000^0.9 = 10^2.7 ≈ 501, so about 2,000,000 / 501 ≈ 3,990. The smaller exponent leaves the rank 1,000 word almost twice as frequent.
مع α = 1، نحو 2,000,000 / 1,000 = 2,000. ومع α = 0.9، 1000^0.9 = 10^2.7 ≈ 501، أي نحو 2,000,000 / 501 ≈ 3,990. الأس الأصغر يجعل الكلمة في الرتبة 1,000 أكثر تكرارًا بنحو الضعف.

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

A corpus follows Zipf's law with α = 1 and its top word occurs 500,000 times. About how often does the word at rank 50 occur?corpus يتبع قانون Zipf مع α = 1، وكلمته الأولى تظهر 500,000 مرة. كم مرة تقريبًا تظهر الكلمة في الرتبة 50؟

Slide 12 plots rank against frequency for three corpora, English Wikipedia, Arabic Wikipedia and an undotted Arabic Wikipedia in which the dots that distinguish letters such as ب, ت and ث have been removed. Both axes are logarithmic, labelled from 10^0 to 10^6 in rank (the Arabic curve runs on to about 2 × 10^6) and to 10^7 in frequency, and two dashed straight lines, each pinned to the top word of its corpus, are drawn with α = 0.9252 for Arabic and α = 0.9290 for English. The first thing to understand is why anyone would expect a straight line at all.

ترسم الشريحة 12 الرتبة مقابل التكرار لثلاثة corpora: Wikipedia الإنجليزية، وWikipedia العربية، وWikipedia عربية غير منقوطة أُزيلت فيها النقاط التي تميّز حروفًا مثل ب وت وث. كلا المحورين لوغاريتمي، ومُعلَّمان من 10^0 إلى 10^6 في الرتبة (ويمتد المنحنى العربي إلى نحو 2 × 10^6) وحتى 10^7 في التكرار، ورُسم خطان مستقيمان متقطعان، كل منهما مثبّت عند الكلمة الأولى في الـ corpus الخاص به، بقيمة α = 0.9252 للعربية وα = 0.9290 للإنجليزية. أول ما يجب فهمه هو لماذا قد يتوقع أحد خطًا مستقيمًا أصلًا.

Write Zipf's law as an equation with a constant, f(R) = C · R^−α, and take the logarithm of both sides. A product becomes a sum and a power becomes a multiplier, which is the whole trick.

اكتب قانون Zipf كمعادلة فيها ثابت، f(R) = C · R^−α، وخذ اللوغاريتم للطرفين. يصبح الضرب جمعًا وتصبح القوة معاملًا مضروبًا، وهذه هي الحيلة كلها.

log⁡f=log⁡C−αlog⁡R\log f = \log C - \alpha \log R
A power law is linear in log-log coordinatesقانون القوة خطي في الإحداثيات اللوغاريتمية المزدوجة (log-log)

On axes that show log R and log f, this is the equation of a straight line with slope −α and intercept log C, which is log f(1) since log 1 = 0. The Stanford IR book states the special case directly: log cf_i = log c + k log i with k = −1. So the two fitted slopes on the slide, −0.9252 and −0.9290, are the exponents of the two Zipf fits, and the fact that they are nearly parallel says Arabic and English share the same kind of head-and-tail shape.

على محاور تعرض log R وlog f، هذه معادلة خط مستقيم ميله −α ومقطعه log C، وهو يساوي log f(1) لأن log 1 = 0. ويذكر كتاب Stanford IR الحالة الخاصة مباشرة: log cf_i = log c + k log i مع k = −1. إذن الميلان الملائمان في الشريحة، −0.9252 و−0.9290، هما أسّا ملاءمتي Zipf، وكونهما متوازيين تقريبًا يعني أن العربية والإنجليزية تشتركان في النوع نفسه من شكل الرأس والذيل.

A straight line of slope −α fitted through the bulk on log-log axes, then the empirical curve laid over it: bent at the head, on the line in the middle, and broken into integer steps at 3, 2 and 1 in the tail.خط مستقيم ميله −α ملائم لمعظم البيانات على محورين لوغاريتميين، ثم المنحنى التجريبي فوقه: منحنٍ عند الرأس، وعلى الخط في الوسط، ومنكسر إلى درجات من أعداد صحيحة عند 3 و2 و1 في الذيل.

Two places where the real curve leaves the lineموضعان يبتعد فيهما المنحنى الحقيقي عن الخط

Look at the slide again and the solid curves do not follow the dashed lines everywhere. They deviate in two characteristic ways, and both are diagnostic rather than noise. At the head, the curve is flatter than the power law: the top few words are common, but the drop from rank 1 to rank 10 is smaller than R^−α demands. This is the same shortfall the Tom Sawyer table showed: f × R was 3,332 for "the" against 8,000 to 10,000 further down, and it is why Mandelbrot added the shift term (R + ρ).

انظر إلى الشريحة مرة أخرى وستجد أن المنحنيات المتصلة لا تتبع الخطوط المتقطعة في كل مكان. فهي تنحرف بطريقتين مميزتين، وكلتاهما تشخيصية وليست ضجيجًا. عند الرأس يكون المنحنى أكثر انبساطًا من قانون القوة: الكلمات القليلة الأولى شائعة، لكن الهبوط من الرتبة 1 إلى الرتبة 10 أصغر مما يتطلبه R^−α. وهذا هو النقص نفسه الذي أظهره جدول Tom Sawyer: كان f × R يساوي 3,332 لـ "the" مقابل 8,000 إلى 10,000 في أسفل القائمة، وهذا سبب إضافة Mandelbrot لحد الإزاحة (R + ρ).

How that flat head looks on a plot depends on where the line is anchored. On slide 12 both fits pass through f(1). The blue English curve bulges slightly above the purple line only for ranks 2 to about 15, then runs just under it. The Arabic curves behave differently: they dip below the red line for ranks 3 to about 50 and cross back above it. At Wikipedia scale the head deviation is small, and the head is not uniformly flatter. The flat head is clearest in small texts such as Tom Sawyer and the explorer's sample; on slide 12 the dominant departure is the tail.

يتوقف شكل هذا الرأس المنبسط على الرسم على مكان تثبيت الخط. في الشريحة 12 تمر الملاءمتان كلتاهما عبر f(1). ينتفخ المنحنى الإنجليزي الأزرق قليلًا فوق الخط البنفسجي في الرتب من 2 إلى نحو 15 فقط، ثم يسير تحته مباشرة. أما المنحنيات العربية فتتصرف بشكل مختلف: تنخفض تحت الخط الأحمر في الرتب من 3 إلى نحو 50 ثم تعبر عائدة فوقه. على مقياس Wikipedia يكون انحراف الرأس صغيرًا، والرأس ليس أكثر انبساطًا بشكل منتظم. ويظهر الرأس المنبسط بأوضح صورة في النصوص الصغيرة مثل Tom Sawyer وعينة المستكشف (explorer)؛ أما في الشريحة 12 فالانحراف الغالب هو الذيل.

At the tail, beyond about rank 10^4, the curves steepen sharply below both lines and then turn into a staircase with horizontal steps at frequencies 3, 2 and 1, stretching out to about rank 2 × 10^6 for Arabic. The reason is that a frequency is a count, and counts are integers. There is no word that occurs 1.5 times. If 400,000 types each occur exactly once, they occupy 400,000 consecutive ranks at height f = 1, which draws as one long flat step. The step at f = 2 is shorter because fewer types occur exactly twice, and so on upward until the counts are large enough that adjacent ranks rarely share a value and the curve looks smooth. The bottom step is the longest because types seen once are the largest single group, the hapax legomena that concept four returns to.

عند الذيل، بعد الرتبة 10^4 تقريبًا، تنحدر المنحنيات بحدة تحت الخطين كليهما ثم تتحول إلى درج له درجات أفقية عند التكرارات 3 و2 و1، ممتدة حتى الرتبة 2 × 10^6 تقريبًا في العربية. والسبب أن التكرار عدد، والأعداد صحيحة. لا توجد كلمة تظهر 1.5 مرة. فإذا ظهر 400,000 نوع كل منها مرة واحدة بالضبط، فإنها تحتل 400,000 رتبة متتالية على الارتفاع f = 1، فتُرسم كدرجة مسطحة طويلة واحدة. والدرجة عند f = 2 أقصر لأن الأنواع التي تظهر مرتين بالضبط أقل عددًا، وهكذا صعودًا حتى تصبح الأعداد كبيرة بما يكفي فلا تتشارك الرتب المتجاورة القيمة نفسها إلا نادرًا، فيبدو المنحنى ناعمًا. والدرجة السفلى هي الأطول لأن الأنواع التي ظهرت مرة واحدة هي أكبر مجموعة منفردة، وهي الـ hapax legomena التي يعود إليها المفهوم الرابع.

What to read off a log-log rank-frequency plotما الذي تقرؤه من مخطط الرتبة والتكرار على محورين لوغاريتميين

Slope of the fitted lineميل الخط الملائم
−α, the Zipf exponent−α، أي سالب أس Zipf
Intercept at log R = 0المقطع عند log R = 0
log f(1), the frequency of the top wordlog f(1)، أي لوغاريتم تكرار الكلمة الأولى
Rightmost rank on the curveأقصى رتبة على يمين المنحنى
|V|, the number of types in the corpus|V|، أي عدد الأنواع (types) في الـ corpus
Length of the bottom stepطول الدرجة السفلى
The number of hapax legomenaعدد الـ hapax legomena
Bend at the head relative to the lineانحناء الرأس مقارنة بالخط
How much flatter the top few words are than the law; above a line pinned to f(1), below a line fitted through the bulkمقدار انبساط الكلمات القليلة الأولى مقارنة بالقانون؛ فوق خط مثبّت عند f(1)، وتحت خط ملائم لمعظم البيانات

One more thing the slide shows without saying it. In the tail, the Arabic curves sit above the English one: at any low count, Arabic has more types occurring at least that often. Templatic morphology and attached clitics mean that a single Arabic lexeme surfaces as many distinct spelled forms, each of which is a separate type for a whitespace tokenizer. That is a preview of the next concept, where the same fact shows up as a larger k in Heaps' law.

شيء آخر تُظهره الشريحة دون أن تقوله. في الذيل تقع المنحنيات العربية فوق المنحنى الإنجليزي: عند أي عدد منخفض، يكون لدى العربية أنواع أكثر تظهر بذلك العدد على الأقل. فالصرف القالبي (templatic morphology) واللواحق المتصلة (clitics) تجعل الوحدة المعجمية (lexeme) العربية الواحدة تظهر بأشكال إملائية كثيرة مختلفة، وكل منها نوع مستقل بالنسبة لـ tokenizer يقسّم على المسافات. وهذا تمهيد للمفهوم التالي، حيث تظهر الحقيقة نفسها كقيمة k أكبر في قانون Heaps.

SimulatorمحاكيZipf explorerمستكشف Zipf

Rank against frequencyالرتبة مقابل التكرار

The teal curve is the real count of every type in Pride and Prejudice, chapters 1 to 3 (3,438 tokens, 845 types). The dashed line is f(R) = C / R^α for the α you choose. With the best fit, C is the least-squares intercept over the top 200 ranks, currently 3.5× the top count f(1) = 125, so the head falls short of the line and the tail steps run under it.المنحنى الأخضر المزرق هو العدد الفعلي لتكرار كل نوع في Pride and Prejudice, chapters 1 to 3 (3,438 رمزًا و845 نوعًا). والخط المتقطع هو f(R) = C / R^α بقيمة α التي تختارها. مع أفضل ملاءمة، تكون C هي نقطة التقاطع بطريقة المربعات الصغرى على أعلى 200 رتبة، وهي حاليًا 3.5× من أعلى تكرار f(1) = 125، لذلك يقصر الرأس عن الخط وتقع درجات الذيل تحته.

Line anchorنقطة تثبيت الخط
10⁰10¹10²10⁰10¹10²rank Rfrequency fsample corpus441 / R^0.93
0.93
Fit versus sampleالملاءمة مقابل العينة
rankالرتبةpredictedالمتوقعobservedالمرصود
1051.848
1006.16
5001.41

The tail is a staircase because counts are integers: 475 types share the step at f = 1, 129 share f = 2, and 63 share f = 3.يبدو الذيل على شكل درج لأن التكرارات أعداد صحيحة: 475 نوعًا تشترك في الدرجة عند f = 1، و129 تشترك في f = 2، و63 تشترك في f = 3.

Recall

Why is a power law a straight line on log-log axes, and what does the slope tell you?لماذا يكون قانون القوة خطًا مستقيمًا على محورين لوغاريتميين، وماذا يخبرك الميل؟

Taking logs of f = C R^−α gives log f = log C − α log R, which is linear in log R. The slope is −α, so the steeper the line, the faster frequency falls with rank.
أخذ اللوغاريتم لـ f = C R^−α يعطي log f = log C − α log R، وهي خطية في log R. الميل يساوي −α، فكلما كان الخط أشد انحدارًا، هبط التكرار أسرع مع الرتبة.

Recall

Name the two visible departures from a Zipf line on a real corpus and give the cause of each.سمِّ الانحرافين الظاهرين عن خط Zipf في corpus حقيقي، واذكر سبب كل منهما.

Head flattening: the top few words drop off more slowly than R^−α, which Mandelbrot models with a shift (R + ρ); it shows as a bulge above a line pinned to f(1) (the English curve) or a shortfall under a line fitted through the bulk. Tail staircase: counts are integers, so all types with frequency 1, then 2, then 3 share one height and draw as horizontal steps.
انبساط الرأس: الكلمات القليلة الأولى تتناقص أبطأ مما يتطلبه R^−α، وهو ما يمثّله Mandelbrot بإزاحة (R + ρ)؛ ويظهر كانتفاخ فوق خط مثبّت عند f(1) (المنحنى الإنجليزي) أو كنقص تحت خط ملائم لمعظم البيانات. درج الذيل: الأعداد صحيحة، فكل الأنواع ذات التكرار 1، ثم 2، ثم 3 تشترك في ارتفاع واحد وتُرسم كدرجات أفقية.

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

On a log-log rank-frequency plot, what does the slope of the fitted straight line equal?على مخطط الرتبة والتكرار بمحورين لوغاريتميين، بماذا يساوي ميل الخط المستقيم الملائم؟

Zipf describes a Corpus frozen at one size. Now let the corpus grow. Read the first thousand words of Pride and Prejudice and you meet 361 distinct types. After ten thousand words the count is 1,698; after fifty thousand, 4,304; at the end of the novel, 123,627 tokens have produced 6,298 types. Each new stretch of text adds fewer new words than the last, but it never adds none. The same pattern holds across corpora of every size.

يصف Zipf corpus مجمّدًا عند حجم واحد. الآن دع الـ corpus ينمو. اقرأ أول ألف كلمة من Pride and Prejudice فتصادف 361 types مختلفة. بعد عشرة آلاف كلمة يصبح العدد 1,698، وبعد خمسين ألفًا 4,304، وفي نهاية الرواية تكون 123,627 tokens قد أنتجت 6,298 نوعًا. كل مقطع جديد من النص يضيف كلمات جديدة أقل مما أضافه سابقه، لكنه لا يتوقف عن الإضافة أبدًا. والنمط نفسه يتكرر في corpora من كل الأحجام.

Corpusالـ corpusInstances Nعدد الـ tokens NTypes |V|عدد الأنواع |V|
Shakespeareأعمال Shakespeare884 thousand884 ألف29 thousand29 ألف
Brown corpusBrown corpus1 million1 مليون38 thousand38 ألف
Switchboard telephone speechالكلام الهاتفي في Switchboard2.4 million2.4 مليون20 thousand20 ألف
COCACOCA440 million440 مليون2 million2 مليون
Google n-gramsGoogle n-grams1 trillion1 تريليون13 million13 مليون
Bigger corpus, bigger vocabulary, no ceiling (SLP3 chapter 2, Figure 2.1; the Google count includes only types seen 40 or more times)corpus أكبر، مفردات أكبر، بلا سقف (SLP3 الفصل 2، الشكل 2.1؛ عدد Google يشمل فقط الأنواع التي ظهرت 40 مرة أو أكثر)

The rule behind these numbers is Heaps' law, also called Herdan's law after the linguist who described it in 1960, nearly two decades before Heaps (1978). The Vocabulary size is a power of the token count, with an exponent strictly between zero and one.

القاعدة خلف هذه الأرقام هي Heaps' law، ويُسمى أيضًا قانون Herdan نسبة إلى اللغوي الذي وصفه عام 1960، قبل Heaps (1978) بنحو عقدين. حجم المفردات (vocabulary) قوة لعدد الـ tokens، بأس يقع بين الصفر والواحد حصرًا.

∣V∣=kNβ,0<β<1|V| = k N^{\beta}, \qquad 0 < \beta < 1
Heaps' (Herdan's) lawقانون Heaps (قانون Herdan)

The two halves of the constraint on β say two different things. Because β < 1, growth is sublinear: doubling the corpus does not double the vocabulary. Because β > 0, growth is unbounded: the derivative d|V| / dN = k β N^(β − 1) is positive for every N, so the curve keeps rising however far you extend it. SLP3 phrases the second half bluntly: no matter how big our vocabulary, we will never have a vocabulary that captures all the possible words that might occur.

نصفا القيد على β يقولان شيئين مختلفين. لأن β < 1، يكون النمو أبطأ من الخطي (sublinear): مضاعفة الـ corpus لا تضاعف المفردات. ولأن β > 0، يكون النمو غير محدود: المشتقة d|V| / dN = k β N^(β − 1) موجبة لكل N، فيستمر المنحنى في الصعود مهما مددته. ويصوغ SLP3 النصف الثاني بصراحة: مهما كبرت مفرداتنا، فلن نحصل أبدًا على مفردات تلتقط كل الكلمات الممكنة التي قد تظهر.

Three fitted vocabulary curves drawn out to a million tokens. The English curve's slope drops from 187 to 27 new types per thousand tokens, and the dotted ceiling fades because there is none.ثلاثة منحنيات مفردات ملائمة مرسومة حتى مليون token. ينخفض ميل المنحنى الإنجليزي من 187 إلى 27 نوعًا جديدًا لكل ألف token، ويتلاشى السقف المنقط لأنه لا يوجد سقف أصلًا.

The slide's three fits, and what the constants meanملاءمات الشريحة الثلاث، وماذا تعني الثوابت

Slide 14 fits the law to the same three corpora as before and reports k and β for each. The constants are worth reading as a pair. k is a multiplicative scale (the predicted |V| at N = 1) that shifts the whole curve up, and β sets the slope on log-log axes: the ratio between two corpus sizes, (N2 / N1)^β, depends on β alone. Plugging in three corpus sizes makes the comparison concrete.

تلائم الشريحة 14 القانون على الـ corpora الثلاثة نفسها كما سبق، وتذكر k وβ لكل منها. ويستحق الثابتان أن يُقرآ كزوج. k معامل قياس ضربي (قيمة |V| المتوقعة عند N = 1) يرفع المنحنى كله، وβ يحدد الميل على المحورين اللوغاريتميين: النسبة بين حجمين للـ corpus، (N2 / N1)^β، تعتمد على β وحدها. والتعويض بثلاثة أحجام للـ corpus يجعل المقارنة ملموسة.

Corpusالـ corpuskkββ|V| at 10⁴|V| عند 10⁴|V| at 10⁶|V| عند 10⁶|V| at 10⁸|V| عند 10⁸New types per 1,000 tokensالأنواع الجديدة لكل 1,000 token
English WikipediaWikipedia الإنجليزية14.94714.9470.5830.5833,2103,21047,04947,049689,531689,531187 at N = 10⁴187 عند N = 10⁴
Arabic WikipediaWikipedia العربية73.32173.3210.5330.5339,9369,936115,672115,6721,346,5681,346,56849 at N = 2.5 × 10⁵49 عند N = 2.5 × 10⁵
Undotted Arabic WikipediaWikipedia العربية غير المنقوطة90.49190.4910.5060.5069,5639,56398,31298,3121,010,6611,010,661not reportedغير مذكور
Slide 14 fits with |V| computed at three corpus sizesملاءمات الشريحة 14 مع حساب |V| عند ثلاثة أحجام للـ corpus

Worked exampleمثال محلول

English fit at one million tokensملاءمة الإنجليزية عند مليون token

  1. Exponentالأس

    N^β = (10^6)^0.583 = 10^(6 × 0.583) = 10^3.498.
    N^β = (10^6)^0.583 = 10^(6 × 0.583) = 10^3.498.
  2. Evaluate the powerاحسب القوة

    10^3.498 ≈ 3,147.8.
    10^3.498 ≈ 3,147.8.
  3. Multiply by kاضرب في k

    |V| ≈ 14.947 × 3,147.8 ≈ 47,049.
    |V| ≈ 14.947 × 3,147.8 ≈ 47,049.
  4. Resultالنتيجة

    About 47 thousand types. For comparison, the Brown corpus has 38 thousand types at one million tokens (SLP3 Figure 2.1), and the IR book's Reuters fit, 44 × 1,000,020^0.49, gives 38,323 against an actual 38,365. Same ballpark, different corpus.
    نحو 47 ألف نوع. وللمقارنة، لدى Brown corpus 38 ألف نوع عند مليون token (SLP3 Figure 2.1)، وملاءمة Reuters في كتاب IR، 44 × 1,000,020^0.49، تعطي 38,323 مقابل قيمة فعلية 38,365. الحجم نفسه تقريبًا، لكن الـ corpus مختلف.
SimulatorمحاكيHeaps explorerمستكشف Heaps

Vocabulary against corpus sizeحجم المفردات مقابل حجم المدونة

0500,0001,000,000121.5K0tokens Ntypes |V|dotted: straight line to the same endpoint
14.947
0.583
Vocabulary at three corpus sizesحجم المفردات عند ثلاثة أحجام للمدونة
N|V|new types per 1,000أنواع جديدة لكل 1,000
10⁴3,210187.2
10⁶47,04927.4
10⁸689,5314
Formulaالصيغة|V| = 14.947 · N^0.583Faint curves are the three slide fits for comparison.المنحنيات الباهتة هي الملاءمات الثلاث من الشرائح للمقارنة.
Growth per 100× more tokensالنمو عند زيادة الرموز 100×14.7×= 100^0.583Below 100 because β < 1, above 1 because β > 0: slower, never zero.أقل من 100 لأن β < 1، وأكبر من 1 لأن β > 0: نمو أبطأ لكنه لا يتوقف أبدًا.

Now compare languages. At a million tokens Arabic Wikipedia reaches 115,672 types, about two and a half times the English figure, and undotted Arabic reaches 98,312. Arabic gets there because of its k, 73 against 15: templatic morphology and attached clitics such as wa-, bi- and -hu multiply the surface forms of every lexeme, so the vocabulary is large from the very first pages. Its β is lower, though, so the curve bends sooner: a hundredfold larger corpus multiplies the English vocabulary by 100^0.583 ≈ 14.7 but the Arabic vocabulary by only 100^0.533 ≈ 11.6. Removing the dots collapses distinct letters into one shape, and the fit agrees that this shrinks the vocabulary: undotted Arabic is below dotted Arabic at every size in the table. Its larger k (90 against 73) is offset by its smaller β, and the two curves cross below about 2,400 tokens, so k alone never tells you which vocabulary is bigger; evaluate k N^β at the N you care about. Parts 03 and 04 explain the morphology.

قارن الآن بين اللغات. عند مليون token تصل Wikipedia العربية إلى 115,672 نوعًا، أي نحو مرتين ونصف قيمة الإنجليزية، وتصل العربية غير المنقوطة إلى 98,312. وتصل العربية إلى ذلك بسبب قيمة k لديها، 73 مقابل 15: فـ الصرف القالبي (templatic morphology) واللواحق المتصلة (clitics) مثل wa- وbi- و-hu تضاعف الأشكال السطحية لكل وحدة معجمية، فتكون المفردات كبيرة منذ الصفحات الأولى. لكن β لديها أقل، فينحني المنحنى أبكر: corpus أكبر بمئة مرة يضرب المفردات الإنجليزية في 100^0.583 ≈ 14.7 لكنه يضرب المفردات العربية في 100^0.533 ≈ 11.6 فقط. وإزالة النقاط تدمج حروفًا مختلفة في شكل واحد، والملاءمة تؤكد أن هذا يقلّص المفردات: العربية غير المنقوطة أدنى من العربية المنقوطة عند كل حجم في الجدول. وقيمة k الأكبر لديها (90 مقابل 73) يعوّضها β الأصغر، ويتقاطع المنحنيان تحت 2,400 token تقريبًا، لذا فإن k وحدها لا تخبرك أبدًا أي المفردات أكبر؛ احسب k N^β عند قيمة N التي تهمك. ويشرح الجزءان 03 و04 الصرف.

Typical values, and how the slide comparesالقيم المعتادة، وأين تقع منها قيم الشريحة

The constants reported across five reference points are easiest to read side by side.

الثوابت المذكورة عبر خمس نقاط مرجعية أسهل قراءة عندما توضع جنبًا إلى جنب.

Sourceالمصدرkkββ
SLP3, current draftSLP3، المسودة الحاليةnot givenغير مذكورة0.44 to 0.560.44 إلى 0.56
IR book, typicalكتاب IR، القيم المعتادة30 to 10030 إلى 100≈ 0.5≈ 0.5
Reuters-RCV1 (IR book)Reuters-RCV1 (كتاب IR)44440.490.49
Earlier SLP3 drafts, larger corporaمسودات SLP3 السابقة، corpora أكبرnot givenغير مذكورة0.67 to 0.750.67 إلى 0.75
Slide 14 fitsملاءمات الشريحة 1414.9 to 90.514.9 إلى 90.50.506 to 0.5830.506 إلى 0.583
Reported Heaps' law constants across sourcesثوابت قانون Heaps المذكورة في المصادر المختلفة

SLP3 summarizes the law as vocabulary growing a little faster than the square root of the corpus length in words, with β depending on corpus size and genre. The Arabic exponents, 0.533 and 0.506, fall inside SLP3's 0.44 to 0.56 band; the English 0.583 is just above it, which SLP3's "or even higher" allows. The English k of 14.9 is on the low side, which is what you get when a fit trades a smaller k for a larger β; the two constants are not independent estimates.

يلخّص SLP3 القانون بأن المفردات تنمو أسرع قليلًا من الجذر التربيعي لطول الـ corpus بالكلمات، مع اعتماد β على حجم الـ corpus ونوعه (genre). الأسّان العربيان، 0.533 و0.506، يقعان داخل نطاق SLP3 من 0.44 إلى 0.56؛ أما الأس الإنجليزي 0.583 فهو فوقه بقليل، وهو ما تسمح به عبارة SLP3 "or even higher" (أو حتى أعلى). وقيمة k الإنجليزية 14.9 في الجانب المنخفض، وهذا ما تحصل عليه عندما تقايض الملاءمة k أصغر بـ β أكبر؛ فالثابتان ليسا تقديرين مستقلين.

Recall

Using the English Wikipedia fit (k = 14.947, β = 0.583), how many types would you expect at 10^4 tokens and at 10^6 tokens?باستخدام ملاءمة Wikipedia الإنجليزية (k = 14.947، β = 0.583)، كم نوعًا تتوقع عند 10^4 token وعند 10^6 token؟

14.947 × 10^(4 × 0.583) = 14.947 × 10^2.332 ≈ 3,210 and 14.947 × 10^3.498 ≈ 47,049. The ratio is 100^0.583 ≈ 14.7, not 100.
14.947 × 10^(4 × 0.583) = 14.947 × 10^2.332 ≈ 3,210 و14.947 × 10^3.498 ≈ 47,049. النسبة بينهما 100^0.583 ≈ 14.7، وليست 100.

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

With k = 73.321 and β = 0.533, roughly how many types does a one-million-token Arabic corpus have under the slide's Heaps fit?مع k = 73.321 و β = 0.533، كم نوعًا تقريبًا يحتوي corpus عربي من مليون token وفق ملاءمة Heaps في الشريحة؟

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

Which statement about vocabulary growth under Heaps' law is correct?أي عبارة عن نمو المفردات وفق قانون Heaps صحيحة؟

Put the two laws together and a design problem falls out. In Tom Sawyer, 3,993 of the 8,018 types occur exactly once, which is 49.8%. In the three chapters of Pride and Prejudice inside the explorer, 475 of 845 types occur once, or 56%. A type seen exactly once is a Hapax legomenon, from the Greek for "read only once", and in corpus after corpus these are about half of everything a model must store.

اجمع القانونين معًا فتبرز مشكلة تصميمية. في Tom Sawyer، 3,993 من أصل 8,018 نوعًا تظهر مرة واحدة بالضبط، أي 49.8%. وفي الفصول الثلاثة من Pride and Prejudice داخل المستكشف، 475 من 845 نوعًا تظهر مرة واحدة، أي 56%. النوع الذي يُرى مرة واحدة بالضبط هو hapax legomenon، من اليونانية بمعنى "قُرئ مرة واحدة فقط"، وفي corpus تلو الآخر تشكّل هذه الأنواع نحو نصف كل ما يجب أن يخزّنه النموذج.

That one half is not a coincidence; it falls out of Zipf's law. With α = 1, the type at rank R has count C / R, so the number of types with count at least m is the rank at which the count drops to m, namely C / m. The types with count exactly m are then C / m − C / (m + 1) = C / (m (m + 1)), and dividing by the total C gives a share of 1 / (m (m + 1)): one half seen once, one sixth seen twice, one twelfth seen three times.

هذا النصف ليس مصادفة، فهو ينتج من قانون Zipf. مع α = 1، يكون عدد مرات ظهور النوع في الرتبة R هو C / R، لذا فعدد الأنواع التي يبلغ عددها m على الأقل هو الرتبة التي ينخفض عندها العدد إلى m، أي C / m. والأنواع التي عددها m بالضبط تكون إذن C / m − C / (m + 1) = C / (m (m + 1))، والقسمة على المجموع C تعطي حصة 1 / (m (m + 1)): النصف يُرى مرة واحدة، والسدس مرتين، وواحد من اثني عشر ثلاث مرات.

CountالعددZipf predictionتنبؤ ZipfTom SawyerTom SawyerSample corpusالـ corpus التجريبي
Exactly onceمرة واحدة بالضبط50%50%49.8%49.8%56%56%
Exactly twiceمرتان بالضبط16.7%16.7%16.1%16.1%15%15%
Share of types with a given count: Zipf prediction against two real corporaحصة الأنواع ذات عدد معيّن: تنبؤ Zipf مقابل corpus حقيقيين

Baayen (2001) develops this connection between the frequency spectrum and vocabulary growth in full, and it is why the bottom step of the staircase on slide 12 is the longest.

يطوّر Baayen (2001) هذه الصلة بين طيف التكرار (frequency spectrum) ونمو المفردات بالتفصيل، وهي السبب في أن الدرجة السفلى من الدرج في الشريحة 12 هي الأطول.

One hundred types from a corpus. About half light up as seen once, sixteen as seen twice, and a dashed square outside the grid stands for the type that was never seen at all.مئة نوع من corpus. نحو النصف يضيء لأنه ظهر مرة واحدة، وستة عشر لأنها ظهرت مرتين، ومربع متقطع خارج الشبكة يمثّل النوع الذي لم يظهر أبدًا.

Slides 15 and 16 list the consequences, and they form a chain rather than a list. Start with size. Heaps' law says a word-level Vocabulary on a large corpus runs to hundreds of thousands or millions of types, and every one of them needs a row in an embedding matrix and a column in the output softmax. Memory grows with |V| × d, where d is the embedding width. Then comes sparsity, which is Zipf's contribution: since half of those types belong to hapax legomena, half of the parameters in that matrix have been trained on a single example. Whatever the model learned about "applausive" it learned from one sentence.

تسرد الشريحتان 15 و16 العواقب، وهي تشكّل سلسلة لا قائمة. ابدأ بالحجم. يقول قانون Heaps إن المفردات (vocabulary) على مستوى الكلمة لـ corpus كبير تبلغ مئات الآلاف أو ملايين الأنواع، وكل منها يحتاج صفًا في مصفوفة الـ embeddings وعمودًا في الـ softmax الخاص بالمخرجات. تنمو الذاكرة مع |V| × d، حيث d عرض الـ embedding. ثم تأتي الندرة (sparsity)، وهي إسهام Zipf: بما أن نصف تلك الـ types من الـ hapax legomena، فنصف المعاملات في تلك المصفوفة دُرّبت على مثال واحد. فكل ما تعلمه النموذج عن "applausive" تعلّمه من جملة واحدة.

Next comes the guarantee. Because Heaps' law has a positive derivative at every N, any finite training corpus stops somewhere on a curve that is still rising. New text therefore always contains types that were never seen, and those types are out-of-vocabulary. This is not a defect of a small corpus that a bigger one would cure; a bigger corpus only pushes the OOV rate down along the same curve, never to zero. Finally, evaluation inherits the problem. Earlier SLP3 drafts warned that mapping unseen words to an <UNK> special token lets a model buy a lower perplexity simply by choosing a smaller vocabulary, since more of the test set collapses onto one easy symbol. The current chapter 3 sidesteps the issue by making the vocabulary subword tokens, so that, in its words, the test set can never contain unseen tokens.

ثم يأتي الضمان. لأن قانون Heaps له مشتقة موجبة عند كل N، فإن أي corpus تدريب محدود يتوقف عند نقطة ما على منحنى ما زال صاعدًا. لذلك يحتوي النص الجديد دائمًا على أنواع لم تُرَ من قبل، وتكون هذه الأنواع خارج المفردات (out-of-vocabulary). وهذا ليس عيبًا في corpus صغير يعالجه corpus أكبر؛ فالـ corpus الأكبر لا يفعل سوى دفع معدل الـ OOV إلى الأسفل على المنحنى نفسه، دون أن يوصله إلى الصفر أبدًا. وأخيرًا، يرث التقييم المشكلة. حذّرت مسودات SLP3 السابقة من أن ربط الكلمات غير المرئية بـ <UNK> بوصفه special token يسمح للنموذج بشراء perplexity أقل بمجرد اختيار مفردات أصغر، لأن جزءًا أكبر من مجموعة الاختبار ينهار على رمز واحد سهل. ويتجنب الفصل 3 الحالي المسألة بجعل المفردات subword tokens، بحيث لا يمكن لمجموعة الاختبار، بحسب عبارته، أن تحتوي أبدًا على tokens غير مرئية.

  • Huge word-level vocabularies: memory in the embedding and output layers scales with |V|.مفردات ضخمة على مستوى الكلمة: الذاكرة في طبقتي الـ embedding والمخرجات تتناسب مع |V|.
  • Sparsity: about half of all types are hapax legomena, so about half of the rows have one training example.الندرة (sparsity): نحو نصف الأنواع hapax legomena، لذا فنحو نصف الصفوف لها مثال تدريبي واحد.
  • Guaranteed OOV: Heaps' law keeps rising, so new text always brings unseen types.OOV مضمون: منحنى قانون Heaps يظل صاعدًا، فالنص الجديد يأتي دائمًا بأنواع غير مرئية.
  • Evaluation sensitivity: mapping unseen words to <UNK> changes what a perplexity number means.حساسية التقييم: ربط الكلمات غير المرئية بـ <UNK> يغيّر معنى رقم الـ perplexity.

Two answers to the same problemإجابتان عن المشكلة نفسها

The two families of language model respond to the chain at different points. N-gram models keep the word as the unit and repair the probability estimate: smoothing moves a little probability mass from seen events to unseen ones, and backoff falls back to a shorter context when the longer one was never observed. Lecture 3 and SLP3 chapter 3 develop both. Neural models change the unit instead. With Subword tokenization, learned by byte-pair encoding as Sennrich, Haddow and Birch showed for machine translation in 2016, a word never seen in training is spelled out of pieces that were, and with byte-level fallback there is nothing left that cannot be represented. The vocabulary becomes a design choice of tens of thousands of units rather than a fact about the corpus, which is exactly the trade part 6 examines.

تستجيب عائلتا نماذج اللغة للسلسلة عند نقطتين مختلفتين. نماذج الـ n-gram تُبقي الكلمة وحدةً وتُصلح تقدير الاحتمال: الـ smoothing ينقل قليلًا من كتلة الاحتمال من الأحداث المرئية إلى غير المرئية، والـ backoff يرجع إلى سياق أقصر عندما لا يكون السياق الأطول قد شوهد. وتطوّر المحاضرة 3 والفصل 3 من SLP3 كليهما. أما النماذج العصبية فتغيّر الوحدة نفسها. مع subword tokenization، المتعلَّم عبر byte-pair encoding كما بيّن Sennrich وHaddow وBirch للترجمة الآلية عام 2016، تُهجّى الكلمة التي لم تُرَ في التدريب من قطع رُئيت فيه، ومع الرجوع إلى مستوى البايت (byte-level fallback) لا يبقى شيء لا يمكن تمثيله. وتصبح المفردات خيارًا تصميميًا من عشرات الآلاف من الوحدات بدلًا من أن تكون حقيقة مفروضة من الـ corpus، وهذه بالضبط المقايضة التي يدرسها الجزء 6.

N-gram, word unitsN-gram، وحدات كلماتNeural, subword unitsعصبي، وحدات subword
Unit of the vocabularyوحدة المفرداتWhole wordsكلمات كاملةSubword pieces, or bytes as the floorقطع subword، أو البايتات (bytes) كحد أدنى
What happens to an unseen wordماذا يحدث لكلمة غير مرئيةMapped to <UNK> or given smoothed massتُربط بـ <UNK> أو تُعطى كتلة احتمال عبر الـ smoothingComposed from known pieces, so never unknownتُركَّب من قطع معروفة، فلا تكون مجهولة أبدًا
Where the fix livesأين يقع الإصلاحIn the probability estimate: smoothing, backoff, interpolationفي تقدير الاحتمال: smoothing وbackoff وinterpolationIn the tokenizer: BPE, WordPiece, byte fallbackفي الـ tokenizer: BPE وWordPiece والرجوع إلى مستوى البايت (byte fallback)
CostالكلفةProbability mass spent on events never seenكتلة احتمال تُنفق على أحداث لم تُرَ قطLonger token sequences, less interpretable unitsتسلسلات tokens أطول، ووحدات أقل قابلية للتفسير
Covered inأين يُشرحLecture 3 and SLP3 chapter 3المحاضرة 3 والفصل 3 من SLP3Part 6 of this lectureالجزء 6 من هذه المحاضرة
Word-level n-gram models versus subword neural modelsنماذج n-gram على مستوى الكلمة مقابل النماذج العصبية على مستوى الـ subword

Recall

In one sentence, why does Heaps' law guarantee OOV words?في جملة واحدة، لماذا يضمن قانون Heaps وجود كلمات OOV؟

Because |V| = k N^β keeps increasing for every N (its derivative is always positive), new text always brings types absent from any finite training corpus.
لأن |V| = k N^β تظل تتزايد لكل N (مشتقتها موجبة دائمًا)، فإن النص الجديد يأتي دائمًا بأنواع غائبة عن أي corpus تدريب محدود.

Recall

Define hapax legomenon and give the typical share of types it accounts for.عرّف الـ hapax legomenon واذكر الحصة المعتادة التي يمثّلها من الأنواع.

A type occurring exactly once in a corpus. Typically about half of all types: 49.8% in Tom Sawyer, 56% in the three-chapter sample corpus.
نوع يظهر مرة واحدة بالضبط في الـ corpus. وعادةً يشكّل نحو نصف كل الأنواع: 49.8% في Tom Sawyer، و56% في الـ corpus التجريبي ذي الفصول الثلاثة.

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

A model trained on 10 million tokens meets a word absent from its training data. Which mechanism lets a modern neural model represent it anyway?نموذج دُرّب على 10 ملايين token يصادف كلمة غائبة عن بيانات تدريبه. أي آلية تسمح لنموذج عصبي حديث بتمثيلها رغم ذلك؟

Recapالخلاصة

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

  • Rank types by count. Zipf: f(R) is proportional to 1 / R^α with α near 1 (0.9252 for Arabic and 0.9290 for English Wikipedia on slide 12).رتّب الأنواع (types) حسب عددها. ينص Zipf على أن f(R) تتناسب مع 1 / R^α حيث α قريبة من 1 (0.9252 لـ Wikipedia العربية و0.9290 للإنجليزية في الشريحة 12).
  • log f = log C − α log R is a line with slope −α. Real corpora flatten at the head (above a line pinned to f(1), below a line fitted through the bulk) and form integer steps at the tail.المعادلة log f = log C − α log R خط ميله −α. وتنبسط الـ corpora الحقيقية عند الرأس (فوق خط مثبّت عند f(1)، وتحت خط ملائم لمعظم البيانات) وتشكّل درجات من أعداد صحيحة عند الذيل.
  • Heaps: |V| = k N^β with 0 < β < 1, sublinear but unbounded. The English fit 14.947 N^0.583 gives 47,049 types at one million tokens; Arabic 115,672; undotted Arabic 98,312.Heaps: |V| = k N^β حيث 0 < β < 1، أي نمو أبطأ من الخطي (sublinear) لكنه غير محدود. ملاءمة الإنجليزية 14.947 N^0.583 تعطي 47,049 نوعًا عند مليون token، والعربية 115,672، والعربية غير المنقوطة 98,312.
  • The larger k for Arabic reflects templatic morphology and clitics. Typical β is 0.44 to 0.56 in the current SLP3 draft, and b ≈ 0.5 with 30 ≤ k ≤ 100 in the IR book.قيمة k الأكبر للعربية تعكس الصرف القالبي (templatic morphology) واللواحق المتصلة (clitics). القيمة المعتادة لـ β بين 0.44 و0.56 في مسودة SLP3 الحالية، وفي كتاب IR تكون b ≈ 0.5 مع 30 ≤ k ≤ 100.
  • Slide 14 plots the fitted formula out to 10^19 tokens. That is an extrapolation, not data.ترسم الشريحة 14 الصيغة الملائمة حتى 10^19 token. هذا استقراء (extrapolation) وليس بيانات.
  • About half of all types are hapax legomena (49.8% in Tom Sawyer, 56% in the sample corpus). Word vocabularies are huge and sparse, and OOV words are guaranteed.نحو نصف الأنواع hapax legomena (49.8% في Tom Sawyer و56% في الـ corpus التجريبي). مفردات الكلمات ضخمة ومتناثرة (sparse)، وظهور كلمات OOV مضمون.
  • N-gram models respond with smoothing and backoff. Neural models respond with subwords (BPE, part 6). Evaluation depends on how unseen items are treated.تستجيب نماذج الـ n-gram بالـ smoothing والـ backoff، وتستجيب النماذج العصبية بالـ subwords (BPE، الجزء 6). ويتوقف التقييم على طريقة معاملة العناصر غير المرئية.
  • Heaps' law is a consequence of Zipf's law (Lü, Zhang and Zhou 2010), not an independent law.قانون Heaps نتيجة لقانون Zipf (Lü وZhang وZhou 2010)، وليس قانونًا مستقلًا.

Sourcesالمصادر