Lecture 04 · Word Embeddings

المحاضرة 04 · تضمينات الكلمات (Word Embeddings)

Embedding Properties

خصائص الـ Embeddings

Slides 90–110 الشرائح 90–110 P2 SHOULD

The other ways to build embeddings, what the window size secretly controls, why analogies work and when they do not, and how you tell whether your vectors are any good.

الطرق الأخرى لبناء الـ embeddings، وما الذي يتحكم فيه حجم النافذة دون أن يظهر ذلك، ولماذا تنجح التناظرات (analogies) ومتى تفشل، وكيف تعرف ما إذا كانت متجهاتك جيدة أصلاً.

Two sections live in this range. Slides 90 to 93 are "Other Variations", the alternatives to skip-gram. Slide 94 is a divider, and from slide 95 on the deck is in "Properties of Embeddings", which is about what these vectors turn out to contain once you have them.

يضم هذا النطاق قسمين. الشرائح من 90 إلى 93 هي "Other Variations"، أي البدائل عن skip-gram. والشريحة 94 فاصل، ومن الشريحة 95 فصاعداً يدخل العرض في "Properties of Embeddings"، وهو عمّا يتبيّن أن هذه المتجهات تحتويه بعد أن تحصل عليها.

Slide 90: CBOW, skip-gram run backwards

الشريحة 90: CBOW، أي skip-gram معكوساً

Word2vec has two architectures and the exam will try to make you confuse them. The difference is one word: direction.

لـ word2vec معماريتان، والامتحان سيحاول أن يجعلك تخلط بينهما. والفرق كلمة واحدة: الاتجاه.

Skip-gram stands on the target word and predicts the context words around it. CBOW, Continuous Bag of Words, does the reverse: it stands on the context words and predicts the centre word.

skip-gram يقف على الكلمة الهدف ويتنبأ بكلمات السياق حولها. أما CBOW، أي Continuous Bag of Words، فيفعل العكس: يقف على كلمات السياق ويتنبأ بالكلمة المركزية.

The slide's sentence is "… I saw a cute grey cat playing in the garden …", with cat as the centre. CBOW takes cute, grey, playing, in, sums their vectors into a single hidden representation, and from that one summed vector predicts cat.

جملة الشريحة هي "… I saw a cute grey cat playing in the garden …"، والكلمة المركزية cat. يأخذ CBOW الكلمات cute وgrey وplaying وin، ويجمع متجهاتها في تمثيل مخفي واحد، ومن هذا المتجه المجموع الواحد يتنبأ بـ cat.

The word "bag" is doing real work in the name. The context vectors are summed, so the order of cute grey versus grey cute makes no difference. It is a bag, not a sequence. And "continuous" means the bag is a bag of dense vectors rather than a bag of discrete word identities.

كلمة "bag" (كيس) لها دور حقيقي في الاسم. متجهات السياق تُجمع، فلا فرق بين ترتيب cute grey وgrey cute. إنه كيس لا تسلسل. وكلمة "continuous" (متصل) تعني أن الكيس كيس من متجهات كثيفة (dense) لا كيس من هويات كلمات منفصلة.

Skip-gram target → context cat cute grey playing in one input, several outputs each (target, context) pair scored separately CBOW context → target cat cute grey playing in several inputs summed into one word order inside the bag is discarded
The arrows are the whole exam answer. Skip-gram's arrows point outward from the target; CBOW's point inward toward it. Same window, same corpus, opposite prediction direction.
الأسهم هي جواب الامتحان كله. أسهم skip-gram تتجه إلى الخارج من الكلمة الهدف، وأسهم CBOW تتجه إلى الداخل نحوها. النافذة نفسها، والمدوّنة نفسها، واتجاه التنبؤ معاكس.

يعرض الرسم skip-gram بأسهم تخرج من الكلمة الهدف إلى كلمات السياق، وCBOW بأسهم تدخل من كلمات السياق إلى الكلمة المركزية. الأسهم هي جواب الامتحان كله: أسهم skip-gram تشير إلى الخارج من الهدف، وأسهم CBOW تشير إلى الداخل نحوه. النافذة نفسها، والـ corpus نفسه، واتجاه التنبؤ معاكس.

Memory hook خطّاف للذاكرة

Skip-gram skips outward. CBOW bags inward.

Skip-gram يقفز إلى الخارج. CBOW يجمع في كيس إلى الداخل.

Or shorter: CBOW predicts the centre. If the thing being predicted is one word in the middle, it is CBOW. If the things being predicted are the neighbours, it is skip-gram.

أو باختصار: CBOW يتنبأ بالمركز. إذا كان الشيء المُتنبَّأ به كلمة واحدة في الوسط فهو CBOW. وإذا كانت الأشياء المُتنبَّأ بها هي الجيران فهو skip-gram.

Trap فخ

Students reliably swap these two under time pressure, usually because both diagrams show the same five words. Do not memorize the picture, memorize the arrow direction. Ask: what is the model's output? One centre word means CBOW. A set of neighbours means skip-gram.

يخلط الطلاب بين هذين باستمرار تحت ضغط الوقت، عادةً لأن الرسمين يعرضان الكلمات الخمس نفسها. لا تحفظ الصورة، احفظ اتجاه السهم. واسأل: ما مُخرَج النموذج؟ كلمة مركزية واحدة تعني CBOW، ومجموعة من الجيران تعني skip-gram.

Slide 91: GloVe

الشريحة 91: GloVe

GloVe stands for Global Vectors for Word Representation. The word "global" is the point of contrast. Word2vec only ever sees one window at a time, so it is local. GloVe starts from the full corpus-wide co-occurrence count N(w, c) and fits vectors to reproduce the log of those counts.

GloVe اختصار لـ Global Vectors for Word Representation. وكلمة "global" (شامل) هي نقطة المقارنة. فـ word2vec لا يرى إلا نافذة واحدة في كل مرة، فهو محلي. أما GloVe فيبدأ من عدّ الظهور المشترك الكامل على مستوى الـ corpus كله N(w, c)، ويضبط المتجهات لتعيد إنتاج لوغاريتم هذه العدّات.

The slide's objective, with the labels it puts on each piece:

دالة الهدف في الشريحة، مع التسميات التي تضعها على كل جزء:

J(θ) = Σw, c ∈ V f(N(w, c)) · ( ucT vw + bc + bw − log N(w, c) )2

تُقرأ المعادلة هكذا: نجمع على كل أزواج الكلمة والسياق w, c في المفردات V. ولكل زوج نأخذ مربع الفرق بين ucT vw + bc + bw وlog N(w, c)، ونضربه في الوزن f(N(w, c)).

The slide gives f two jobs: penalize rare events and not over-weight frequent events. The little plot beside it shows f rising from 0 and then going flat at 1 once the count passes a threshold xmax.

تعطي الشريحة الدالة f مهمتين: معاقبة الأحداث النادرة وعدم المبالغة في وزن الأحداث المتكررة. والرسم الصغير بجانبها يُظهر f ترتفع من 0 ثم تستوي عند 1 بمجرد أن يتجاوز العدّ العتبة xmax.

Read that curve as two separate protections. On the left, pairs that co-occurred once or twice get a weight near zero, so noise from rare accidental co-occurrences does not dominate. On the right, the curve caps at 1, so a pair that co-occurred ten million times does not count ten million times more than a pair that co-occurred ten thousand times. You have seen this instinct before: it is the same concern that produced the α = 0.75 exponent.

