ICS 582Lecture 01المحاضرة 01Part 03الجزء 03
How NLP is done: approaches and linguistic knowledgeكيف تُنجز NLP: المناهج والمعرفة اللغوية
The four families of NLP approaches, the pipeline from paragraphs to morphemes, the levels of linguistic knowledge from phonetics to discourse, and the contrast between a machine and a child who is predisposed to acquire language.العائلات الأربع من مناهج NLP، والمسار من الفقرات وصولا إلى المورفيمات، ومستويات المعرفة اللغوية من علم الأصوات (phonetics) إلى الخطاب (discourse)، والمقارنة بين الآلة والطفل المهيأ فطريا لاكتساب اللغة.
- Conceptsالمفاهيم
- 4
- Slidesالشرائح
- 14-19
- Readingمدة القراءة
- 24 min24 دقيقة
Why this part mattersلماذا يهمّ هذا الجزء
Everything after this lecture, from regular expressions and n-grams to classifiers, sequence labelling and transformers, is one of four approaches applied at one of a handful of linguistic levels. This part gives you both axes.
The exam questions on this material are definitional and comparative, so precise vocabulary is the whole game: which step turns sentences into words, how stemming differs from lemmatization, which levels exist only for speech. The research project will demand the same vocabulary in a different form, because every task you propose has to say which level it lives at and whether the knowledge at that level is coded by hand or learned from data. We build the four approaches first, run one paragraph through the text pipeline, climb the levels of linguistic knowledge, and finish with the observation that motivates the next part: a machine starts with none of this.
كل ما يأتي بعد هذه المحاضرة، من التعابير النمطية (regular expressions) وn-grams إلى المصنِّفات ووسم التسلسلات (sequence labelling) والمحوّلات (transformers)، هو أحد أربعة مناهج مطبّق عند واحد من عدد قليل من المستويات اللغوية. هذا الجزء يعطيك المحورين معًا.
أسئلة الامتحان في هذه المادة تعريفية ومقارِنة، لذا فالمصطلحات الدقيقة هي كل شيء: أي خطوة تحوّل الجمل إلى كلمات، وكيف يختلف stemming عن lemmatization، وأي المستويات موجودة للكلام المنطوق فقط. والمشروع البحثي سيطلب منك المصطلحات نفسها بصيغة أخرى، لأن كل مهمة تقترحها يجب أن تقول عند أي مستوى تقع، وهل المعرفة عند ذلك المستوى مكتوبة يدويًا أم متعلَّمة من البيانات. سنبني المناهج الأربعة أولًا، ثم نمرّر فقرة واحدة عبر خط معالجة النص، ثم نصعد مستويات المعرفة اللغوية، وننتهي بالملاحظة التي تمهّد للجزء التالي: الآلة تبدأ من دون أي شيء من هذا.
By the end you canفي نهاية هذا الجزء ستستطيع
- Name the four approaches and say for each what a human writes and what the data supplies, with one strength and one weakness.أن تسمّي المناهج الأربعة، وتقول لكل منها ما الذي يكتبه الإنسان وما الذي توفّره البيانات، مع نقطة قوة واحدة ونقطة ضعف واحدة.
- Run a paragraph through sentence boundary disambiguation, tokenization, stemming and lemmatization, and predict where each step can go wrong.أن تمرّر فقرة عبر تحديد حدود الجمل (sentence boundary disambiguation) والتقطيع إلى وحدات (tokenization) والتجذيع (stemming) والتأصيل المعجمي (lemmatization)، وتتوقع أين يمكن أن تخطئ كل خطوة.
- Define stemming versus lemmatization and give an example where they differ.أن تعرّف التجذيع (stemming) مقابل التأصيل المعجمي (lemmatization)، وتعطي مثالًا يختلفان فيه.
- Order the levels of linguistic knowledge from phonetics to discourse, place orthography and the lexical level, and say which levels apply to speech only.أن ترتّب مستويات المعرفة اللغوية من علم الأصوات النطقي (phonetics) إلى الخطاب (discourse)، وتحدد موضع الإملاء (orthography) والمستوى المعجمي (lexical)، وتقول أي المستويات تخص الكلام المنطوق فقط.
- Explain why a machine, unlike a child, must have every level hand-coded or learned, and connect that to why NLP is difficult.أن تشرح لماذا يجب أن يُبرمج كل مستوى يدويًا أو يُتعلّم في حالة الآلة، بخلاف الطفل، وتربط ذلك بسبب صعوبة معالجة اللغات الطبيعية (NLP).
In 1966 Joseph Weizenbaum's ELIZA could take "I need some help" and answer "WHAT WOULD IT MEAN TO YOU IF YOU GOT SOME HELP". Jurafsky and Martin describe it as "a surprisingly simple program that uses pattern matching on words to recognize phrases like 'I need X' and change the words into suitable outputs", working "by having a series or cascade of regex substitutions". Every one of those rules was typed by a person. A modern translation system, by contrast, was shown millions of sentence pairs and nobody wrote a rule for any of them.
في عام 1966 كان برنامج ELIZA الذي كتبه Joseph Weizenbaum يستطيع أن يأخذ عبارة «I need some help» ويجيب «WHAT WOULD IT MEAN TO YOU IF YOU GOT SOME HELP». ويصفه Jurafsky وMartin بأنه «برنامج بسيط على نحو مفاجئ يستخدم مطابقة الأنماط على الكلمات ليتعرّف على عبارات مثل 'I need X' ويحوّل الكلمات إلى مخرجات مناسبة»، ويعمل «عبر سلسلة أو تتابع من عمليات الاستبدال بالتعابير النمطية (regex)». كل واحدة من تلك القواعد كتبها إنسان. أما نظام الترجمة الحديث، في المقابل، فقد عُرضت عليه ملايين أزواج الجمل ولم يكتب أحد قاعدة لأي منها.
Those two systems mark the ends of one axis, and the four approaches on slide 15 are points along it. What separates them is not the task and not the programming language. It is the answer to a single question: what does a human write, and what does the data supply?
هذان النظامان يحددان طرفي محور واحد، والمناهج الأربعة في الشريحة 15 نقاط على امتداده. ما يفرّق بينها ليس المهمة وليس لغة البرمجة، بل الإجابة عن سؤال واحد: ما الذي يكتبه الإنسان، وما الذي توفّره البيانات؟
Rule-based: the human writes everythingالمنهج القائم على القواعد: الإنسان يكتب كل شيء
In rule-based NLP the knowledge of language lives in artefacts a person authored: a grammar, a lexicon, a set of regular expressions, a finite-state machine. The Georgetown-IBM demonstration of 7 January 1954, the first public machine translation, was in Hutchins's account "a small-scale experiment of just 250 words and six 'grammar' rules". ELIZA came twelve years later, and Jurafsky and Martin date the whole symbolic era "roughly from 1965 til the early 1990s".
في rule-based NLP (المعالجة القائمة على القواعد) تعيش المعرفة باللغة في أدوات ألّفها إنسان: قواعد نحوية (grammar)، ومعجم (lexicon)، ومجموعة من التعابير النمطية، وآلة حالات منتهية (finite-state machine). وعرض Georgetown-IBM في 7 January 1954، وهو أول ترجمة آلية علنية، كان بحسب رواية Hutchins «تجربة صغيرة الحجم من 250 كلمة فقط وست قواعد ‹نحوية›». وجاء ELIZA بعده باثنتي عشرة سنة، ويؤرّخ Jurafsky وMartin الحقبة الرمزية كلها بأنها «تقريبًا من 1965 حتى أوائل التسعينيات (1990s)».
The strengths follow from authorship. A rule is precise, you can read it, you can explain any output by pointing at the rule that produced it, and nothing has to be trained. Rule-based tokenizers are, in Jurafsky and Martin's words, "deterministic algorithms based on regular expressions compiled into efficient finite state automata", which is why they are fast. The weakness follows from the same fact: language keeps producing phenomena nobody wrote a rule for, and every one of them costs another rule, which may conflict with the rules already there.
نقاط القوة نابعة من كون الإنسان هو المؤلف. القاعدة دقيقة، ويمكنك قراءتها، ويمكنك تفسير أي مخرج بالإشارة إلى القاعدة التي أنتجته، ولا شيء يحتاج إلى تدريب. والمقطِّعات (tokenizers) القائمة على القواعد هي، بتعبير Jurafsky وMartin، «خوارزميات حتمية مبنية على تعابير نمطية مترجمة إلى آلات حالات منتهية فعّالة»، ولهذا هي سريعة. ونقطة الضعف نابعة من الحقيقة نفسها: اللغة لا تتوقف عن إنتاج ظواهر لم يكتب لها أحد قاعدة، وكل ظاهرة منها تكلّف قاعدة جديدة، قد تتعارض مع القواعد الموجودة أصلًا.
Classical machine learning: the human writes the features, the data sets the weightsتعلم الآلة الكلاسيكي: الإنسان يكتب السمات، والبيانات تحدد الأوزان
Machine learning based NLP moves the boundary. A person still decides what the model looks at, but the data decides how much each observation matters. For a part-of-speech tagger the designer might say "look at the word, its suffix, its capitalisation, and the previous tag". Jurafsky and Martin describe the arrangement exactly: "Although the idea of what features to use is done by the system designer by hand, the specific features are automatically populated by using feature templates", so a word-shape feature maps DC10-30 to XXdd-dd without anyone listing every flight number. A Classifier such as naive Bayes or logistic regression, or a sequence model such as a hidden Markov model or a conditional random field (Lafferty, McCallum and Pereira, 2001), then learns the weights from labelled examples.
Machine learning based NLP (المعالجة القائمة على تعلم الآلة) تحرّك الحد الفاصل. لا يزال الإنسان يقرر ما الذي ينظر إليه النموذج، لكن البيانات تقرر مدى أهمية كل ملاحظة. ففي واسم أقسام الكلام (part-of-speech tagger) قد يقول المصمم «انظر إلى الكلمة، ولاحقتها، وحالة أحرفها الكبيرة، والوسم السابق». ويصف Jurafsky وMartin هذا الترتيب بدقة: «رغم أن فكرة السمات التي تُستخدم يضعها مصمم النظام يدويًا، فإن السمات المحددة تُملأ تلقائيًا باستخدام قوالب السمات (feature templates)»، فسمة شكل الكلمة (word-shape) تحوّل DC10-30 إلى XXdd-dd دون أن يسرد أحد كل أرقام الرحلات. ثم يتعلم classifier (مصنِّف) مثل naive Bayes أو logistic regression، أو نموذج تسلسلي مثل hidden Markov model أو conditional random field (Lafferty وMcCallum وPereira، 2001)، الأوزانَ من أمثلة موسومة.
The era began, by Jurafsky and Martin's account, with Jelinek's IBM speech group between 1975 and 1985, and "by the late 1980s statistical methods had begun to spread from speech researchers to NLP researchers working on text"; they date this "long revival of empiricism" as lasting until 2017. The strength is robustness: a probabilistic model degrades gracefully on input no rule anticipated. The price is twofold. Someone must label the training data, and someone must engineer the features, which is where the linguistic knowledge of the designer now goes.
بدأت هذه الحقبة، بحسب رواية Jurafsky وMartin، مع مجموعة الكلام في IBM بقيادة Jelinek بين 1975 و1985، و«بحلول أواخر الثمانينيات (1980s) بدأت الطرق الإحصائية تنتشر من باحثي الكلام إلى باحثي NLP العاملين على النص»؛ ويؤرّخان هذا «الإحياء الطويل للتجريبية» بأنه استمر حتى 2017. نقطة القوة هي المتانة: النموذج الاحتمالي يتراجع أداؤه بلطف على مدخلات لم تتوقعها أي قاعدة. والثمن مزدوج: يجب أن يَسِم أحدٌ بيانات التدريب، ويجب أن يهندس أحدٌ السمات، وهناك تذهب الآن المعرفة اللغوية لدى المصمم.
End-to-end deep learning: the data supplies the representations tooالتعلم العميق من الطرف إلى الطرف: البيانات توفّر التمثيلات أيضًا
End-to-end NLP using deep learning removes feature engineering. The model reads raw text (or audio) and learns its own intermediate representations on the way to the output. Sutskever, Vinyals and Le (2014) translated by using "a multilayered Long Short-Term Memory (LSTM) to map the input sequence to a vector of a fixed dimensionality, and then another deep LSTM to decode the target sequence". Vaswani and colleagues (2017) then proposed "a new simple network architecture, the Transformer, based solely on attention mechanisms, dispensing with recurrence and convolutions entirely". Jurafsky and Martin note that the transformer, "invented for machine translation, quickly became a general-purpose neural architecture", and mark prompting in 2019 as the next inflection point. Speech went the same way: modern recognisers are encoder-decoder models with no hand-built pronunciation pipeline in front.
End-to-end NLP using deep learning (المعالجة من الطرف إلى الطرف بالتعلم العميق) تلغي هندسة السمات. يقرأ النموذج النص الخام (أو الصوت) ويتعلم تمثيلاته الوسيطة بنفسه في طريقه إلى المخرج. ترجم Sutskever وVinyals وLe (2014) باستخدام «شبكة Long Short-Term Memory (LSTM) متعددة الطبقات لتحويل تسلسل المدخل إلى متجه ذي أبعاد ثابتة، ثم شبكة LSTM عميقة أخرى لفك ترميز التسلسل الهدف». ثم اقترح Vaswani وزملاؤه (2017) «معمارية شبكة بسيطة جديدة، هي Transformer، تقوم على آليات الانتباه (attention) وحدها، وتستغني عن التكرار (recurrence) والالتفاف (convolutions) تمامًا». ويلاحظ Jurafsky وMartin أن المحوّل «الذي اختُرع للترجمة الآلية سرعان ما صار معمارية عصبية للأغراض العامة»، ويعدّان التلقين (prompting) عام 2019 نقطة التحوّل التالية. وسار الكلام في الطريق نفسه: أنظمة التعرف على الكلام الحديثة نماذج encoder-decoder لا يسبقها خط معالجة للنطق مبني يدويًا.
What the designer still writes is the architecture and the training objective. Everything else, including whatever the model knows about morphology or syntax, arrives from data. That gives the best accuracy and one model for many tasks, at the cost of very large data sets and compute, and of a system nobody can read. Jurafsky and Martin treat interpretability as an open research field for exactly this reason.
ما يكتبه المصمم الآن هو المعمارية وهدف التدريب فقط. كل ما عدا ذلك، بما فيه أي شيء يعرفه النموذج عن الصرف (morphology) أو النحو (syntax)، يأتي من البيانات. وهذا يعطي أعلى دقة ونموذجًا واحدًا لمهام كثيرة، على حساب مجموعات بيانات وقدرة حوسبة ضخمة جدًا، وعلى حساب نظام لا يستطيع أحد قراءته. ولهذا السبب تحديدًا يعامل Jurafsky وMartin قابلية التفسير (interpretability) بوصفها مجالًا بحثيًا مفتوحًا.
Hybrid: rules around a learned coreالمنهج الهجين: قواعد حول نواة متعلَّمة
The Hybrid approach is what most production systems actually are. The pattern is a learned model in the middle with rules on either side: rules for normalisation before the model, and rules for constraints, safety checks or formatting after it. The clearest example is hiding inside the largest models. The GPT-2 tokenizer first runs a hand-written regular expression, which Jurafsky and Martin show as "the GPT-2 pre-tokenizer regular expression, used to split (roughly) on whitespace before running the BPE algorithm", and only then applies byte-pair encoding merges learned from data (Sennrich, Haddow and Birch, 2016). Rule first, learning second, in the front door of a language model.
hybrid approach (المنهج الهجين) هو ما تكونه معظم أنظمة الإنتاج فعليًا. النمط هو نموذج متعلَّم في الوسط وقواعد على جانبيه: قواعد للتطبيع (normalisation) قبل النموذج، وقواعد للقيود أو فحوص الأمان أو التنسيق بعده. وأوضح مثال مختبئ داخل أكبر النماذج نفسها: مقطِّع GPT-2 يشغّل أولًا تعبيرًا نمطيًا مكتوبًا يدويًا، يعرضه Jurafsky وMartin بوصفه «التعبير النمطي للتقطيع المسبق في GPT-2، المستخدم للتقسيم (تقريبًا) عند المسافات قبل تشغيل خوارزمية BPE»، وبعد ذلك فقط يطبّق عمليات دمج byte-pair encoding المتعلَّمة من البيانات (Sennrich وHaddow وBirch، 2016). القاعدة أولًا، والتعلم ثانيًا، عند الباب الأمامي لنموذج لغوي.
| Approachالمنهج | What a human writesما يكتبه الإنسان | What the data suppliesما توفّره البيانات | Strengthsنقاط القوة | Weaknessesنقاط الضعف | Era and exampleالحقبة والمثال |
|---|---|---|---|---|---|
| Rule-basedالقائم على القواعد (Rule-based) | Grammars, lexicons, regular expressions, finite-state machinesقواعد نحوية (grammars)، ومعاجم (lexicons)، وتعابير نمطية (regular expressions)، وآلات حالات منتهية (finite-state machines) | Nothingلا شيء | Precise, inspectable, needs no training data, fastدقيق، وقابل للفحص، ولا يحتاج إلى بيانات تدريب، وسريع | Brittle; every new phenomenon is another rule to writeهشّ؛ كل ظاهرة جديدة تعني قاعدة أخرى يجب كتابتها | Georgetown-IBM 1954, ELIZA 1966; symbolic era to the early 1990sGeorgetown-IBM 1954، وELIZA 1966؛ الحقبة الرمزية حتى أوائل التسعينيات (1990s) |
| Classical machine learningتعلم الآلة الكلاسيكي (Classical machine learning) | Feature templates, the choice of modelقوالب السمات (feature templates)، واختيار النموذج | The weights, from labelled examplesالأوزان، من أمثلة موسومة | Robust to noise, gives probabilities, learns from dataمتين أمام الضوضاء، ويعطي احتمالات، ويتعلم من البيانات | Needs labelled data and hand-designed featuresيحتاج إلى بيانات موسومة وسمات مصممة يدويًا | Naive Bayes, HMM, CRF (2001); empiricist era starting between 1975 and 1988, lasting to 2017Naive Bayes وHMM وCRF (2001)؛ حقبة تجريبية بدأت بين 1975 و1988 واستمرت حتى 2017 |
| End-to-end deep learningالتعلم العميق من الطرف إلى الطرف (End-to-end deep learning) | The architecture and the lossالمعمارية ودالة الخسارة (loss) | Representations and weightsالتمثيلات والأوزان | Highest accuracy, no feature engineering, one model for many tasksأعلى دقة، ولا هندسة سمات، ونموذج واحد لمهام كثيرة | Needs large data and compute; hard to inspectيحتاج إلى بيانات وحوسبة ضخمة؛ ويصعب فحصه | seq2seq 2014, Transformer 2017, prompting 2019seq2seq 2014، وTransformer 2017، والتلقين (prompting) 2019 |
| Hybridالهجين (Hybrid) | Normalisation rules, constraints and checksقواعد التطبيع (normalisation)، والقيود، والفحوص | The learned coreالنواة المتعلَّمة | Practical, safe, works for low-resource languagesعملي، وآمن، ويصلح للغات قليلة الموارد | Two systems to maintainنظامان يجب صيانتهما | GPT-2 regex pre-tokenizer plus learned BPE merges (2019)التعبير النمطي للتقطيع المسبق في GPT-2 مع عمليات دمج BPE متعلَّمة (2019) |
Quick checkاختبار سريع
Which approach typically needs the most training data and compute to reach its accuracy?أي منهج يحتاج عادةً إلى أكبر قدر من بيانات التدريب والحوسبة ليبلغ دقته؟
Recall
Name the four approaches on slide 15 and give one strength and one weakness of each.سمِّ المناهج الأربعة في الشريحة 15 وأعطِ نقطة قوة واحدة ونقطة ضعف واحدة لكل منها.
Take one paragraph: "Dr. Ahmad's students are running experiments. The pipeline costs 3.14 dollars per run. It works!" To a machine this is a string of characters. Before any approach from the last concept can be applied, that string has to be cut into units the approach can work on, and slide 16 names the cuts: paragraphs to sentences, sentences to words, words to their morphology.
خذ فقرة واحدة: «Dr. Ahmad's students are running experiments. The pipeline costs 3.14 dollars per run. It works!». بالنسبة للآلة هذه مجرد سلسلة من الحروف. وقبل أن يُطبَّق عليها أي منهج من المفهوم السابق، يجب أن تُقطَّع هذه السلسلة إلى وحدات يستطيع المنهج العمل عليها، والشريحة 16 تسمّي هذه القطوع: من الفقرات إلى الجمل، ومن الجمل إلى الكلمات، ومن الكلمات إلى بنيتها الصرفية.
Step through the paragraph below before reading on. Watch which periods survive as sentence boundaries, where the apostrophe goes, and what happens to are under each normaliser.
تنقّل خطوة بخطوة عبر الفقرة أدناه قبل أن تكمل القراءة. راقب أي النقاط تبقى حدودًا للجمل، وأين تذهب الفاصلة العليا (apostrophe)، وماذا يحدث لكلمة are مع كل أداة تطبيع.
Dr. Ahmad's students are running experiments. The pipeline costs 3.14 dollars per run. It works!
- Stepالخطوة
- Raw inputالمدخل الخام
- Changedما تغيّر
- Nothing yet. The text is one string of characters with no structure the machine can use.لا شيء بعد. النص سلسلة واحدة من الحروف بلا أي بنية يستطيع الحاسوب استخدامها.
- Watchلاحظ
- Two periods are not boundaries: the abbreviation in Dr. and the decimal point in 3.14.نقطتان ليستا حدَّي جملة: النقطة في الاختصار Dr. والفاصلة العشرية في 3.14.
- Paragraphsالفقرات
- 1
- Sentencesالجمل
- 3
- Periods kept inside tokensنقاط باقية داخل الوحدات اللفظية
- 2
- Tokensالوحدات اللفظية
- 19
- Clitics split offلواحق متصلة مفصولة
- 1
- Non-word stemsجذوع ليست كلمات
- 3
Outputs precomputed with NLTK: the Punkt sentence tokenizer, the Treebank word tokenizer, the Porter stemmer in ORIGINAL_ALGORITHM mode, and the WordNet lemmatizer given each token's part of speech. Porter's own reference implementation leaves one- and two-letter words untouched, so it returns is unchanged where NLTK's original mode gives i.المخرجات محسوبة مسبقًا بمكتبة NLTK: مُقطِّع الجمل Punkt، ومُقطِّع الكلمات Treebank، وأداة التجذيع Porter في نمط ORIGINAL_ALGORITHM، وأداة الإرجاع إلى الأصل WordNet مع تمرير قسم الكلام لكل وحدة لفظية. التنفيذ المرجعي الأصلي لخوارزمية Porter يترك الكلمات ذات الحرف الواحد والحرفين دون تغيير، فيُعيد is كما هي، بينما يُعطي النمط الأصلي في NLTK الناتج i.
Paragraphs to sentences: the period is ambiguousمن الفقرات إلى الجمل: النقطة ملتبسة
Sentence boundary disambiguation looks easy because sentences end in punctuation. Jurafsky and Martin explain why it is not: "Question marks and exclamation points are relatively unambiguous markers", but "the period character '.', on the other hand, is ambiguous between a sentence boundary marker and a marker of abbreviations like Dr. or Inc.". Our paragraph has two periods that are not boundaries: the one in Dr. and the decimal point in 3.14. The stepper's second example adds the harder case, Inc., where one period closes the abbreviation and ends the sentence at the same time. Jurafsky and Martin use that case to argue that "sentence tokenization and word tokenization can be addressed jointly": the decision about the period is one decision, not two.
يبدو sentence boundary disambiguation (تحديد حدود الجمل) سهلًا لأن الجمل تنتهي بعلامات ترقيم. ويشرح Jurafsky وMartin لماذا ليس كذلك: «علامات الاستفهام والتعجب مؤشرات غير ملتبسة نسبيًا»، لكن «حرف النقطة '.'، في المقابل، ملتبس بين كونه علامة على حد الجملة وكونه علامة على اختصارات مثل Dr. أو Inc.». في فقرتنا نقطتان ليستا حدّين: التي في Dr.، والفاصلة العشرية في 3.14. والمثال الثاني في الأداة التفاعلية يضيف الحالة الأصعب، Inc.، حيث تُغلق نقطة واحدة الاختصار وتُنهي الجملة في الوقت نفسه. ويستخدم Jurafsky وMartin هذه الحالة ليحتجّا بأن «تقطيع الجمل وتقطيع الكلمات يمكن معالجتهما معًا»: القرار بشأن النقطة قرار واحد، لا قراران.
Practical splitters decide with an abbreviation dictionary, which "can be hand-built or machine-learned" (Kiss and Strunk, 2006, is the standard unsupervised method, and the NLTK Punkt tokenizer in the stepper implements it). Notice which approach that is: a rule, backed by a list that a person or a corpus supplies. The last concept's axis is already in play at the first step.
المقسِّمات العملية تقرر باستخدام معجم اختصارات، «يمكن أن يُبنى يدويًا أو يُتعلَّم آليًا» (وKiss وStrunk، 2006، هي الطريقة غير الموجَّهة (unsupervised) المعيارية، ومقطِّع NLTK Punkt في الأداة التفاعلية يطبّقها). لاحظ أي منهج هذا: قاعدة، مدعومة بقائمة يوفّرها إنسان أو مدوّنة نصية. فمحور المفهوم السابق حاضر منذ الخطوة الأولى.
Sentences to words: tokenization is not splitting on spacesمن الجمل إلى الكلمات: التقطيع ليس تقسيمًا عند المسافات
Tokenization turns a sentence into tokens, and the trouble starts with the apostrophe. Jurafsky and Martin point out that "I'm is one word, grammatically it functions as two words". The 's in Ahmad's is a clitic, in their definition "a morpheme that acts syntactically like a word but is reduced in form and attached ... to another word" (a morpheme being the smallest meaningful piece of a word, defined properly below), and the Penn Treebank convention therefore splits it off, giving Ahmad and 's as two tokens. The same convention separates doesn't into does and n't, keeps hyphenated words such as San Francisco-based together, and makes every punctuation mark its own token, which is why the first sentence yields eight tokens, not six words.
Tokenization (التقطيع إلى وحدات) يحوّل الجملة إلى وحدات (tokens)، والمشكلة تبدأ مع الفاصلة العليا. يشير Jurafsky وMartin إلى أن «I'm كلمة واحدة، لكنها نحويًا تعمل ككلمتين». و's في Ahmad's هي clitic (لاحقة متصلة)، وهي في تعريفهما «مورفيم يتصرف نحويًا مثل كلمة لكنه مختزل الشكل وملتصق ... بكلمة أخرى» (والمورفيم هو أصغر جزء ذي معنى في الكلمة، وسنعرّفه تعريفًا دقيقًا أدناه)، ولذلك يفصلها عرف Penn Treebank، فيعطي Ahmad و's بوصفهما وحدتين. والعرف نفسه يفصل doesn't إلى does وn't، ويُبقي الكلمات الموصولة بشرطة مثل San Francisco-based معًا، ويجعل كل علامة ترقيم وحدة مستقلة، ولهذا تعطي الجملة الأولى ثماني وحدات، لا ست كلمات.
The choices are language-specific. Arabic attaches the preposition b (by, with) and the conjunction w (and) to the following word, so a tokenizer for Arabic must decide whether to detach them. Chinese, Japanese and Thai, in Jurafsky and Martin's words, "simply don't have orthographic words at all": Chinese words average "roughly between 1.5 and 1.9 characters long" and a sentence such as 姚明进入总决赛 can be segmented as three words, five words or seven characters. Numbers differ too, 555,500.50 in one convention and 555 500,50 in another. This is Segmentation in its most basic form, and part 4 returns to it as a source of difficulty.
هذه الخيارات خاصة بكل لغة. فالعربية تُلصق حرف الجر الباء (b، بمعنى «بـ» أو «مع») وحرف العطف الواو (w، بمعنى «و») بالكلمة التالية، فيجب على مقطِّع العربية أن يقرر هل يفصلهما أم لا. أما الصينية واليابانية والتايلاندية فهي، بتعبير Jurafsky وMartin، «ببساطة لا تملك كلمات إملائية على الإطلاق»: متوسط طول الكلمة الصينية «تقريبًا بين 1.5 و1.9 حرف»، وجملة مثل 姚明进入总决赛 يمكن تقسيمها إلى ثلاث كلمات أو خمس كلمات أو سبعة حروف. والأرقام تختلف أيضًا: 555,500.50 في عرف و555 500,50 في عرف آخر. هذا هو segmentation (التجزئة) في أبسط صوره، والجزء 4 يعود إليه بوصفه مصدرًا للصعوبة.
Words to morphology: chop, or look upمن الكلمات إلى الصرف: اقطع، أو ابحث في المعجم
A word is built from morphemes, which Jurafsky and Martin define as minimal meaning-bearing units: cats is the morpheme cat plus the morpheme -s. Morphology is the level that knows this, and slide 16 lists two ways to use it. Stemming, in Manning, Raghavan and Schütze's definition, is "a crude heuristic process that chops off the ends of words in the hope of achieving this goal correctly most of the time". Lemmatization means "doing things properly with the use of a vocabulary and morphological analysis of words, normally aiming to remove inflectional endings only" and returning the lemma, the dictionary form.
الكلمة مبنية من مورفيمات (morphemes)، يعرّفها Jurafsky وMartin بأنها أصغر الوحدات الحاملة للمعنى: cats هي المورفيم cat زائد المورفيم -s. وmorphology (الصرف) هو المستوى الذي يعرف هذا، والشريحة 16 تذكر طريقتين لاستخدامه. Stemming (التجذيع)، في تعريف Manning وRaghavan وSchütze، هو «عملية استدلالية خشنة تقطع أواخر الكلمات على أمل تحقيق هذا الهدف بشكل صحيح في أغلب الأحيان». أما lemmatization (التأصيل المعجمي) فيعني «فعل الأمور كما ينبغي باستخدام مفردات (vocabulary) وتحليل صرفي للكلمات، بهدف إزالة اللواحق التصريفية فقط في العادة» وإرجاع الـ lemma، أي الصيغة المعجمية للكلمة.
The difference is visible in the stepper. Porter's 1980 algorithm, "the most common algorithm for stemming English", turns experiments into experi and are into ar: neither is a word, and the stemmer does not care, because it never consults a dictionary. The WordNet lemmatizer turns are into be. No suffix rule can do that; Manning and colleagues give exactly this case, "am, are, is" to be, as the reason lemmatization needs a vocabulary. It also needs the part of speech: running as a verb lemmatizes to run, but as a noun ("the running of the race") it stays running. The Porter stemmer gives run either way, and on that verb the two methods happen to agree.
الفرق ظاهر في الأداة التفاعلية. خوارزمية Porter لعام 1980، وهي «أشهر خوارزمية لتجذيع الإنجليزية»، تحوّل experiments إلى experi وare إلى ar: ولا واحدة منهما كلمة، والمجذِّع لا يبالي، لأنه لا يرجع إلى أي معجم أبدًا. أما مؤصِّل WordNet فيحوّل are إلى be. لا توجد قاعدة لواحق تستطيع ذلك؛ ويعطي Manning وزملاؤه هذه الحالة بعينها، «am, are, is» إلى be، بوصفها سبب احتياج التأصيل المعجمي إلى مفردات. ويحتاج أيضًا إلى part of speech (نوع الكلمة): فـ running بوصفها فعلًا تؤصَّل إلى run، أما بوصفها اسمًا («the running of the race») فتبقى running. ومجذِّع Porter يعطي run في الحالتين، وفي حالة الفعل هذه يتفق الأسلوبان مصادفةً.
Worked exampleمثال محلول
The first sentence through all four stagesالجملة الأولى عبر المراحل الأربع كلها
Sentence boundary disambiguationتحديد حدود الجمل
"Dr. Ahmad's students are running experiments." is kept as one sentence. The period in Dr. is judged an abbreviation marker, the final period a boundary.تُبقى «Dr. Ahmad's students are running experiments.» جملة واحدة. يُحكم على النقطة في Dr. بأنها علامة اختصار، وعلى النقطة الأخيرة بأنها حد الجملة.Tokenization (Penn Treebank convention)التقطيع إلى وحدات (عرف Penn Treebank)
Dr. / Ahmad / 's / students / are / running / experiments / . The clitic is split off; the abbreviation keeps its period.Dr. / Ahmad / 's / students / are / running / experiments / . تُفصل اللاحقة المتصلة (clitic)؛ ويحتفظ الاختصار بنقطته.Porter stemsجذوع Porter
dr. / ahmad / ' / student / ar / run / experi / .dr. / ahmad / ' / student / ar / run / experi / .WordNet lemmas, given the part of speechالصيغ المعجمية من WordNet، مع معرفة نوع الكلمة
students to student; are to be; running (verb) to run; experiments to experiment.students إلى student؛ are إلى be؛ running (فعل) إلى run؛ experiments إلى experiment.Resultالنتيجة
8 tokens, 2 stems that are not words (ar, experi), and 1 lemma that no suffix rule could reach (be).8 وحدات، وجذعان اثنان (2) ليسا كلمتين (ar، experi)، وصيغة معجمية واحدة (1) لا تستطيع أي قاعدة لواحق الوصول إليها (be).
| Stemmingالتجذيع (Stemming) | Lemmatizationالتأصيل المعجمي (Lemmatization) | |
|---|---|---|
| Methodالطريقة | Chops suffixes by ruleيقطع اللواحق بالقاعدة | Looks up the dictionary form using a vocabulary and morphological analysisيبحث عن الصيغة المعجمية باستخدام مفردات (vocabulary) وتحليل صرفي |
| Outputالمخرج | May be a non-wordقد لا يكون كلمة | Always a real word (the lemma)دائمًا كلمة حقيقية (الـ lemma) |
| Speedالسرعة | Fastسريع | Slowerأبطأ |
| Needsما يحتاجه | Nothing beyond the rulesلا شيء غير القواعد | A lexicon, and often the part of speechمعجم (lexicon)، وغالبًا نوع الكلمة (part of speech) |
| Exampleمثال | experiments to experi, are to arexperiments إلى experi، وare إلى ar | experiments to experiment, are to beexperiments إلى experiment، وare إلى be |
| Typical useالاستخدام المعتاد | Search indexing, where recall matters more than readable outputفهرسة البحث، حيث يهم الاستدعاء (recall) أكثر من قابلية قراءة المخرج | Anything that shows text to people or feeds a parserأي شيء يعرض نصًا على الناس أو يغذّي محللًا نحويًا (parser) |
Quick checkاختبار سريع
In the pipeline of slide 16, which step turns sentences into words?في خط المعالجة في الشريحة 16، أي خطوة تحوّل الجمل إلى كلمات؟
Recall
Define stemming and lemmatization with one example each, and name what lemmatization needs that stemming does not.عرّف التجذيع (stemming) والتأصيل المعجمي (lemmatization) مع مثال لكل منهما، واذكر ما يحتاجه التأصيل المعجمي ولا يحتاجه التجذيع.
Recall
Why is the period a problem for sentence boundary disambiguation? Give a counterexample.لماذا تمثّل النقطة مشكلة في تحديد حدود الجمل؟ أعطِ مثالًا مضادًا.
Extend the running example by one sentence: "Dr. Ahmad's students are running experiments. They will publish them tomorrow." Say it aloud, and something has to know that the sound wave you produced for running counts as that word and not runny. Write it down, and something has to know that they means the students and them means the experiments. Between those two ends lie the levels of linguistic knowledge, and slide 17 draws them twice: as concentric rings and as a stack with two roots.
وسّع المثال الجاري بجملة واحدة: «Dr. Ahmad's students are running experiments. They will publish them tomorrow.». قلها بصوت عالٍ، وعندها يجب أن يعرف شيءٌ ما أن الموجة الصوتية التي أصدرتها لـ running تُحسب تلك الكلمة لا runny. واكتبها، وعندها يجب أن يعرف شيءٌ ما أن they تعني الطلاب وthem تعني التجارب. وبين هذين الطرفين تقع مستويات المعرفة اللغوية، والشريحة 17 ترسمها مرتين: حلقاتٍ متحدة المركز، ومكدّسًا (stack) له جذران.
Walking one sentence up the ringsصعود جملة واحدة عبر الحلقات
Phonetics is, in Jurafsky and Martin's definition, "the study of the speech sounds used in the languages of the world, how they are produced in the human vocal tract, how they are realized acoustically, and how they can be digitized and processed". Its unit is the phone, the actual speech sound; the rings figure labels it "speech sounds", which is correct. A casual runnin' ends in a different phone from a careful running, and a recogniser must still hear one word: that variation is phonetics. Phonology abstracts over that variation to phonemes, the sound units that make one word different from another: running and runny differ by phonemes, however each is pronounced. Jurafsky and Martin put both under one heading in their list, "Phonetics and Phonology: knowledge about linguistic sounds", and note that speech recognition and synthesis need them to know "how words are pronounced in terms of sequences of sounds and how each of these sounds is realized acoustically".
Phonetics (علم الأصوات النطقي) هو، في تعريف Jurafsky وMartin، «دراسة أصوات الكلام المستخدمة في لغات العالم، وكيف تُنتج في المجرى الصوتي للإنسان، وكيف تتحقق صوتيًا (acoustically)، وكيف يمكن رقمنتها ومعالجتها». ووحدته الـ phone، أي الصوت الكلامي الفعلي؛ والشكل الحلقي يسمّيه «أصوات الكلام» (speech sounds)، وهذا صحيح. فكلمة runnin' المنطوقة بعفوية تنتهي بـ phone مختلف عن running المنطوقة بعناية، ومع ذلك يجب أن يسمع نظام التعرف على الكلام كلمة واحدة: هذا التنوع هو مجال phonetics. أما Phonology (علم الأصوات الوظيفي) فيجرّد هذا التنوع إلى فونيمات (phonemes)، وهي الوحدات الصوتية التي تجعل كلمة تختلف عن أخرى: running وrunny تختلفان بفونيمات، مهما كان نطق كل منهما. ويضع Jurafsky وMartin الاثنين تحت عنوان واحد في قائمتهما، «Phonetics and Phonology: المعرفة بالأصوات اللغوية»، ويلاحظان أن التعرف على الكلام وتوليده يحتاجان إليهما لمعرفة «كيف تُنطق الكلمات بوصفها تسلسلات من الأصوات وكيف يتحقق كل صوت منها صوتيًا».
On the text side the same role is played by Orthography, the writing system: the letters r-u-n-n-i-n-g, the fact that Arabic is written right to left with letters that change shape by position, the choice of Unicode code points. Both branches feed Morphology, which was the last concept: run plus -ing, student plus -s, Ahmad plus 's. Jurafsky and Martin's example is that "recognizing that doors is plural" requires morphology.
وعلى جانب النص يؤدي الدور نفسه orthography (الإملاء)، أي نظام الكتابة: الحروف r-u-n-n-i-n-g، وحقيقة أن العربية تُكتب من اليمين إلى اليسار بحروف يتغير شكلها بحسب موضعها، واختيار نقاط الترميز في Unicode. وكلا الفرعين يغذّي morphology (الصرف)، وهو موضوع المفهوم السابق: run زائد -ing، وstudent زائد -s، وAhmad زائد 's. ومثال Jurafsky وMartin هو أن «التعرف على أن doors جمع» يتطلب الصرف.
Above morphology sits the lexical level, which slide 16 calls "lexemes". A Lexeme is a vocabulary item with its senses: run as move fast, as operate, as manage. This is the level where Word sense disambiguation lives, the same task that slide 9 needed to read "heavy" as mass. Syntax is "knowledge of the structural relationships between words": the noun phrase "Dr. Ahmad's students" is the subject of "are running", and Parsing is the task that recovers such structure. Semantics is "knowledge of meaning", here the literal proposition that some students conduct experiments.
فوق الصرف يقع المستوى المعجمي (lexical)، الذي تسمّيه الشريحة 16 «lexemes». والـ lexeme (الوحدة المعجمية) مفردة من المفردات مع معانيها: run بمعنى يركض، وبمعنى يشغّل، وبمعنى يدير. وهذا هو المستوى الذي تعيش فيه word sense disambiguation (تحديد معنى الكلمة)، وهي المهمة نفسها التي احتاجتها الشريحة 9 لقراءة «heavy» بمعنى الكتلة. وsyntax (النحو) هو «المعرفة بالعلاقات البنيوية بين الكلمات»: العبارة الاسمية «Dr. Ahmad's students» هي فاعل «are running»، وparsing (التحليل النحوي) هو المهمة التي تستعيد هذه البنية. وsemantics (علم الدلالة) هو «المعرفة بالمعنى»، وهو هنا القضية الحرفية بأن بعض الطلاب يُجرون تجارب.
The last two levels leave the sentence (the rings stop at pragmatics; only the stack adds discourse above it). Pragmatics is "knowledge of the relationship of meaning to the goals and intentions of the speaker": "tomorrow" names a different day depending on when the sentence was written, which is exactly what the calendar extraction of slide 12 had to resolve. Discourse is "knowledge about linguistic units larger than a single utterance": deciding that they and them refer back to the students and the experiments is coreference resolution, the standard discourse task. Jurafsky and Martin close the list with the sentence that opens the next part: "most tasks in speech and language processing can be viewed as resolving ambiguity at one of these levels".
المستويان الأخيران يتجاوزان الجملة (الحلقات تتوقف عند pragmatics؛ والمكدّس وحده يضيف discourse فوقه). pragmatics (التداولية) هي «المعرفة بعلاقة المعنى بأهداف المتكلم ومقاصده»: «tomorrow» (غدًا) تشير إلى يوم مختلف بحسب وقت كتابة الجملة، وهذا بالضبط ما كان على استخراج التقويم في الشريحة 12 أن يحلّه. وdiscourse (الخطاب) هو «المعرفة بالوحدات اللغوية الأكبر من قول واحد»: تقرير أن they وthem تعودان على الطلاب والتجارب هو coreference resolution (حل الإحالة المشتركة)، وهي المهمة المعيارية على مستوى الخطاب. ويختم Jurafsky وMartin القائمة بالجملة التي تفتتح الجزء التالي: «معظم المهام في معالجة الكلام واللغة يمكن النظر إليها على أنها حل لالتباس عند أحد هذه المستويات».
| Levelالمستوى | Unitالوحدة | Question it answersالسؤال الذي يجيب عنه | Example taskمهمة مثالية |
|---|---|---|---|
| Phoneticsعلم الأصوات النطقي (Phonetics) | Phones (speech sounds)الأصوات الكلامية (phones) | How is it pronounced, and what does the waveform look like?كيف يُنطق، وكيف يبدو شكل الموجة الصوتية؟ | Speech recognition front end, feature extractionالواجهة الأمامية للتعرف على الكلام، واستخراج السمات |
| Phonologyعلم الأصوات الوظيفي (Phonology) | Phonemesالفونيمات (phonemes) | Which sound differences change the word?أي فروق صوتية تغيّر الكلمة؟ | Pronunciation modelling in speech recognition and synthesisنمذجة النطق في التعرف على الكلام وتوليده |
| Orthographyالإملاء (Orthography) | Characters, Unicode code pointsالحروف، ونقاط الترميز في Unicode | How is the language written?كيف تُكتب اللغة؟ | Unicode and UTF-8 handling, script-specific normalisationالتعامل مع Unicode و UTF-8، والتطبيع الخاص بكل نظام كتابة |
| Morphologyالصرف (Morphology) | Morphemesالمورفيمات (morphemes) | What parts is the word built from?من أي أجزاء بُنيت الكلمة؟ | Stemming, lemmatization, subword tokenizationالتجذيع (stemming)، والتأصيل المعجمي (lemmatization)، والتقطيع إلى وحدات جزئية (subword tokenization) |
| Lexicalالمعجمي (Lexical) | Lexemes and sensesالوحدات المعجمية (lexemes) ومعانيها | Which word, and which sense of it?أي كلمة، وبأي معنى من معانيها؟ | Word sense disambiguation (the 'heavy' of slide 9)تحديد معنى الكلمة (word sense disambiguation)، مثل 'heavy' في الشريحة 9 |
| Syntaxالنحو (Syntax) | Phrases and sentencesالعبارات والجمل | How do the words group?كيف تتجمع الكلمات؟ | Parsing, prepositional phrase attachment (slide 21)التحليل النحوي (parsing)، وإلحاق شبه الجملة الحرفية (الشريحة 21) |
| Semanticsعلم الدلالة (Semantics) | Propositionsالقضايا (propositions) | What does it literally mean?ما معناه الحرفي؟ | Semantic role labelling, question answeringوسم الأدوار الدلالية (semantic role labelling)، والإجابة عن الأسئلة |
| Pragmaticsالتداولية (Pragmatics) | An utterance in contextقول في سياقه (utterance in context) | What did the speaker intend?ماذا قصد المتكلم؟ | Resolving 'tomorrow' in slide 12, dialogue systemsحل 'tomorrow' في الشريحة 12، وأنظمة الحوار |
| Discourseالخطاب (Discourse) | Multi-sentence textنص من عدة جمل | How do the sentences connect?كيف تترابط الجمل؟ | Coreference resolution, coherence modellingحل الإحالة المشتركة (coreference resolution)، ونمذجة الترابط |
Two figures, three omissionsشكلان، وثلاثة إغفالات
The rings and the stack on slide 17 disagree in three small ways, and each is worth knowing because they are the kind of thing an exam question probes. The rings have no lexical ring: they go straight from morphology (words) to syntax (phrases and sentences), while the stack has "lexemes" between them. The rings have no orthography: they start from phonetics as if all input were speech, while the stack shows the text branch explicitly. The rings also stop at pragmatics, labelled "meaning in context of discourse", while the stack puts a separate discourse level on top. Read the stack as the complete list and the rings as the speech-first view.
الحلقات والمكدّس في الشريحة 17 يختلفان في ثلاثة أمور صغيرة، وكل منها يستحق المعرفة لأنها من النوع الذي يختبره سؤال الامتحان. الحلقات ليس فيها حلقة معجمية (lexical): تنتقل مباشرة من morphology (الكلمات) إلى syntax (العبارات والجمل)، بينما في المكدّس «lexemes» بينهما. والحلقات ليس فيها orthography: تبدأ من phonetics كأن كل المدخلات كلام منطوق، بينما يُظهر المكدّس فرع النص صراحة. والحلقات أيضًا تتوقف عند pragmatics، المعنونة «meaning in context of discourse» (المعنى في سياق الخطاب)، بينما يضع المكدّس مستوى discourse منفصلًا في الأعلى. اقرأ المكدّس بوصفه القائمة الكاملة، والحلقات بوصفها المنظور الذي يبدأ من الكلام.
Quick checkاختبار سريع
Which level of linguistic knowledge deals with meaning in the context of the discourse and the speaker's intent?أي مستوى من مستويات المعرفة اللغوية يتناول المعنى في سياق الخطاب ومقصد المتكلم؟
Quick checkاختبار سريع
Which two levels does speech input pass through that text input skips?ما المستويان اللذان يمر بهما مدخل الكلام ويتخطاهما مدخل النص؟
Recall
Order the levels from sound to discourse, and say which two apply to speech only.رتّب المستويات من الصوت إلى الخطاب، وقل أي اثنين منها يخصان الكلام المنطوق فقط.
The lecture opens its next question, why NLP is difficult, with a picture rather than a list: a baby in a pinstriped suit sitting beside a laptop, labelled "Predisposed for acquiring language" and "Not so!". The joke carries the most important idea in the part. Jurafsky and Martin cite estimates that young adult speakers of American English know between 30,000 and 100,000 words, and conclude that children must learn "about 7 to 10 words a day, every single day" to reach that level by age 20 (the full range alone implies roughly 4 to 14 a day), most of them picked up "as a by-product of reading" with nobody teaching each one. The laptop knows nothing until someone types rules or feeds it data.
تفتتح المحاضرة سؤالها التالي، لماذا NLP صعبة، بصورة لا بقائمة: رضيع في بدلة مقلّمة يجلس بجانب حاسوب محمول، مع العبارتين «Predisposed for acquiring language» (مهيّأ لاكتساب اللغة) و«Not so!» (ليس كذلك!). والنكتة تحمل أهم فكرة في هذا الجزء. يستشهد Jurafsky وMartin بتقديرات تفيد بأن المتحدثين البالغين الشباب بالإنجليزية الأمريكية يعرفون بين 30,000 و100,000 كلمة، ويستنتجان أن الأطفال يجب أن يتعلموا «نحو 7 إلى 10 كلمات يوميًا، كل يوم دون انقطاع» ليصلوا إلى هذا المستوى بحلول سن 20 (والمدى الكامل وحده يعني تقريبًا 4 إلى 14 كلمة يوميًا)، ومعظمها يُلتقط «بوصفه نتيجة جانبية للقراءة» دون أن يعلّم أحدٌ كل كلمة منها. أما الحاسوب المحمول فلا يعرف شيئًا حتى يكتب له أحدٌ قواعد أو يغذّيه ببيانات.
The claim on the slide is the nativist position in psycholinguistics. Its classic argument is the poverty of the stimulus: in the Stanford Encyclopedia's summary, "there are aspects of developed linguistic competence which cannot be explained with respect to the evidence available to the language learning child", so something must be built in. The debate about how much is built in remains open; the same entry notes that modern empiricists no longer defend a blank slate but "complex, innately structured minds and learning systems" while denying that any of them are specific to language. For this course you do not need to settle that. You need the part of the slide that nobody disputes: whatever a child brings to the task, a machine brings none of it.
الادعاء في الشريحة هو الموقف الفطري (nativist) في علم النفس اللغوي. وحجته الكلاسيكية هي فقر المثير (poverty of the stimulus): في تلخيص موسوعة Stanford، «هناك جوانب من الكفاءة اللغوية المكتملة لا يمكن تفسيرها بالأدلة المتاحة للطفل الذي يتعلم اللغة»، فلا بد أن يكون شيء ما مبنيًا فيه مسبقًا. والجدل حول مقدار ما هو مبني مسبقًا لا يزال مفتوحًا؛ إذ يلاحظ المدخل نفسه أن التجريبيين المعاصرين لم يعودوا يدافعون عن صفحة بيضاء، بل عن «عقول وأنظمة تعلّم معقدة ذات بنية فطرية»، مع إنكارهم أن يكون أيٌّ منها خاصًا باللغة. في هذا المقرر لا تحتاج إلى حسم ذلك. تحتاج إلى الجزء من الشريحة الذي لا يجادل فيه أحد: مهما كان ما يجلبه الطفل إلى المهمة، فالآلة لا تجلب منه شيئًا.
Now put the two previous concepts side by side. The rings list the Knowledge of language that any language processor must have, from phonetics to discourse. The four approaches list the only two ways that knowledge can get into a machine: a person writes it down (rule-based), or a model extracts it from data (machine learning and Deep learning). There is no third route. Every ring, for every language the system must handle, has to be filled through one of those two arrows. That is why NLP is difficult, which part 4 takes up, and why slide 24 lists the disciplines and tools needed to do the filling.
الآن ضع المفهومين السابقين جنبًا إلى جنب. الحلقات تسرد knowledge of language (المعرفة باللغة) التي يجب أن يملكها أي معالج للغة، من phonetics إلى discourse. والمناهج الأربعة تسرد الطريقتين الوحيدتين اللتين يمكن أن تدخل بهما هذه المعرفة إلى الآلة: إما أن يكتبها إنسان (rule-based)، وإما أن يستخرجها نموذج من البيانات (machine learning وdeep learning). لا يوجد طريق ثالث. كل حلقة، ولكل لغة يجب أن يتعامل معها النظام، يجب أن تُملأ عبر أحد هذين السهمين. ولهذا NLP صعبة، وهو ما يتناوله الجزء 4، ولهذا تسرد الشريحة 24 التخصصات والأدوات اللازمة لعملية الملء هذه.
The learned route is now the dominant one, and Jurafsky and Martin describe how far it reaches: large language models "learn this knowledge of language, knowledge of concepts, and knowledge of the world simply by being taught to predict the next word", an idea that goes back to the distributional hypothesis of the 1950s. Note what the learner is given: text, and only text. A child gets speech embedded in a situation, with gestures, objects and corrections. Jurafsky and Martin add that "grounding from real-world interaction or other modalities like vision can help build even more powerful models, but even text alone is remarkably useful".
طريق التعلم هو المهيمن الآن، ويصف Jurafsky وMartin إلى أي مدى يصل: large language models (النماذج اللغوية الكبيرة) «تتعلم هذه المعرفة باللغة، والمعرفة بالمفاهيم، والمعرفة بالعالم، ببساطة عبر تدريبها على توقّع الكلمة التالية»، وهي فكرة ترجع إلى الفرضية التوزيعية (distributional hypothesis) في الخمسينيات (1950s). لاحظ ما يُعطى للمتعلم: نص، ونص فقط. أما الطفل فيحصل على كلام مغروس في موقف، مع إيماءات وأشياء وتصحيحات. ويضيف Jurafsky وMartin أن «التأريض (grounding) من التفاعل مع العالم الحقيقي أو من وسائط أخرى مثل الرؤية يمكن أن يساعد في بناء نماذج أقوى، لكن حتى النص وحده مفيد على نحو لافت».
What each learner starts withما يبدأ به كل متعلّم
- Childالطفل
- A predisposition to acquire language (the slide's claim), plus speech in context with feedbackتهيّؤ فطري لاكتساب اللغة (وهو ادعاء الشريحة)، إضافةً إلى كلام في سياقه مع تغذية راجعة
- Rule-based systemالنظام القائم على القواعد
- Whatever grammars, lexicons and regular expressions a person has writtenما كتبه إنسان من قواعد نحوية (grammars) ومعاجم (lexicons) وتعابير نمطية (regular expressions)، لا أكثر
- Learned systemالنظام المتعلِّم
- An architecture and a training objective; every level must be extracted from dataمعمارية وهدف تدريب؛ وكل مستوى يجب أن يُستخرج من البيانات
Quick checkاختبار سريع
According to slide 19, how must each level of linguistic knowledge get into a machine?بحسب الشريحة 19، كيف يجب أن يدخل كل مستوى من مستويات المعرفة اللغوية إلى الآلة؟
Recall
What must happen to every level of linguistic knowledge before a machine can use it, and why does the slide contrast the machine with a child?ما الذي يجب أن يحدث لكل مستوى من مستويات المعرفة اللغوية قبل أن تستطيع الآلة استخدامه، ولماذا تقارن الشريحة الآلة بالطفل؟
Recapالخلاصة
If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا
- The four approaches differ in who supplies the knowledge: rules (a human), classical ML (human features, data-set weights), end-to-end deep learning (data supplies the representations too), hybrid (rules around a learned core).تختلف المناهج الأربعة في من يوفّر المعرفة: القواعد (الإنسان)، وتعلم الآلة الكلاسيكي (الإنسان يحدد السمات والبيانات تحدد الأوزان)، والتعلم العميق من الطرف إلى الطرف (البيانات توفّر التمثيلات أيضًا)، والهجين (قواعد تحيط بنواة متعلَّمة).
- Rule-based NLP runs from the Georgetown-IBM demo of 1954 (250 words, six rules) and ELIZA in 1966 through the symbolic era to the early 1990s; statistical methods dominated until 2017; transformers (2017) and prompting (2019) define the current era.تمتد معالجة اللغة القائمة على القواعد من عرض Georgetown-IBM عام 1954 (250 كلمة وست قواعد) و ELIZA عام 1966 مرورًا بالحقبة الرمزية حتى أوائل التسعينيات؛ ثم هيمنت الطرق الإحصائية حتى 2017؛ وتحدد المحوّلات (transformers) عام 2017 والتلقين (prompting) عام 2019 الحقبة الحالية.
- The pipeline is paragraphs to sentences (sentence boundary disambiguation), sentences to words (tokenization), words to morphology (stemming or lemmatization). Parsing builds structure over tokens; it is not a splitting step.خط المعالجة هو: من الفقرات إلى الجمل (تحديد حدود الجمل)، ومن الجمل إلى الكلمات (tokenization)، ومن الكلمات إلى الصرف (stemming أو lemmatization). أما التحليل النحوي (parsing) فيبني بنية فوق الوحدات؛ وليس خطوة تقسيم.
- The period is ambiguous: abbreviation, decimal or sentence end, and sometimes two at once, as in 'Acme Inc.' at the end of a sentence.النقطة ملتبسة: قد تكون علامة اختصار، أو فاصلة عشرية، أو نهاية جملة، وأحيانًا اثنين معًا، كما في 'Acme Inc.' في آخر الجملة.
- Tokenization is not trivial: clitics ('s, n't, Arabic b and w), hyphens, numbers, and Chinese, Japanese and Thai with no spaces between words.التقطيع إلى وحدات ليس أمرًا تافهًا: هناك اللواحق المتصلة (clitics) مثل 's و n't وحرفا الباء والواو في العربية، والشرطات، والأرقام، واللغات الصينية واليابانية والتايلاندية التي لا تضع مسافات بين الكلمات.
- Stemming chops (experiments to experi, are to ar); lemmatization looks up (experiments to experiment, are to be) and may need the part of speech.التجذيع يقطع (experiments إلى experi، و are إلى ar)؛ والتأصيل المعجمي يبحث في المعجم (experiments إلى experiment، و are إلى be) وقد يحتاج إلى نوع الكلمة (part of speech).
- Levels from sound to discourse: phonetics, phonology (speech only), orthography (text only), morphology, lexical, syntax, semantics, pragmatics, discourse. Most NLP tasks resolve ambiguity at one of these levels.المستويات من الصوت إلى الخطاب: phonetics، ثم phonology (للكلام فقط)، ثم orthography (للنص فقط)، ثم morphology، ثم lexical، ثم syntax، ثم semantics، ثم pragmatics، ثم discourse. ومعظم مهام NLP تحل التباسًا عند أحد هذه المستويات.
- A child is predisposed to acquire language; a machine is not, so every level must be hand-coded or learned from data. That is the bridge to why NLP is hard.الطفل مهيّأ فطريًا لاكتساب اللغة؛ أما الآلة فليست كذلك، ولذلك يجب أن يُبرمج كل مستوى يدويًا أو يُتعلّم من البيانات. وهذا هو الجسر إلى سؤال لماذا NLP صعبة.
Sourcesالمصادر
- Speech and Language Processing, 3rd edition draft, chapter 1: IntroductionBookJurafsky and Martin, StanfordHistory of NLP and Figure 1.6 (section 1.4), vocabulary growth (1.2), interpretability and probing (1.5), LLMs learning from next-word predictionتاريخ NLP والشكل 1.6 (القسم 1.4)، ونمو المفردات (1.2)، وقابلية التفسير والسَّبر (1.5)، وتعلّم النماذج اللغوية الكبيرة من توقّع الكلمة التالية(opens in a new tab)(يفتح في تبويب جديد)
- Speech and Language Processing, 3rd edition draft, chapter 2: Words and TokensBookJurafsky and Martin, StanfordELIZA, morphemes and clitics, Chinese segmentation, Penn Treebank tokenization, rule-based tokenization, sentence segmentation (2.8.1), GPT-2 pre-tokenizer regex (Figure 2.15)ELIZA، والمورفيمات واللواحق المتصلة (clitics)، وتجزئة الصينية، والتقطيع بعرف Penn Treebank، والتقطيع القائم على القواعد، وتقسيم الجمل (2.8.1)، والتعبير النمطي للتقطيع المسبق في GPT-2 (الشكل 2.15)(opens in a new tab)(يفتح في تبويب جديد)
- Speech and Language Processing, 3rd edition draft, chapter 15: PhoneticsBookJurafsky and Martin, StanfordDefinition of phonetics, phones, the phonemeتعريف علم الأصوات النطقي (phonetics)، والأصوات الكلامية (phones)، والفونيم (phoneme)(opens in a new tab)(يفتح في تبويب جديد)
- Speech and Language Processing, 3rd edition draft, chapter 16: Automatic Speech RecognitionBookJurafsky and Martin, StanfordEncoder-decoder speech recognition with no hand-built pronunciation pipelineالتعرف على الكلام بنماذج encoder-decoder دون خط معالجة للنطق مبني يدويًا(opens in a new tab)(يفتح في تبويب جديد)
- Speech and Language Processing, 3rd edition draft, chapter 18: Sequence LabelingBookJurafsky and Martin, StanfordHMMs, CRFs, feature templates and word-shape features designed by hand (18.5)نماذج HMM و CRF، وقوالب السمات (feature templates) وسمات شكل الكلمة (word-shape) المصممة يدويًا (18.5)(opens in a new tab)(يفتح في تبويب جديد)
- Speech and Language Processing, 3rd edition draft, chapter 24: Coreference ResolutionBookJurafsky and Martin, StanfordCoreference as the standard discourse-level taskالإحالة المشتركة (coreference) بوصفها المهمة المعيارية على مستوى الخطاب(opens in a new tab)(يفتح في تبويب جديد)
- Speech and Language Processing, 2nd edition, chapter 1 (sample chapter)BookPearson, Jurafsky and MartinSection 1.1: the six kinds of knowledge from phonetics and phonology to discourse; section 1.2: most tasks resolve ambiguity at one of these levelsالقسم 1.1: أنواع المعرفة الستة من phonetics و phonology إلى discourse؛ والقسم 1.2: معظم المهام تحل التباسًا عند أحد هذه المستويات(opens in a new tab)(يفتح في تبويب جديد)
- Introduction to Information Retrieval: Stemming and lemmatizationBookCambridge University Press, Manning, Raghavan and SchützeDefinitions of stemming and lemmatization, am/are/is to be, Porter as the most common English stemmerتعريفا التجذيع (stemming) والتأصيل المعجمي (lemmatization)، وتحويل am/are/is إلى be، و Porter بوصفه أشهر مجذِّع للإنجليزية(opens in a new tab)(يفتح في تبويب جديد)
- Natural Language Processing with Python, chapter 3BookBird, Klein and Loper, NLTKStemming is not a well-defined process; Porter versus the WordNet lemmatizer; Punkt sentence tokenizerالتجذيع ليس عملية محددة تحديدًا جيدًا؛ ومقارنة Porter بمؤصِّل WordNet؛ ومقسِّم الجمل Punkt(opens in a new tab)(يفتح في تبويب جديد)
- An algorithm for suffix stripping (Program 14(3), 1980), official pagePaperM. F. PorterThe original Porter algorithm with test vocabulary and outputsخوارزمية Porter الأصلية مع مفردات الاختبار ومخرجاتها(opens in a new tab)(يفتح في تبويب جديد)
- The Georgetown-IBM experiment demonstrated in January 1954PaperAMTA 2004, W. J. Hutchins250 words and six grammar rules250 كلمة وست قواعد نحوية(opens in a new tab)(يفتح في تبويب جديد)
- Conditional Random Fields: Probabilistic Models for Segmenting and Labeling Sequence DataPaperICML 2001, Lafferty, McCallum and PereiraThe CRF, a classical ML sequence modelنموذج CRF، وهو نموذج تسلسلي من تعلم الآلة الكلاسيكي(opens in a new tab)(يفتح في تبويب جديد)
- Sequence to Sequence Learning with Neural NetworksPaperNeurIPS 2014, Sutskever, Vinyals and LeDeep LSTM encoder and decoder for translationمرمِّز (encoder) ومفكِّك ترميز (decoder) من نوع LSTM عميق للترجمة(opens in a new tab)(يفتح في تبويب جديد)
- Attention Is All You NeedPaperNeurIPS 2017, Vaswani et al.The Transformer, based solely on attentionالمحوّل (Transformer)، القائم على الانتباه (attention) وحده(opens in a new tab)(يفتح في تبويب جديد)
- Neural Machine Translation of Rare Words with Subword UnitsPaperACL 2016, Sennrich, Haddow and BirchByte-pair encoding as learned subword tokenizationترميز أزواج البايتات (byte-pair encoding) بوصفه تقطيعًا متعلَّمًا إلى وحدات جزئية(opens in a new tab)(يفتح في تبويب جديد)
- Unsupervised Multilingual Sentence Boundary DetectionPaperComputational Linguistics 2006, Kiss and StrunkThe Punkt method for learning abbreviation listsطريقة Punkt لتعلّم قوائم الاختصارات(opens in a new tab)(يفتح في تبويب جديد)
- A Structural Probe for Finding Syntax in Word RepresentationsPaperNAACL 2019, Hewitt and ManningSyntax trees recovered from inside language model representationsأشجار نحوية مستعادة من داخل تمثيلات النماذج اللغوية(opens in a new tab)(يفتح في تبويب جديد)
- BERT Rediscovers the Classical NLP PipelinePaperACL 2019, Tenney, Das and PavlickCoreference and other levels encoded inside BERTالإحالة المشتركة ومستويات أخرى مُرمَّزة داخل BERT(opens in a new tab)(يفتح في تبويب جديد)
- Innateness and LanguageArticleStanford Encyclopedia of Philosophy, G. DupreThe poverty of the stimulus argument and the state of the nativist debateحجة فقر المثير (poverty of the stimulus) وحال الجدل حول الموقف الفطري (nativist)(opens in a new tab)(يفتح في تبويب جديد)