اقرأ هذا المنحنى على أنه حمايتان منفصلتان. على اليسار، الأزواج التي ظهرت معاً مرة أو مرتين تأخذ وزناً قريباً من الصفر، فلا يطغى الضجيج الناتج عن ظهور مشترك عرضي نادر. وعلى اليمين، يتوقف المنحنى عند 1، فالزوج الذي ظهر معاً عشرة ملايين مرة لا يُحسب أكثر بألف ضعف من زوج ظهر معاً عشرة آلاف مرة. لقد رأيت هذه الغريزة من قبل: إنه القلق نفسه الذي أنتج الأس α = 0.75.

Slide 92: fastText and subword information

الشريحة 92: fastText ومعلومات أجزاء الكلمة (subword)

Word2vec and GloVe both treat a word as an atom. run, runs, running and runner are four unrelated vocabulary entries, and a word that never appeared in training has no vector at all.

يعامل كل من word2vec وGloVe الكلمة كذرّة لا تتجزأ. فـ run وruns وrunning وrunner أربعة مدخلات في المفردات لا علاقة بينها، والكلمة التي لم تظهر في التدريب ليس لها متجه أصلاً.

fastText builds on word2vec by learning vector representations not just for each word but for the n-grams found within each word. The slide's three bullets:

يبني fastText على word2vec بتعلّم تمثيلات متجهية ليس لكل كلمة فقط، بل أيضاً لـ الـ n-grams الموجودة داخل كل كلمة. وهذه نقاط الشريحة الثلاث:

  1. Each word is represented as a bag of character n-grams.

    تُمثَّل كل كلمة على أنها كيس من character n-grams.

  2. A vector representation is associated with each n-gram.

    يرتبط بكل n-gram تمثيل متجهي.

  3. A word is represented by the sum of the vector representations of its n-grams.

    تُمثَّل الكلمة بـ مجموع التمثيلات المتجهية لـ n-grams التي فيها.

The slide is also explicit about the price: this adds a lot of additional computation to training. What you buy with it is that embeddings can encode sub-word information.

والشريحة صريحة أيضاً بشأن الثمن: هذا يضيف قدراً كبيراً من الحساب الإضافي إلى التدريب. وما تشتريه بهذا الثمن هو أن الـ embeddings تستطيع ترميز معلومات ما دون الكلمة (sub-word).

Trap فخ

fastText's advantage is not speed. The name says fast and the library is fast, but the slide says the opposite about this feature: subword n-grams add computation. The advantage is that it can build a vector for a word it has never seen, by summing the vectors of the character n-grams inside it, and that morphologically related words share n-grams and therefore share structure. That matters enormously for morphologically rich languages, Arabic and Turkish among them.

ميزة fastText ليست السرعة. الاسم يقول fast والمكتبة سريعة فعلاً، لكن الشريحة تقول العكس عن هذه الخاصية: الـ subword n-grams تضيف حساباً. الميزة هي أنه يستطيع بناء متجه لكلمة لم يرها قط، بجمع متجهات الـ character n-grams التي داخلها، وأن الكلمات المترابطة صرفياً تتشارك n-grams فتتشارك بنيةً. وهذا مهم جداً للغات الغنية صرفياً، ومنها العربية والتركية.

The three static embedding methods, side by side

طرق الـ embedding الثابتة (static) الثلاث، جنباً إلى جنب

word2vec (SGNS)word2vec (SGNS)GloVeGloVefastTextfastText
Core ideaالفكرة الجوهريةpredict, locallyالتنبؤ، محلياًfit global countsمطابقة العدّات الكلية (global)word2vec plus subwordsword2vec مع أجزاء الكلمة
What it readsما يقرؤهone window at a timeنافذة واحدة في كل مرةthe whole co-occurrence matrixمصفوفة الظهور المشترك كاملةone window at a timeنافذة واحدة في كل مرة
Smallest unitأصغر وحدةthe wordالكلمةthe wordالكلمةthe character n-gramn-gram الحروف
Objectiveدالة الهدفbinary logistic lossخسارة لوجستية ثنائية (binary logistic loss)weighted least squares on log N(w, c)مربعات صغرى موزونة على log N(w, c)binary logistic lossخسارة لوجستية ثنائية (binary logistic loss)
Bias termsحدود الانحياز (bias)noneلا يوجدbc and bw, both learnedbc وbw، وكلاهما مُتعلَّمnoneلا يوجد
Word unseen in trainingكلمة لم تُرَ في التدريبno vectorلا متجه لهاno vectorلا متجه لهاvector from its n-gramsمتجه من n-grams الخاصة بها
Downweights rare pairs byيخفّض وزن الأزواج النادرة عبرα = 0.75 samplingأخذ العينات بـ α = 0.75the weighting function fدالة الترجيح fα = 0.75 samplingأخذ العينات بـ α = 0.75

يقارن الجدول الطرق الثلاث. word2vec (SGNS) يتنبأ محلياً، ويقرأ نافذة واحدة في كل مرة، ووحدته الصغرى الكلمة، ودالة هدفه binary logistic loss، ولا حدود انحياز فيه، ولا متجه فيه لكلمة لم تظهر في التدريب، ويخفض وزن الأزواج النادرة بالمعاينة α = 0.75. وGloVe يلائم العدّات الشاملة، ويقرأ مصفوفة الظهور المشترك كاملة، ووحدته الصغرى الكلمة، ودالة هدفه مربعات صغرى مرجّحة على log N(w, c)، وفيه bc وbw وكلاهما متعلَّم، ولا متجه فيه لكلمة لم تظهر في التدريب، ويخفض وزن الأزواج النادرة بدالة الترجيح f. وfastText هو word2vec مع وحدات ما دون الكلمة، يقرأ نافذة واحدة في كل مرة، ووحدته الصغرى character n-gram، ودالة هدفه binary logistic loss، ولا حدود انحياز فيه، ويبني للكلمة غير المرئية متجهاً من n-grams التي فيها، ويخفض وزن الأزواج النادرة بالمعاينة α = 0.75. والخلايا المميّزة: قراءة GloVe للمصفوفة كاملة، ووحدة fastText الحرفية، ومتجهه للكلمات غير المرئية.

Slide 93: pushing skip-gram up to sentences

الشريحة 93: رفع skip-gram إلى مستوى الجمل

One slide, one idea. Skip-Thought Vectors (Kiros et al., NIPS 2015) ask what happens if you apply the skip-gram framing one level up.

شريحة واحدة وفكرة واحدة. Skip-Thought Vectors (Kiros et al., NIPS 2015) تسأل: ماذا يحدث لو طبّقت صياغة skip-gram على مستوى أعلى بدرجة واحدة؟

Before

قبل

Use a word to predict its surrounding context words.

قبل: استخدم كلمة للتنبؤ بـ كلمات السياق المحيطة بها.

Now

الآن

Encode a sentence to predict the sentences around it.

الآن: رمّز جملة للتنبؤ بـ الجمل المحيطة بها.

The distributional hypothesis, unchanged, with the unit swapped. A sentence is characterized by the sentences it keeps.

إنها distributional hypothesis نفسها دون تغيير، مع استبدال الوحدة. فالجملة تُعرَف بالجمل التي تصاحبها.

Slides 95 and 96: the window size decides what "similar" means

الشريحتان 95 و96: حجم النافذة يحدد معنى "متشابه"

This is the most examinable idea in the second half of the lecture, and it is not intuitive, so read it twice.

هذه أكثر فكرة قابلة للامتحان في النصف الثاني من المحاضرة، وهي ليست بديهية، فاقرأها مرتين.

The context window size is not a quality knob where bigger is better. It is a knob that changes what kind of relationship ends up encoded. Slide 95 states both settings with the same test word, Hogwarts.

حجم نافذة السياق ليس مقبض جودة كلما كبر كان أفضل. إنه مقبض يغيّر نوع العلاقة التي ينتهي بها الأمر مُرمَّزة. وتذكر الشريحة 95 الإعدادين بكلمة الاختبار نفسها، Hogwarts.

Small window, C = ±2نافذة صغيرة، C = ±2Large window, C = ±5نافذة كبيرة، C = ±5
Nearest words areأقرب الكلمات هيsyntactically similar words in the same taxonomyكلمات متشابهة نحوياً في التصنيف نفسه (taxonomy)related words in the same semantic fieldكلمات مترابطة في الحقل الدلالي نفسه (semantic field)
Neighbours of Hogwartsجيران HogwartsSunnydale, Evernight, BlandingsDumbledore, half-blood, Malfoy
What those areما هي هذه الكلماتother fictional schoolsمدارس خيالية أخرىthe Harry Potter worldعالم Harry Potter
Slide 96's labelتسمية الشريحة 96functional and syntactic similarityتشابه وظيفي ونحويtopical similarityتشابه موضوعي
Slide 96's dog exampleمثال الكلب في الشريحة 96Poodle, Rottweiler, Pitbulldog, bark, leash
Slide 96's verb exampleمثال الفعل في الشريحة 96walking, running, approachingwalking, walked, run
Informal nameالاسم غير الرسميsimilar: substitutableمتشابهة (similar): قابلة للاستبدالrelated: associatedمترابطة (related): متلازمة

يقارن الجدول بين نافذة صغيرة C = ±2 ونافذة كبيرة C = ±5. في النافذة الصغيرة تكون أقرب الكلمات متشابهة نحوياً ومن التصنيف نفسه، فجيران Hogwarts هي Sunnydale, Evernight, Blandings، أي مدارس خيالية أخرى، وتسمّيها الشريحة 96 تشابهاً وظيفياً ونحوياً (functional and syntactic similarity)، ومثال الكلاب Poodle, Rottweiler, Pitbull، ومثال الأفعال walking, running, approaching، واسمها غير الرسمي: متشابهة أي قابلة للإحلال (substitutable). وفي النافذة الكبيرة تكون أقرب الكلمات مترابطة من الحقل الدلالي نفسه، فالجيران Dumbledore, half-blood, Malfoy، أي عالم هاري بوتر، وتسمّيها الشريحة تشابهاً موضوعياً (topical similarity)، ومثال الكلاب dog, bark, leash، ومثال الأفعال walking, walked, run، واسمها غير الرسمي: مترابطة أي متصاحبة (associated).

Compare the two columns of the dog row. A small window groups Poodle, Rottweiler and Pitbull, which are three things of the same kind. You could swap one for another in a sentence and it would still read correctly. A large window groups dog, bark and leash, which are not the same kind of thing at all. They are a noun, a verb and an object, bound together by being about the same topic. You cannot substitute them for each other.

قارن عمودَي صف الكلاب. النافذة الصغيرة تجمع Poodle وRottweiler وPitbull، وهي ثلاثة أشياء من النوع نفسه، يمكنك أن تضع أحدها مكان الآخر في جملة وتبقى الجملة سليمة. أما النافذة الكبيرة فتجمع dog وbark وleash، وهي ليست من النوع نفسه إطلاقاً: اسم وفعل وأداة، يربطها أنها عن الموضوع نفسه. ولا يمكنك أن تضع أحدها مكان الآخر.

The verb row makes the same point from the other side. Small window: walking, running, approaching, all present participles, all filling the same grammatical slot. Large window: walking, walked, run, which are different tenses and forms, held together by all being about locomotion.

وصف الأفعال يوصل الفكرة نفسها من الجهة الأخرى. النافذة الصغيرة: walking وrunning وapproaching، كلها صيغ present participle تملأ الخانة النحوية نفسها. والنافذة الكبيرة: walking وwalked وrun، وهي أزمنة وصيغ مختلفة، يجمعها أنها كلها عن المشي والحركة.

small window, C = ±2 … [x x Hogwarts x x] … Hogwarts Sunnydale Evernight Blandings other fictional schools same taxonomy, substitutable large window, C = ±5 … [x x x x x Hogwarts x x x x x] … Hogwarts Dumbledore half-blood Malfoy the Harry Potter world same semantic field, associated
Slide 95's example drawn twice. Identical corpus, identical algorithm, identical word. Only the window width changed, and the neighbour set changed category completely.
مثال الشريحة 95 مرسوماً مرتين. المدوّنة نفسها، والخوارزمية نفسها، والكلمة نفسها. لم يتغير إلا عرض النافذة، فتغيرت فئة مجموعة الجيران تماماً.

مثال الشريحة 95 مرسوماً مرتين: لوحة لجيران Hogwarts مع النافذة الصغيرة، ولوحة مع النافذة الكبيرة. الـ corpus نفسه، والخوارزمية نفسها، والكلمة نفسها. لم يتغير إلا عرض النافذة، فتغيّرت فئة مجموعة الجيران بالكامل.

Memory hook خطّاف للذاكرة

Small window, same kind. Big window, same topic.

نافذة صغيرة: النوع نفسه. نافذة كبيرة: الموضوع نفسه.

Or: narrow is substitutable, wide is associated. Poodle/Rottweiler is narrow. Dog/leash is wide.

أو: الضيقة قابلة للإحلال، والواسعة متصاحبة. Poodle/Rottweiler ضيقة، وDog/leash واسعة.

Trap فخ

A bigger window is not a better window. It is a different question. If your downstream task needs part-of-speech-like or synonym-like behaviour, a wide window actively hurts you. If your task is topic classification or retrieval, a narrow window hurts you. There is no setting that wins both, which is why slide 88 gives a range (5 to 10) rather than a number and SLP3 says the window size is tuned on a devset.

النافذة الأكبر ليست نافذة أفضل. إنها سؤال مختلف. إذا كانت مهمتك اللاحقة تحتاج سلوكاً يشبه أقسام الكلام (part-of-speech) أو المرادفات، فالنافذة الواسعة تضرّك فعلاً. وإذا كانت مهمتك تصنيف مواضيع أو استرجاعاً، فالنافذة الضيقة تضرّك. لا يوجد إعداد يفوز في الحالتين، ولهذا تعطي الشريحة 88 مدى (من 5 إلى 10) لا رقماً واحداً، ويقول SLP3 إن حجم النافذة يُضبط على devset.

Slides 97 and 98: analogies and the parallelogram

الشريحتان 97 و98: التناظرات (analogies) ومتوازي الأضلاع

Slide 97 introduces a model that predates embeddings entirely: the classic parallelogram model of analogical reasoning (Rumelhart and Abrahamson, 1973).

تقدّم الشريحة 97 نموذجاً يسبق الـ embeddings كلياً: نموذج متوازي الأضلاع الكلاسيكي للاستدلال بالتناظر (parallelogram model of analogical reasoning) (Rumelhart and Abrahamson, 1973).

The puzzle: "apple is to tree as grape is to ______". The parallelogram answer: compute the vector tree − apple, which is the "grows on" relation as a direction in space, then add that direction to grape. You land near vine.

اللغز: "apple is to tree as grape is to ______"، أي التفاحة إلى الشجرة كالعنب إلى ماذا؟ وجواب متوازي الأضلاع: احسب المتجه tree − apple، وهو علاقة "ينمو على" ممثلةً كاتجاه في الفضاء، ثم أضف هذا الاتجاه إلى grape. فتصل قريباً من vine (الكرمة).

The geometric name comes from the shape this makes. Four points with two parallel equal-length sides is a parallelogram. Slide 97 literally draws it.

الاسم الهندسي يأتي من الشكل الناتج. أربع نقاط بضلعين متوازيين متساويين في الطول تشكّل متوازي أضلاع، والشريحة 97 ترسمه حرفياً.

Slide 98 says this method works with both sparse and dense embeddings (Turney and Littman 2005, Mikolov et al. 2013b), and gives the two famous demonstrations:

تقول الشريحة 98 إن هذه الطريقة تعمل مع الـ embeddings المتناثرة (sparse) والكثيفة (dense) معاً (Turney and Littman 2005, Mikolov et al. 2013b)، وتعطي المثالين الشهيرين:

king − man + woman is close to queen Paris − France + Italy is close to Rome

السطر الأول: king − man + woman قريب من queen. والسطر الثاني: Paris − France + Italy قريب من Rome.

Then the general form. For a problem written a : a* :: b : b*, meaning you are given a, a* and b and must find b*, the slide writes:

ثم الصيغة العامة. لمسألة مكتوبة على الشكل a : a* :: b : b*، أي يُعطى لك a وa* وb وعليك إيجاد b*، تكتب الشريحة:

b̂* = argmaxx distance(x, a* − a + b)

تقول المعادلة إن التقدير b̂* هو الكلمة x التي تحقق argmax لـ distance(x, a* − a + b). أي نبني النقطة a* − a + b ثم نبحث عن الكلمة المطابقة لها. وانظر ملاحظة الترميز أدناه حول argmax وargmin.

Match this against the king example and the letters stop being scary. a = man, a* = king, b = woman, so a* − a + b = king − man + woman, and b̂* is queen.

طابق هذا مع مثال king فتكفّ الحروف عن أن تكون مخيفة. a = man، وa* = king، وb = woman، إذن a* − a + b = king − man + woman، وb̂* هو queen.

Notation note ملاحظة عن الرموز

The slide writes argmax distance. The textbook writes the same equation as argmin distance (SLP3 chapter 5, eq. 5.28, "with some distance function, such as Euclidean distance"). The intent is identical in both: you want the vector x that is closest to a* − a + b. Whichever form the exam shows you, read it as "find the nearest word". If you are asked to write it yourself, argmin distance (or equivalently argmax similarity) is the safe version.

تكتب الشريحة argmax distance. ويكتب الكتاب المعادلة نفسها بـ argmin distance (SLP3 الفصل 5، المعادلة 5.28، "with some distance function, such as Euclidean distance"). والمقصود واحد في الحالتين: تريد المتجه x الأقرب إلى a* − a + b. وأياً كانت الصيغة التي يعرضها الامتحان، اقرأها على أنها "أوجد أقرب كلمة". وإذا طُلب منك كتابتها بنفسك، فـ argmin distance (أو ما يكافئها argmax similarity) هي الصيغة الآمنة.

0 dimension 1 dimension 2 man [2, 1] woman [3, 2] king [7, 4] queen [9, 7] princess [8, 8] king − man + woman = [8, 5] the royalty offset [5, 3] same offset, applied to woman the two long arrows are parallel and equal length: that is the parallelogram
The parallelogram with the illustrative numbers used in the worked example below. The arrow man → king is the relation. Copy it onto woman and the tip lands at [8, 5]. The nearest real word to that tip, once the three input words are excluded, is queen.
متوازي الأضلاع بالأرقام التوضيحية المستخدمة في المثال المحلول أدناه. السهم man → king هو العلاقة. انسخه على woman فيقع رأسه عند [8, 5]. وأقرب كلمة حقيقية إلى ذلك الرأس، بعد استبعاد كلمات الإدخال الثلاث، هي queen.

الرسم مستوٍ ثنائي الأبعاد عليه man وwoman وking وqueen بالأرقام التوضيحية المستخدمة في المثال المحلول أدناه. السهم man → king هو العلاقة. انسخه على woman فيقع رأسه عند [8, 5]. وأقرب كلمة حقيقية إلى هذا الرأس، بعد استبعاد كلمات المدخلات الثلاث، هي queen.

Worked مثال محلول

Illustrative two-dimensional vectors, invented so the arithmetic is exact. The slide gives no numbers.

متجهات توضيحية ثنائية الأبعاد، اختُرعت لتكون الحسابات دقيقة. الشريحة لا تعطي أرقاماً.

VOCABULARY
  man      = [2, 1]
  woman    = [3, 2]
  king     = [7, 4]
  queen    = [9, 7]
  princess = [8, 8]

PROBLEM:  man : king  ::  woman : ?
  so a = man, a* = king, b = woman

STEP 1, build the target point  t = a* - a + b
  dimension 1:  7 - 2 + 3 = 8
  dimension 2:  4 - 1 + 2 = 5
  t = [8, 5]

STEP 2, Euclidean distance from t to every candidate
  king:      (7-8)^2 + (4-5)^2 = 1 + 1  =  2   -> sqrt(2)  = 1.4142
  queen:     (9-8)^2 + (7-5)^2 = 1 + 4  =  5   -> sqrt(5)  = 2.2361
  princess:  (8-8)^2 + (8-5)^2 = 0 + 9  =  9   -> sqrt(9)  = 3.0000
  woman:     (3-8)^2 + (2-5)^2 = 25 + 9 = 34   -> sqrt(34) = 5.8310
  man:       (2-8)^2 + (1-5)^2 = 36 + 16 = 52  -> sqrt(52) = 7.2111

STEP 3, rank them
  1.4142  king        <- an INPUT word
  2.2361  queen
  3.0000  princess
  5.8310  woman       <- an INPUT word
  7.2111  man         <- an INPUT word

STEP 4, the answer
  raw nearest neighbour  = king, which is one of the three inputs
  after excluding a, a*, b = queen, at distance 2.2361      correct

المفردات: man = [2, 1]، وwoman = [3, 2]، وking = [7, 4]، وqueen = [9, 7]، وprincess = [8, 8]. المسألة man : king :: woman : ?، أي a = man وa* = king وb = woman. الخطوة 1: النقطة الهدف t = a* - a + b، في البعد الأول 7 - 2 + 3 = 8 وفي الثاني 4 - 1 + 2 = 5، فـ t = [8, 5]. الخطوة 2: المسافة الإقليدية من t إلى كل مرشّح: king تساوي sqrt(2) = 1.4142، وqueen تساوي sqrt(5) = 2.2361، وprincess تساوي sqrt(9) = 3.0000، وwoman تساوي sqrt(34) = 5.8310، وman تساوي sqrt(52) = 7.2111. الخطوة 3: الترتيب يضع king أولاً وهي من كلمات المدخلات، ثم queen، ثم princess، ثم woman وman وهما من المدخلات أيضاً. الخطوة 4: أقرب جار خام هو king، وهو أحد المدخلات الثلاثة، وبعد استبعاد a وa* وb يصبح الجواب queen على مسافة 2.2361، وهو الصحيح.

Step 4 is not a quirk of these made-up numbers. It is the normal behaviour. See the caveat below.

الخطوة 4 ليست غرابة خاصة بهذه الأرقام المصطنعة، بل هي السلوك المعتاد. انظر التحذير أدناه.

Slides 99, 100 and 101: what the offsets look like at scale

الشرائح 99 و100 و101: كيف تبدو الإزاحات على نطاق واسع

Slides 99 and 100 show the same claim with real embeddings. The equations repeated at the top are:

تعرض الشريحتان 99 و100 الادعاء نفسه مع embeddings حقيقية. والمعادلتان المكررتان في الأعلى هما:

vector('king') − vector('man') + vector('woman') ≈ vector('queen') vector('Paris') − vector('France') + vector('Italy') ≈ vector('Rome')

أي أن متجه king ناقص متجه man زائد متجه woman يساوي تقريباً متجه queen، وأن متجه Paris ناقص متجه France زائد متجه Italy يساوي تقريباً متجه Rome.

The plots underneath show that the arrow from man to woman and the arrow from uncle to aunt and the arrow from king to queen all point roughly the same way and have roughly the same length. Slide 100 adds two more families of the same shape: verb tense (walking to walked, swimming to swam) and country to capital (Spain to Madrid, Japan to Tokyo, and so on, drawn as a bundle of near-parallel lines).

تُظهر الرسوم تحتها أن السهم من man إلى woman، والسهم من uncle إلى aunt، والسهم من king إلى queen، كلها تشير تقريباً إلى الاتجاه نفسه ولها تقريباً الطول نفسه. وتضيف الشريحة 100 عائلتين أخريين بالشكل نفسه: زمن الفعل (walking إلى walked، وswimming إلى swam)، والدولة إلى عاصمتها (Spain إلى Madrid، وJapan إلى Tokyo، وهكذا، مرسومة كحزمة من الخطوط شبه المتوازية).

Slide 101 is the GloVe version of the same picture, a scatter plot where brother/sister, nephew/niece, uncle/aunt, heir/heiress, sir/madam, king/queen, earl/countess, duke/duchess and emperor/empress are each joined by a dashed line, and all the dashed lines run in roughly the same direction.

الشريحة 101 هي نسخة GloVe من الصورة نفسها: رسم نقطي (scatter plot) يُربط فيه كل من brother/sister وnephew/niece وuncle/aunt وheir/heiress وsir/madam وking/queen وearl/countess وduke/duchess وemperor/empress بخط متقطع، وكل الخطوط المتقطعة تسير تقريباً في الاتجاه نفسه.

That parallelism is the content. It means a relation such as "male to female" is not stored anywhere in particular; it is a consistent direction in the space, and the same direction works for many pairs. That is why vector arithmetic can answer an analogy at all.

هذا التوازي هو المضمون. معناه أن علاقة مثل "مذكّر إلى مؤنث" ليست مخزّنة في مكان بعينه، بل هي اتجاه ثابت في الفضاء، والاتجاه نفسه يصلح لأزواج كثيرة. ولهذا تستطيع الحسابات المتجهية أن تجيب عن تناظر أصلاً.

Slide 102: the caveats, which are examinable

الشريحة 102: التحفظات، وهي مما يُختبر فيه

The slide is short and every clause matters. The parallelogram method only seems to work for:

الشريحة قصيرة وكل عبارة فيها مهمة. طريقة متوازي الأضلاع لا تبدو ناجحة إلا مع:

Cited: Linzen 2016, Gladkova et al. 2016, Ethayarajh et al. 2019a. And the closing line: understanding analogy is an open area of research (Peterson et al. 2020).

المراجع المذكورة: Linzen 2016، وGladkova et al. 2016، وEthayarajh et al. 2019a. والسطر الختامي: فهم التناظر مجال بحث مفتوح (Peterson et al. 2020).

Trap فخ

The famous demos are quietly rigged. SLP3 chapter 5 spells out what slide 102 compresses: the closest vector returned by the parallelogram algorithm in word2vec or GloVe space is usually not b*, but one of the three input words or a morphological variant of one. Their example is cherry : red :: potato : x, which returns potato or potatoes rather than brown. So implementations explicitly exclude a, a* and b from the candidate list.

العروض الشهيرة مُرتَّبة بصمت. يشرح SLP3 في الفصل 5 ما تختصره الشريحة 102: المتجه الأقرب الذي تُرجعه خوارزمية متوازي الأضلاع في فضاء word2vec أو GloVe ليس عادةً b*، بل إحدى كلمات المدخلات الثلاث أو صيغة صرفية منها. ومثالهم cherry : red :: potato : x، الذي يُرجع potato أو potatoes بدلاً من brown. لذلك تستبعد التطبيقات صراحةً a وa* وb من قائمة المرشحين.

This is exactly what step 4 of the worked example above demonstrates. If an exam asks why "king − man + woman = queen" overstates how well embeddings do analogies, the exclusion of the input words is a correct and specific answer, alongside the frequent-words-only and some-relations-only limits.

وهذا بالضبط ما توضحه الخطوة 4 في المثال المحلول أعلاه. فإذا سألك الامتحان لماذا تبالغ "king − man + woman = queen" في تصوير قدرة الـ embeddings على التناظر، فاستبعاد كلمات المدخلات جواب صحيح ومحدد، إلى جانب قيدَي "الكلمات المتكررة فقط" و"بعض العلاقات فقط".

Slide 103: embeddings as a window onto historical semantics

الشريحة 103: الـ embeddings نافذة على الدلالات التاريخية

Train separate embedding spaces on different decades of historical text, then watch where a word moves. The source is around 30 million books from Google Books covering 1850 to 1990 (Hamilton, Leskovec and Jurafsky, 2016, ACL).

درّب فضاءات embedding منفصلة على عقود مختلفة من النصوص التاريخية، ثم راقب إلى أين تتحرك الكلمة. المصدر نحو 30 مليون كتاب من Google Books تغطي الفترة من 1850 إلى 1990 (Hamilton, Leskovec and Jurafsky, 2016, ACL).

The slide shows three words drifting, each labelled by decade with its nearest neighbours at that time:

تعرض الشريحة ثلاث كلمات ينجرف معناها، كل واحدة موسومة بالعقد مع أقرب جيرانها في ذلك الوقت:

WordالكلمةEarlier neighboursالجيران الأقدمLater neighboursالجيران الأحدث
gay1900s: daft, flaunting, tasteful, frolicsome, witty
1950s: bright, cheerful, pleasant
1990s: homosexual, lesbian, bisexual, gays
broadcast1850s: sow, seed, scatter
1900s: newspapers, circulated
1990s: television, radio, bbc
awful1850s: solemn, majestic, awe, dread1900s: appalling, terrible, horrible
1990s: wonderful, weird, awfully

يتتبع الجدول ثلاث كلمات. gay: في 1900s كان جيرانها daft, flaunting, tasteful, frolicsome, witty، وفي 1950s bright, cheerful, pleasant، ثم في 1990s homosexual, lesbian, bisexual, gays. وbroadcast: في 1850s sow, seed, scatter، وفي 1900s newspapers, circulated، ثم في 1990s television, radio, bbc. وawful: في 1850s solemn, majestic, awe, dread، ثم في 1900s appalling, terrible, horrible، وفي 1990s wonderful, weird, awfully.

broadcast is the clearest: it began as an agricultural term meaning to scatter seed widely, and the sense was carried over to scattering a signal widely. The embeddings recover that without anyone telling them.

broadcast هي الأوضح: بدأت مصطلحاً زراعياً معناه نثر البذور على نطاق واسع، ثم انتقل المعنى إلى بثّ الإشارة على نطاق واسع. والـ embeddings تستعيد ذلك دون أن يخبرها أحد.

Slides 104 and 105: embeddings reflect cultural bias

الشريحتان 104 و105: الـ embeddings تعكس التحيز الثقافي

Slide 104 (Bolukbasi et al., NeurIPS 2016) runs the parallelogram method on the same embeddings and reports what comes out:

تطبّق الشريحة 104 (Bolukbasi et al., NeurIPS 2016) طريقة متوازي الأضلاع على الـ embeddings نفسها وتعرض ما يخرج منها:

Analogy askedالتناظر المطلوبx returnedقيمة x المُعادةVerdictالحكم
Paris : France :: Tokyo : xJapana correct geographic factحقيقة جغرافية صحيحة
father : doctor :: mother : xnursea stereotype, not a factصورة نمطية، لا حقيقة
man : computer programmer :: woman : xhomemakera stereotype, not a factصورة نمطية، لا حقيقة

الصف الأول Paris : France :: Tokyo : x يُرجع Japan، وهي حقيقة جغرافية صحيحة. والثاني father : doctor :: mother : x يُرجع nurse، وهو صورة نمطية لا حقيقة. والثالث man : computer programmer :: woman : x يُرجع homemaker، وهو أيضاً صورة نمطية لا حقيقة.

Read the first row next to the other two. The same mechanism produced all three. The model has no way to distinguish "this regularity in the corpus is a fact about the world" from "this regularity in the corpus is a prejudice held by the people who wrote it". It learns both with equal enthusiasm.

اقرأ الصف الأول بجانب الصفين الآخرين. الآلية نفسها أنتجت الثلاثة. لا يملك النموذج أي وسيلة للتمييز بين "هذا الانتظام في الـ corpus حقيقة عن العالم" و"هذا الانتظام في الـ corpus تحيّز يحمله من كتبوه". فيتعلّم الاثنين بالحماس نفسه.

The slide's consequence: algorithms that use embeddings as part of, for example, hiring searches for programmers might lead to bias in hiring. The harm is not that a vector is offensive, it is that the vector gets deployed.

ونتيجة الشريحة: الخوارزميات التي تستخدم الـ embeddings جزءاً منها، مثل البحث عن مبرمجين عند التوظيف، قد تؤدي إلى تحيّز في التوظيف. والضرر ليس أن المتجه مسيء، بل أن المتجه يُستخدم فعلياً في التطبيقات.

Slide 105 (Garg, Schiebinger, Jurafsky and Zou, PNAS 2018) turns the problem around and uses the bias as a measuring instrument. Method: compute a gender or ethnic bias score for each adjective, defined as how much closer that adjective sits to "woman" synonyms than to "man" synonyms, or to names of particular ethnicities. Run it on historical embeddings, decade by decade. Findings:

الشريحة 105 (Garg, Schiebinger, Jurafsky and Zou, PNAS 2018) تقلب المشكلة وتستخدم التحيّز أداةَ قياس. الطريقة: احسب درجة تحيّز جنسي أو عرقي لكل صفة، وتُعرَّف بمقدار قرب الصفة من مرادفات "woman" مقارنةً بمرادفات "man"، أو من أسماء أعراق معيّنة. ثم طبّقها على embeddings تاريخية، عقداً بعد عقد. النتائج:

And the validation that makes it science rather than anecdote: these results match the results of old surveys done in the 1930s. An independent measurement of the same attitudes agrees with what the embeddings say.

والتحقق الذي يجعلها علماً لا حكاية: هذه النتائج تطابق نتائج استطلاعات قديمة أُجريت في ثلاثينيات القرن العشرين. قياس مستقل للمواقف نفسها يتفق مع ما تقوله الـ embeddings.

Slide 106: visualizing embeddings

الشريحة 106: تصوير الـ embeddings

Short slide, one method: use a clustering algorithm to show a hierarchical representation of which words are similar to others in the embedding space. The figure is a dendrogram where body parts (WRIST, ANKLE, SHOULDER, ARM, LEG, HAND, FOOT) branch together, then animals (DOG, CAT, PUPPY, KITTEN, COW), then cities (CHICAGO, ATLANTA, MONTREAL, NASHVILLE), then countries (CHINA, RUSSIA, AFRICA, ASIA, EUROPE).

شريحة قصيرة وطريقة واحدة: استخدم خوارزمية تجميع (clustering algorithm) لعرض تمثيل هرمي يبيّن أي الكلمات تشبه غيرها في فضاء الـ embedding. الشكل مخطط شجري (dendrogram) تتفرع فيه أعضاء الجسم معاً (WRIST, ANKLE, SHOULDER, ARM, LEG, HAND, FOOT)، ثم الحيوانات (DOG, CAT, PUPPY, KITTEN, COW)، ثم المدن (CHICAGO, ATLANTA, MONTREAL, NASHVILLE)، ثم الدول والقارات (CHINA, RUSSIA, AFRICA, ASIA, EUROPE).

The point is that nobody labelled those categories. They fall out of the geometry.

الفكرة أن أحداً لم يضع هذه الفئات. إنها تخرج من الهندسة وحدها.

Slide 107: how to evaluate embeddings

الشريحة 107: كيف نقيّم الـ embeddings

Two families, and the distinction is a classic exam question.

عائلتان، والتمييز بينهما سؤال امتحان كلاسيكي.

Intrinsic

التقييم الداخلي (Intrinsic)

Evaluation on a specific or intermediate subtask. You test the vectors directly, with no application attached.

داخلي (intrinsic): تقييم على مهمة فرعية محددة أو وسيطة. تختبر المتجهات مباشرة، دون أي تطبيق مرتبط بها.

  • Correlation between the algorithm's similarity scores and human word similarity ratings. WordSim353 is 353 noun pairs rated 0 to 10, for example sim(plane, car) = 5.77.

    الارتباط بين درجات التشابه التي تعطيها الخوارزمية وتقييمات البشر لتشابه الكلمات. WordSim353 هو 353 زوجاً من الأسماء مُقيَّمة من 0 إلى 10، مثلاً sim(plane, car) = 5.77.

  • Taking TOEFL multiple-choice vocabulary tests. The slide's item: "Levied is closest in meaning to: imposed, believed, requested, correlated."

    حلّ اختبارات المفردات متعددة الخيارات في TOEFL. وسؤال الشريحة: "Levied is closest in meaning to: imposed, believed, requested, correlated."

Extrinsic

التقييم الخارجي (Extrinsic)

Evaluation on a real task.

خارجي (extrinsic): تقييم على مهمة حقيقية.

  • Take some task (machine translation, named entity recognition, coreference resolution) or several tasks.

    خذ مهمة ما (الترجمة الآلية، أو التعرّف على الكيانات المسمّاة NER، أو حل الإحالة المرجعية coreference) أو عدة مهام.

  • Train the same system with different pretrained word embeddings.

    درّب النظام نفسه مع embeddings مختلفة مُدرَّبة مسبقاً.

  • If the task quality is better, that embedding wins.

    إذا كانت جودة المهمة أفضل، فذلك الـ embedding هو الفائز.

Memory hook خطّاف للذاكرة

Intrinsic asks the vectors. Extrinsic asks the application.

التقييم الداخلي (intrinsic) يسأل المتجهات. والتقييم الخارجي (extrinsic) يسأل التطبيق.

WordSim353 and TOEFL are intrinsic because they score the vectors in isolation. MT and NER are extrinsic because the vectors are only judged by whether something downstream improved.

WordSim353 وTOEFL داخليان لأنهما يقيّمان المتجهات بمعزل عن أي شيء آخر. وMT وNER خارجيان لأن المتجهات لا يُحكم عليها إلا بتحسّن شيء لاحق أو عدمه.

Slides 108 and 109: do we even need pretrained embeddings?

الشريحتان 108 و109: هل نحتاج أصلاً إلى embeddings مُدرَّبة مسبقاً؟

Slide 108 poses the objection as a thought bubble next to a neural network reading "I saw a cat .": if we already have a neural network for our task, why do we have to learn parameters for word embeddings using some other classifier? The network has an embedding layer of its own, and it could just learn it.

تطرح الشريحة 108 الاعتراض كفقاعة تفكير بجانب شبكة عصبية تقرأ "I saw a cat .": إذا كان لدينا أصلاً شبكة عصبية لمهمتنا، فلماذا علينا تعلّم معاملات الـ word embeddings باستخدام مصنّف آخر؟ للشبكة طبقة embedding خاصة بها، ويمكنها أن تتعلمها ببساطة.

Slide 109 is the answer, and it is a two-column decision rule.

الشريحة 109 هي الجواب، وهي قاعدة قرار من عمودين.

SituationالحالةWhat to doما العملWhyالسبب
Not enough data, or the task is too simpleالبيانات غير كافية، أو المهمة بسيطة جداًuse embeddings pretrained on the other taskاستخدم embeddings مُدرَّبة مسبقاً على المهمة الأخرىyour data cannot support learning good embeddings from scratch, so borrow themبياناتك لا تكفي لتعلّم embeddings جيدة من الصفر، فاستعِرها
Enough data and a hard task (LM, MT, …)بيانات كافية ومهمة صعبة (LM, MT, …)train them with the modelدرّبها مع النموذجembeddings tuned for your task beat generic ones, and you have the data to fit themالـ embeddings المضبوطة لمهمتك تتفوق على العامة، ولديك البيانات لتدريبها

الصف الأول: إذا لم تكن البيانات كافية، أو كانت المهمة بسيطة جداً، فاستخدم embeddings مُدرَّبة مسبقاً على المهمة الأخرى، لأن بياناتك لا تكفي لتعلّم embeddings جيدة من الصفر، فاستعرها. الصف الثاني: إذا كانت البيانات كافية والمهمة صعبة (LM، MT، …)، فـ درّبها مع النموذج، لأن الـ embeddings المضبوطة لمهمتك تتفوق على العامة، ولديك البيانات لملاءمتها.

The rule is about data volume and task difficulty, not about which embeddings are better in the abstract. Pretrained vectors are a substitute for data you do not have.

القاعدة تتعلق بـ حجم البيانات وصعوبة المهمة، لا بأي الـ embeddings أفضل بشكل مجرد. فالمتجهات المُدرَّبة مسبقاً بديل عن بيانات لا تملكها.

Slide 110: references

الشريحة 110: المراجع

The closing slide credits the sources. The main ones are Jurafsky and Martin, Speech and Language Processing (which is the SLP3 chapter 5 referenced throughout these pages), Lena Voita at the University of Amsterdam, and Diyi Yang's CS 4650/7650 at Georgia Tech. Also listed: Nizar Habash on Arabic NLP, Yoav Goldberg's Neural Network Methods for NLP, Eisenstein, the CMU 11-411 course, and Christopher Manning's CS224N at Stanford.

الشريحة الختامية تذكر المصادر. أهمها Jurafsky and Martin، Speech and Language Processing (وهو فصل SLP3 رقم 5 المشار إليه في هذه الصفحات كلها)، وLena Voita في جامعة أمستردام، ومقرر CS 4650/7650 لـ Diyi Yang في Georgia Tech. ومذكور أيضاً: Nizar Habash عن معالجة اللغة العربية، وكتاب Yoav Goldberg Neural Network Methods for NLP، وEisenstein، ومقرر CMU 11-411، ومقرر CS224N لـ Christopher Manning في Stanford.

Thirty-second recap

خلاصة في ثلاثين ثانية

skip-gram: target → context skip-gram: من الهدف إلى السياق CBOW: context → centre CBOW: من السياق إلى الكلمة المركزية GloVe: global counts, weighted least squares, learned biases GloVe: عدّات كلية، مربعات صغرى موزونة، انحيازات مُتعلَّمة fastText: character n-grams, so unseen words get vectors fastText: n-grams الحروف، فتحصل الكلمات غير المرئية على متجهات small window = same kind نافذة صغيرة = النوع نفسه big window = same topic نافذة كبيرة = الموضوع نفسه b̂* nearest to a* − a + b b̂* هو الأقرب إلى a* − a + b analogies: frequent words and some relations only التناظرات: للكلمات الشائعة وبعض العلاقات فقط the three input words are excluded from the answers كلمات الإدخال الثلاث مستبعدة من الأجوبة intrinsic = WordSim353, TOEFL الداخلي = WordSim353, TOEFL extrinsic = MT, NER, coref الخارجي = MT, NER, coref little data → pretrained · lots of data → train together بيانات قليلة: مُدرَّبة مسبقاً · بيانات كثيرة: تدريب مشترك

Check yourself

اختبر نفسك

What is the single defining difference between skip-gram and CBOW?

ما الفرق الحاسم الوحيد بين skip-gram وCBOW؟

The prediction direction is the whole difference, and slide 90's heading states CBOW's direction explicitly: predict the centre word from the bag of context words. A is the most tempting distractor because negative sampling really is associated with skip-gram in this course (SGNS), but it is a training trick that can be applied to either architecture, not the architectural difference. C and D are invented; both are word2vec and both produce dense vectors.

الجواب B. اتجاه التنبؤ هو كل الفرق، وعنوان الشريحة 90 يذكر اتجاه CBOW صراحةً: تنبّأ بالكلمة المركزية من كيس كلمات السياق. والخيار A أكثر المشتتات إغراءً لأن negative sampling مرتبط فعلاً بـ skip-gram في هذا المقرر (SGNS)، لكنه حيلة تدريب يمكن تطبيقها على أي من المعماريتين، وليس الفرق المعماري. وC وD مختلَقان، فكلاهما word2vec وكلاهما ينتج متجهات كثيفة.

You train embeddings twice on the same corpus, once with C = ±2 and once with C = ±5. In which run is Dumbledore likely to be a nearest neighbour of Hogwarts, and why?

تدرّب embeddings مرتين على الـ corpus نفسه، مرة بـ C = ±2 ومرة بـ C = ±5. في أي تشغيل يُرجَّح أن تكون Dumbledore من أقرب جيران Hogwarts، ولماذا؟

Slide 95 gives this exact split: with C = ±5 the neighbours of Hogwarts are the Harry Potter world (Dumbledore, half-blood, Malfoy); with C = ±2 they are other fictional schools (Sunnydale, Evernight, Blandings). A is the trap built on the belief that one window is simply better. Neither is more accurate; they encode different relationships, and the small window gives the taxonomy neighbours instead.

الجواب D. تعطي الشريحة 95 هذا التقسيم بالضبط: مع C = ±5 جيران Hogwarts هم عالم هاري بوتر (Dumbledore, half-blood, Malfoy)، ومع C = ±2 هم مدارس خيالية أخرى (Sunnydale, Evernight, Blandings). والخيار A فخ مبني على الاعتقاد بأن إحدى النافذتين أفضل ببساطة. لا أحد منهما أدق، فكل منهما يرمّز علاقات مختلفة، والنافذة الصغيرة تعطي جيران التصنيف بدلاً من ذلك.

Using the parallelogram method on a : a* :: b : b*, with a = France, a* = Paris, b = Italy, which vector do you compute before searching for the nearest word?

باستخدام طريقة متوازي الأضلاع على a : a* :: b : b*، حيث a = France وa* = Paris وb = Italy، أي متجه تحسبه قبل البحث عن أقرب كلمة؟

The formula is a* − a + b, so Paris − France + Italy, which is exactly the line printed on slide 98 and lands near Rome. A is the most tempting error: swapping a and a* reverses the relation, giving "capital to country" instead of "country to capital", and would land somewhere near a country name rather than a city. Check your ordering by asking which two words differ by the relation you want, then subtract the one you are moving away from.

الجواب C. الصيغة a* − a + b، أي Paris − France + Italy، وهو بالضبط السطر المطبوع في الشريحة 98، ويصل قريباً من Rome. والخيار A أكثر الأخطاء إغراءً: تبديل a وa* يعكس العلاقة، فيعطي "العاصمة إلى الدولة" بدلاً من "الدولة إلى العاصمة"، فيصل قرب اسم دولة لا مدينة. تحقّق من الترتيب بأن تسأل: أي كلمتين تختلفان بالعلاقة التي تريدها؟ ثم اطرح الكلمة التي تبتعد عنها.

Why do analogy demonstrations exclude a, a* and b from the list of candidate answers?

لماذا تستبعد عروض التناظر a وa* وb من قائمة الأجوبة المرشحة؟

SLP3 chapter 5 states it directly, using cherry : red :: potato : x, which returns potato or potatoes instead of brown unless the inputs are excluded. The worked example on this page shows the same thing: king at distance 1.4142 beats queen at 2.2361. D is tempting because it sounds like a sensible engineering reason, but removing three items from a 50,000-word search changes nothing about speed. The exclusion exists because the answers would otherwise be wrong.

الجواب A. يقولها SLP3 في الفصل 5 مباشرة، باستخدام cherry : red :: potato : x، الذي يُرجع potato أو potatoes بدلاً من brown ما لم تُستبعد المدخلات. والمثال المحلول في هذه الصفحة يُظهر الشيء نفسه: king على مسافة 1.4142 يتغلب على queen على مسافة 2.2361. والخيار D مغرٍ لأنه يبدو سبباً هندسياً معقولاً، لكن حذف ثلاثة عناصر من بحث على 50,000 كلمة لا يغيّر شيئاً في السرعة. الاستبعاد موجود لأن الأجوبة ستكون خاطئة لولاه.

What is fastText's actual advantage over word2vec, according to slide 92?

ما الميزة الفعلية لـ fastText على word2vec بحسب الشريحة 92؟

The slide says each word is a bag of character n-grams, each n-gram gets a vector, and the word is the sum of those vectors. It also says plainly that this adds a lot of computation, so A is backwards even though the name invites it. C describes GloVe (slide 91) and D describes contextual embeddings such as BERT (slide 63), not fastText.

الجواب B. تقول الشريحة إن كل كلمة كيس من character n-grams، ولكل n-gram متجه، والكلمة هي مجموع هذه المتجهات. وتقول بوضوح أيضاً إن هذا يضيف حساباً كثيراً، فالخيار A معكوس رغم أن الاسم يغري به. وC يصف GloVe (الشريحة 91)، وD يصف الـ contextual embeddings مثل BERT (الشريحة 63)، لا fastText.

Testing word vectors by checking how well their similarity scores correlate with the human ratings in WordSim353 is an example of

اختبار متجهات الكلمات بفحص مدى ارتباط درجات تشابهها بتقييمات البشر في WordSim353 هو مثال على

Slide 107 lists WordSim353 and the TOEFL vocabulary test under intrinsic evaluation: a specific or intermediate subtask. Extrinsic means plugging the embeddings into a real system such as MT, NER or coreference and measuring whether that system improved. A is the trap, built on the word "external"; the distinction is about whether a downstream task is involved, not about whether humans are.

الجواب D. تضع الشريحة 107 WordSim353 واختبار مفردات TOEFL تحت التقييم الداخلي (intrinsic): مهمة فرعية محددة أو وسيطة. أما الخارجي (extrinsic) فيعني إدخال الـ embeddings في نظام حقيقي مثل MT أو NER أو حل الإحالة المرجعية، وقياس ما إذا تحسّن ذلك النظام. والخيار A هو الفخ، مبني على كلمة "external"، فالتمييز يتعلق بوجود مهمة لاحقة، لا بوجود البشر.

Slide 104 reports that the embeddings answer "father : doctor :: mother : x" with nurse. What is the lesson the slide draws?

تذكر الشريحة 104 أن الـ embeddings تجيب عن "father : doctor :: mother : x" بـ nurse. ما الدرس الذي تستخلصه الشريحة؟

The slide pairs this with the correct "Paris : France :: Tokyo : Japan" result to make the point that the same mechanism returns facts and stereotypes indiscriminately, then names the consequence: embeddings used in hiring searches for programmers might lead to bias in hiring. D is tempting because the geographic example is the one that works, but slide 102 lists several relation types that work, including parts of speech, so geography is not special in that way.

الجواب C. تضع الشريحة هذا بجانب النتيجة الصحيحة "Paris : France :: Tokyo : Japan" لتوضح أن الآلية نفسها تُرجع الحقائق والصور النمطية دون تمييز، ثم تسمّي العاقبة: الـ embeddings المستخدمة في البحث عن مبرمجين عند التوظيف قد تؤدي إلى تحيّز في التوظيف. والخيار D مغرٍ لأن المثال الجغرافي هو الذي ينجح، لكن الشريحة 102 تذكر عدة أنواع من العلاقات التي تنجح، منها أقسام الكلام، فالجغرافيا ليست مميزة بهذا المعنى.