Administrator
This teaching view is for the instructor. Enter the administrator password.
Wrong password · Mot de passe incorrect
When you read the word happiness, you may think of many things. You may think of related words, like joy or contentment. You may think about the translation in another language, like bonheur or geluk. You may think about a different form of the word: happy. Depending on your musical preferences, you may think of a song by Taylor Swift, Pharrell Williams, or “if you’re happy and you know it clap your hands”.
When a computer program “reads” the word happiness, it only gets a series of bits: the numbers associated to the characters of that exact word. The only easy connections to compute would be to other sequences of similar bits. For instance, the word happening has many of the same letters and exactly the same length.
So this is the fundamental challenge of NLP natural language processing (NLP)traitement automatique de la langue (TAL) NLPTAL An interdisciplinary field that develops and studies computational methods for analyzing, processing, and generating human language.Domaine interdisciplinaire qui développe et étudie des méthodes computationnelles pour analyser, traiter et générer le langage humain. : how do we get computer systems, designed to compute, i.e., calculate with numbers, to work with language? How can we capture language in numbers, beyond simple character similarities?
Ask the room what happiness brings them before showing the right-hand side. The point to land: the codes are a table position, not a meaning, and happiness and happening are two characters apart.
Il est encore là means he is still there, when you have been waiting for him to leave. It means he is there again, when he also came yesterday. Same four words, and English has no one word that covers both: the translation has to commit to still or to again. You make that choice from context, instantly and usually without registering that a choice existed.
Ambiguity like this runs through language at every level:
- Words. Livre is a book or a pound; marche is a step, a walk, or a form of marcher; English bat is an animal or sports equipment. Most frequent words have several senses, a property called polysemy polysemypolysémie linguisticslinguistique The property of a word or lemma having two or more related senses.Propriété d'un mot ou d'un lemme qui possède deux sens apparentés ou plus. , and text does not label which sense is meant.
- Structure. Groucho Marx, in Animal Crackers: “One morning I shot an elephant in my pajamas. How he got in my pajamas, I don’t know.” The joke is the second sentence taking the reading you did not. In my pajamas can hang from shot or from elephant, both are grammatical, and nothing but your sense of what is likely picked one.
The promptLa requête
I want to generate an image to illustrate Groucho Marx's joke "One morning I shot an elephant in my pajamas. How he got into my pajamas I'll never know." Can you generate an image of a moustached person with big eyebrows and a cigar, shooting a picture of an elephant wearing pajamas? Make it resemble a watercolour picture.
- Reference. In the animal didn’t cross the street because it was too tired, the word it points at the animal; make the ending too wide and the same word points at the street. Nothing in the grammar decides; what streets and animals can be does.
The same property makes this hard for machines and invisible to people. Resolving it was too wide takes knowledge about streets; resolving encore takes the surrounding sentences. You bring that knowledge for free. A computer has to be given it, in a form it can compute with.
Your professional reflex, it depends on the context, is the requirement that word-by-word approaches to language technology could not satisfy.
The translators in the room resolve all three without noticing. That is the point: every effortless resolution is a computation somebody has to pay for. Mardi, je suis libre against Enfin, je suis libre ! is the one to run live if there is time.
Language never stands still or stays uniform. The French of a Montréal contract, a Paris news site and a group chat differ in vocabulary, spelling and syntax while all being French. New words arrive continuously (selfie, deepfake and a steady stream of borrowed tech vocabulary; covid did not exist in 2019 and was unavoidable a year later), old words shift sense, and real text is full of typos, abbreviations and creative usage that no dictionary anticipated.
And where language does follow rules, as the expression goes, the exception proves the rule. French plurals add -s, except -al words taking -aux, except bals and festivals; English past tenses add -ed, except a few hundred of the most frequent verbs. Writing the rule is quick. The real challenge is writing the exceptions, the exceptions to the exceptions, and the way the rules interact with one another: each addition fixes some cases and breaks others, and the effort of maintaining the set grows with its size.
Rule-based systems rule-based systemsystème à base de règles AIIA A system whose behaviour is fixed by rules that people wrote, most often of the form "if this condition, then this action", so that every output can be traced to the rule that produced it.Système dont le comportement est fixé par des règles écrites par des personnes, le plus souvent de la forme « si cette condition, alors cette action », de sorte que chaque résultat peut être rapporté à la règle qui l'a produit. can still be useful for simple, well-defined tasks: if someone types example in a French text, autocorrect it to exemple. However, the more complex and open-ended the task, the more ambiguity ambiguityambiguïté linguisticslinguistique The property of a stretch of language that allows more than one interpretation.Propriété d'un segment de langue qui autorise plus d'une interprétation. there is, and the more likely it becomes that no limited set of rules can capture it.
This is the concrete experience behind the move to learning from data (see also the Four paradigms page, in the Foundations of AI & NLP module) (voir aussi la page Quatre paradigmes, dans le module Fondements de l'IA et du TAL). A statistical system does not need the exception list written out. Given enough text, the exceptions are in the data, with their frequencies attached.
The catch is the phrase given enough text. A system that learns language from data inherits the language of that data, its regions, registers and blind spots included, and that inheritance can be measured directly on the languages a model handles worst (see also the Consequences of tokenization chapter, in the Language as numbers module) (voir aussi le chapitre Conséquences de la jetonisation, dans le module Le langage en nombres).
Last line is the pivot to the rest of the term: statistics do not need the exception list written out. The cost of that move, inheriting the language of the data, comes back in the tokenization chapter.
Quand vous lisez le mot bonheur, vous pouvez penser à bien des choses. Vous pouvez penser à des mots apparentés, comme joie ou contentement. Vous pouvez penser à sa traduction dans une autre langue, comme happiness ou geluk. Vous pouvez penser à une autre forme du mot : heureux. Selon vos goûts musicaux, vous pouvez penser à une chanson de Taylor Swift, de Pharrell Williams ou à « si tu aimes le soleil, tape des mains ».
Quand un programme informatique « lit » le mot bonheur, il ne reçoit qu’une suite de bits : les nombres associés aux caractères de ce mot précis. Les seules mises en relation faciles à calculer seraient avec d’autres suites de bits semblables. Le mot honneur, par exemple, a exactement la même longueur et cinq de ses sept lettres à la même place.
Voilà le défi fondamental du TAL natural language processing (NLP)traitement automatique de la langue (TAL) NLPTAL An interdisciplinary field that develops and studies computational methods for analyzing, processing, and generating human language.Domaine interdisciplinaire qui développe et étudie des méthodes computationnelles pour analyser, traiter et générer le langage humain. : comment amener des systèmes informatiques, conçus pour calculer, c’est-à-dire pour faire des opérations sur des nombres, à travailler sur la langue ? Comment capter la langue en nombres, au-delà des simples ressemblances entre caractères ?
Demander au groupe ce que bonheur lui évoque avant de montrer la partie droite. Le point à faire passer : les codes sont une position dans une table, pas un sens.
Il est encore là veut dire qu’il n’est pas encore parti, quand vous attendiez qu’il parte. Cela veut dire qu’il est revenu, quand il était déjà venu la veille. Les quatre mêmes mots, et l’anglais n’a aucun mot qui couvre les deux sens : la traduction doit trancher entre still et again. Vous faites ce choix à partir du contexte, immédiatement et sans même remarquer qu’un choix se présentait.
Une ambiguïté de ce genre traverse la langue à tous les niveaux :
- Les mots. Livre est un ouvrage ou une unité de poids ; marche est un degré d’escalier, une promenade ou une forme de marcher ; l’anglais bat est un animal ou un instrument de sport. La plupart des mots fréquents ont plusieurs sens, une propriété appelée polysémie polysemypolysémie linguisticslinguistique The property of a word or lemma having two or more related senses.Propriété d'un mot ou d'un lemme qui possède deux sens apparentés ou plus. , et le texte n’indique pas lequel est visé.
- La structure. Groucho Marx, dans Animal Crackers : « One morning I shot an elephant in my pajamas. How he got in my pajamas, I don’t know. » La blague tient à la deuxième phrase, qui prend le sens que vous n’aviez pas retenu. In my pajamas peut se rattacher à shot ou à elephant, les deux sont grammaticaux, et rien d’autre que votre idée du vraisemblable n’en a choisi un.
The promptLa requête
I want to generate an image to illustrate Groucho Marx's joke "One morning I shot an elephant in my pajamas. How he got into my pajamas I'll never know." Can you generate an image of a moustached person with big eyebrows and a cigar, shooting a picture of an elephant wearing pajamas? Make it resemble a watercolour picture.
- La référence. Dans le camion n’a pas franchi le pont parce qu’il était trop lourd, le mot il désigne le camion ; mettez trop étroit à la fin et le même mot désigne le pont. Les deux noms sont masculins, donc la grammaire ne tranche pas ; ce sont les propriétés des camions et des ponts qui le font.
C’est la même propriété qui rend la chose difficile pour une machine et invisible pour une personne. Résoudre trop étroit demande de savoir ce qu’est un pont ; résoudre encore demande les phrases autour. Vous apportez ce savoir gratuitement. Il faut le donner à un ordinateur, sous une forme avec laquelle il peut calculer.
Votre réflexe professionnel, cela dépend du contexte, est l’exigence à laquelle les approches mot à mot de la technologie langagière n’ont pas pu répondre.
Les traductrices et traducteurs de la salle lèvent les trois ambiguïtés sans s’en apercevoir. C’est le point : chaque résolution sans effort est un calcul que quelqu’un doit payer. Le camion et le pont est l’exemple à faire en direct s’il reste du temps : deux noms masculins, la grammaire ne tranche pas.
La langue ne s’arrête jamais et ne reste jamais uniforme. Le français d’un contrat montréalais, d’un site d’information parisien et d’un fil de clavardage diffère par le vocabulaire, l’orthographe et la syntaxe tout en restant du français. De nouveaux mots arrivent continuellement (égoportrait, hypertrucage et un flux constant de vocabulaire technique emprunté ; covid n’existait pas en 2019 et était incontournable un an plus tard), des mots anciens changent de sens, et les textes réels sont pleins de fautes de frappe, d’abréviations et d’usages inventifs qu’aucun dictionnaire n’avait prévus.
Et là où la langue suit bel et bien des règles, comme dit l’expression, l’exception confirme la règle. Le pluriel français ajoute -s, sauf les mots en -al qui prennent -aux, sauf bals et festivals ; le prétérit anglais ajoute -ed, sauf quelques centaines des verbes les plus fréquents. Écrire la règle est rapide. La vraie difficulté est d’écrire les exceptions, les exceptions aux exceptions et la façon dont les règles interagissent entre elles : chaque ajout corrige des cas et en casse d’autres, et l’effort d’entretien croît avec la taille du jeu de règles.
Les systèmes à base de règles rule-based systemsystème à base de règles AIIA A system whose behaviour is fixed by rules that people wrote, most often of the form "if this condition, then this action", so that every output can be traced to the rule that produced it.Système dont le comportement est fixé par des règles écrites par des personnes, le plus souvent de la forme « si cette condition, alors cette action », de sorte que chaque résultat peut être rapporté à la règle qui l'a produit. restent utiles pour des tâches simples et bien délimitées : si quelqu’un tape exemple dans un texte anglais, le corriger automatiquement en example. Cependant, plus la tâche est complexe et ouverte, plus elle comporte d’ambiguïté ambiguityambiguïté linguisticslinguistique The property of a stretch of language that allows more than one interpretation.Propriété d'un segment de langue qui autorise plus d'une interprétation. , et moins il est probable qu’un jeu de règles limité puisse en rendre compte.
C’est l’expérience concrète qui explique le passage à l’apprentissage à partir de données (see also the Four paradigms page, in the Foundations of AI & NLP module) (voir aussi la page Quatre paradigmes, dans le module Fondements de l'IA et du TAL). Un système statistique n’a pas besoin qu’on lui écrive la liste des exceptions. Avec assez de texte, les exceptions sont dans les données, avec leurs fréquences.
Le piège tient dans l’expression avec assez de texte. Un système qui apprend la langue à partir de données hérite de la langue de ces données, avec ses régions, ses registres et ses angles morts, et cet héritage se mesure directement sur les langues qu’un modèle traite le plus mal (see also the Consequences of tokenization chapter, in the Language as numbers module) (voir aussi le chapitre Conséquences de la jetonisation, dans le module Le langage en nombres).
La dernière ligne est le pivot vers le reste du trimestre : la statistique n’a pas besoin que la liste des exceptions soit écrite. Le coût de ce choix, hériter de la langue des données, revient dans le chapitre sur la jetonisation.
Cette vue enseignement n'existe qu'en anglais.
The systems behind much of today’s language technology, including almost all machine translation systems and chatbots with which you will interact, are neural networks. The name suggests something brain-like, and the inspiration is real, but loose: there are some similarities between artificial neural networks and natural neural networks like our brain, but this does not go beyond the very basics.
Each unit, called a neuron, is a small mathematical function. It receives numbers from the units connected to it, combines them, and passes a number on. Every connection has a strength, called a weight weightpoids machine learningapprentissage automatique A real number attached to one input of a computing unit, learned during training, that sets how much that input counts towards the unit's output.Nombre réel attaché à une entrée d'une unité de calcul, appris pendant l'entraînement, qui détermine l'importance de cette entrée dans la sortie de l'unité. , and those weights, the network’s parameters parameterparamètre de modèle machine learningapprentissage automatique A numerical value learned during a model's training and used in its computations.Valeur numérique apprise pendant l'entraînement d'un modèle et utilisée dans ses calculs. , are what training adjusts: a stronger connection means one unit’s output matters more to the next.
The units are organized in layers. An input layer takes in the raw data as numbers; one or more hidden layers transform it, step by step; an output layer produces the answer, for example one value per possible category. When there are many hidden layers, the network is called deep, which is all that the “deep” in deep learning means (LeCun et al., 2015).
Depth is what lets a network build complex patterns out of simple ones. Early layers pick up simple regularities in the raw input; later layers combine those into larger ones. In image recognition, the classic illustration, first edges, then shapes, then faces. For text the same principle applies, with one catch: a network’s input layer takes numbers, so using one for language requires a way to encode language as numbers (see also the Language as numbers module) (voir aussi le module Le langage en nombres).
Worth saying aloud and not projecting: the brain inspiration is real and loose, and each unit is a small mathematical function. Depth is what lets a network build complex patterns out of simple ones: edges, then shapes, then faces for images.
A toy example
Suppose we want a network that tells diamonds, squares and circles apart.Shapes are a toy task, chosen for its simplicity and easy visualization. A real network chooses among far more classes, and its input is rarely anything as tidy as a drawn shape. The loop is the same either way, which is what lets the example be this small. That already fixes the shape of its output layer: one unit per category, one for square, one for circle, one for diamond. Their scores are turned into percentages that add up to 100, so the three answers compete, and raising one lowers the others.
A network answers in probabilities from the start. Untrained, they are essentially random. Given a picture of a diamond and asked what shape it is, the answer might be something like: square 40%, circle 35%, diamond 25%. Early in training they can be confidently wrong instead: square 80%, circle 10%, diamond 10%. The network is then told the right answer, and the predict-compare-adjust loop of supervised learning reappears in its neural form (see also the From rules to machine learning chapter, in the Foundations of AI & NLP module) (voir aussi le chapitre Des règles à l'apprentissage automatique, dans le module Fondements de l'IA et du TAL): the error flows backward through the network, and the connections that pushed toward square are weakened, the ones that pushed toward diamond strengthened.
Millions of small adjustments
Adjustment is not reserved for mistakes. A network nudges its connections on every example, including the ones it already gets right; the nudge simply gets smaller as the prediction moves closer to the label. One example changes little. Millions of examples, each nudging millions of parameters parameterparamètre de modèle machine learningapprentissage automatique A numerical value learned during a model's training and used in its computations.Valeur numérique apprise pendant l'entraînement d'un modèle et utilisée dans ses calculs. , add up to a system whose predictions are sharp. Nothing else in the network changes during training: the architecture, the layers and the connections stay as designed. Learning is entirely a matter of adjusting the strengths.
The difference from a feature-based model
The decisive difference from a feature-based model is what the network learns from. A feature-based model needed a human to decide that suffixes and capitalization matter. A neural network takes raw data (e.g., pixels of an image, or numerical representations of words), and finds its own regularities in it, including ones no human would have thought to specify. The features are learned, and feature engineering disappears. The human work does not disappear with it: choosing and encoding features used to be most of the effort of building a system, and the effort now goes into collecting the data, defining the task and designing the network.
Why it took until the 2010s
Nothing about the idea is new: the underlying design goes back to the perceptron of the 1950s (Rosenblatt, 1958), the first model that could learn its own weights weightpoids machine learningapprentissage automatique A real number attached to one input of a computing unit, learned during training, that sets how much that input counts towards the unit's output.Nombre réel attaché à une entrée d'une unité de calcul, appris pendant l'entraînement, qui détermine l'importance de cette entrée dans la sortie de l'unité. from labelled examples (Goodfellow et al., 2016). In the 2010s, its two main requirements could finally be fulfilled. Learning features from raw data takes far more examples than learning weights for a few hand-picked features, and processing them takes enormous computation. Large collections of digital text and images supplied the first; graphics processors, built to render games, turned out to suit the calculations and supplied the second. With both in place, deep networks moved the state of the art in speech recognition, image recognition and object detection, and in fields as far from language as drug discovery (LeCun et al., 2015).
The second line is the one that connects back to the features chapter: no human decides that suffixes and capitalization matter. The third is the answer to “why now”: two appetites, data and computation, fed at the same time in the 2010s. LeCun et al. (2015) name speech, images and object detection as where it showed first.
With a rule-based system rule-based systemsystème à base de règles AIIA A system whose behaviour is fixed by rules that people wrote, most often of the form "if this condition, then this action", so that every output can be traced to the rule that produced it.Système dont le comportement est fixé par des règles écrites par des personnes, le plus souvent de la forme « si cette condition, alors cette action », de sorte que chaque résultat peut être rapporté à la règle qui l'a produit. you can always find out why an output came out as it did: some rule was triggered, and that rule can be read, disagreed with and changed. In a trained neural network there is nothing to read. Its behaviour is stored as millions of numerical connection weights weightpoids machine learningapprentissage automatique A real number attached to one input of a computing unit, learned during training, that sets how much that input counts towards the unit's output.Nombre réel attaché à une entrée d'une unité de calcul, appris pendant l'entraînement, qui détermine l'importance de cette entrée dans la sortie de l'unité. , learnt from data, and no single one of them means anything on its own. The mathematics of every step is known exactly; what the steps collectively do is not stated anywhere in a form a person can check.
Statistical systems are a sort of middle ground: their rules are learnt from data rather than written by hand, but stay more or less readable (see also the Four paradigms page, in the Foundations of AI & NLP module) (voir aussi la page Quatre paradigmes, dans le module Fondements de l'IA et du TAL). How readable depends on the algorithm: a decision tree can be printed and followed, while the weights of a support vector machine with a non-linear kernel cannot be read that way.
This is what people mean when they call neural networks black boxes, and it is a property of the approach rather than a defect to be patched later. The power of the method comes from letting the system find regularities too numerous and too diffuse for anyone to write down; a representation humans could read would be a representation humans could have written.
Four consequences follow for anyone who works with these systems:
- Errors cannot be fixed the way a rule is fixed. There is no line to correct. Improving a network means changing its training data training setjeu de données d'entraînement machine learningapprentissage automatique The portion of a dataset used to train a machine-learning model.Portion d'un jeu de données servant à entraîner un modèle d'apprentissage automatique. , training it further, or changing its architecture and training again, and any of these can shift its behaviour elsewhere in ways nobody chose.
- Behaviour is discovered by testing, not by inspection. The only way to know how a system handles legal text, or Québécois French, is to try it on legal text and Québécois French, which is why evaluation is a professional skill in its own right (see also the Evaluating language technology module) (voir aussi le module L'évaluation des technologies langagières).
- The same input need not give the same output. A classifier is deterministic deterministicdéterministe computinginformatique Describes a process, algorithm, or system that, under the same initial conditions and with the same input, always produces the same output.Se dit d'un processus, d'un algorithme ou d'un système qui, dans les mêmes conditions initiales et avec la même entrée, produit toujours la même sortie. : the same email gives the same verdict every time. A system that generates text often is not, because choosing each next word can involve randomness, and one run then differs from the next. A single trial is evidence about that run, not about the system.
- Confidence is not self-knowledge. A network reports probabilities, and they measure how its training data looked, never how much it “knows” (see also the Critical issues with LLMs module) (voir aussi le module Enjeux critiques des GML).
Put it to the room: how would you find out whether a system handles Québécois French? The only answer is to try it on Québécois French, which is why evaluation is a professional skill and a whole module here.
One model, many tasks
Every system of the first three paradigms was built for one task: a spam filter sorts email, a tagger labels words with their grammatical class, and the next system means starting again, with new rules, new features or new labelled data. A large language model is a neural network neural network (NN)réseau de neurones (RNA) machine learningapprentissage automatique A machine-learning model composed of interconnected layers of small computational units.Modèle d'apprentissage automatique composé de couches interconnectées de petites unités de calcul. of the kind this chapter describes, trained from examples like the second and third paradigms, except that the examples are plain text and the task is to predict the next word (Jurafsky & Martin, 2026). Nothing in that training names a task, and once trained, the same model translates, summarizes, lists the terms in a text or labels its words, when the request is written to it in a prompt (Brown et al., 2020). Figure 6figure 6 sets the two arrangements side by side.
Decreasing human influence
Each shift took one thing out of the developer’s hands, as the table below sets out, and the last took the largest: the task itself, which passes to the person using the model.
| Shift | No longer specified by the developer | Still specified by people |
|---|---|---|
| Rules to machine learning | the patterns | the task and the features, by the developer, before training |
| Machine learning to deep learning | the features featureattribut machine learningapprentissage automatique A property or representation of an observation that a machine-learning model uses as input when making a prediction.Propriété ou représentation d'une observation qu'un modèle d'apprentissage automatique utilise en entrée pour produire une prédiction. | the task and its data, by the developer, before training |
| Deep learning to large language models | the task | the task, by the person using the model, in a prompt |
A large language model is, technically, deep learning. Four things make it a paradigm of its own all the same, rather than a step inside the third:
- One general system instead of a system per task. The line is not absolute, since a model can be fine-tuned fine-tuningaffinage machine learningapprentissage automatique Further training of a pretrained model on new data to adapt it for a particular task, domain, or intended behaviour.Poursuite de l'entraînement d'un modèle préentraîné sur un jeu de données généralement plus restreint et spécialisé, afin de l'adapter à une tâche ou à un domaine particulier. for one task or one context (see also the Fine-tuning chapter, in the LLM lifecycle module) (voir aussi le chapitre Affinage, dans le module Cycle de vie des GML) and dedicated systems are built on top of models, but its capabilities are far broader than those of any earlier system, and a prompt alone reaches most of them.
- A far simpler interface, so far less specialized users. A prompt is ordinary text rather than a program, so the person who describes the job is often the person who used to be a user of someone else’s system. The line between building a system and using one has moved.
- An even larger appetite for data and computation, in place of explicit knowledge. Each earlier shift already traded knowledge written by people for data; this one trades the task description itself for more text and more computation.
- A blurrier line between natural language processing natural language processing (NLP)traitement automatique de la langue (TAL) NLPTAL An interdisciplinary field that develops and studies computational methods for analyzing, processing, and generating human language.Domaine interdisciplinaire qui développe et étudie des méthodes computationnelles pour analyser, traiter et générer le langage humain. and the rest of AI. The model that labels words or extracts terms is the same one that writes code, describes images and acts on your behalf, and language has become the interface to all of it.
A prompt steers a model without changing it, and within limits (see also the In-context learning chapter, in the LLM lifecycle module) (voir aussi le chapitre Apprentissage en contexte, dans le module Cycle de vie des GML).
Still deep learning
Everything that was true of the third paradigm is still true of the fourth:
- the patterns it learned are spread over billions of numbers nobody can read (see also the black box page, in the Foundations of AI & NLP module) (voir aussi la page La boîte noire, dans le module Fondements de l'IA et du TAL);
- everything it does comes from its training text, with that text’s gaps and leanings (see also the Critical issues with LLMs module) (voir aussi le module Enjeux critiques des GML);
- the tasks it does well and badly do not follow what a person finds hard, so its abilities have to be tested;
- the dedicated systems have not disappeared: for a task run on whole corpora, fast and the same way every time, a trained tagger or a term extractor is still the usual tool (see also the Comparing term extraction methods page, in the Classical NLP module) (voir aussi la page Comparer les méthodes d'extraction de termes, dans le module TAL classique).
If words have to become numbers, the obvious first move is a list: a dictionary with its entries numbered.
angelic = 1
ape = 2
apple = 3
ardour = 4
...
zany = 99,997
zeal = 99,998
zebra = 99,999Every word now has a number, and the conversion is trivial in both directions. But, as Figure 1figure 1 shows, there are three specific issues, where such numbers miss some essential part of what would make them useful.
- Arithmetic on these numbers is meaningless. One plus two is three, so an angelic (1) ape (2) makes an apple (3)? Any calculation a system performs on the codes manipulates alphabetical position, which has nothing to do with what the words mean.
- The numbers place related words no closer than unrelated ones. Ardour (4) and zeal (99,998) are near-synonyms sitting about 99,000 apart, farther from each other than either is from apple. A translation system needs exactly the opposite: words with similar meanings should have similar representations.
- A single number per word smuggles in an ordering. 99,999 is bigger than 2, but zebra is not more of anything than ape. A model fed these codes risks attaching meaning to the size of the number, where the only thing behind it is alphabetical order.
Walk the three across the figure: angelic (1) plus ape (2) is apple (3), ardour and zeal 99,000 apart, zebra “bigger” than ape. All three come back to the same thing: the numbers identify a word and say nothing about it.
The word vector sounds more technical than what it names.
Read [2, 3] as directions on a map: two steps along the horizontal axis,
three along the vertical, and you have marked a point. A vector with three
numbers marks a point in three-dimensional space, and nothing stops a vector
from having three hundred numbers; the space can no longer be drawn or
imagined, but the mathematics works the same way.
Points, unlike bare code numbers, have geometry. Two points can be close together or far apart; a cluster of points forms a group; a direction in the space can be followed. If each word is placed at a point, then closeness in the space becomes available to represent closeness in meaning, which a single number per word had no way to express.
The first vector representation of words that the field actually used works like a row of switches with one of them on. Each word in a 100,000-word vocabulary gets its own position, and is represented as a vector of 100,000 numbers: zeros everywhere, except a single 1 at that word’s position.
angelic = [1, 0, 0, 0, ..., 0, 0, 0]
ape = [0, 1, 0, 0, ..., 0, 0, 0]
apple = [0, 0, 1, 0, ..., 0, 0, 0]
ardour = [0, 0, 0, 1, ..., 0, 0, 0]
...
zebra = [0, 0, 0, 0, ..., 0, 0, 1]The false ordering is gone. No word’s vector is larger than another’s; zebra is no longer “more” than ape. In the geometry of the space, each word now owns its own axis, and every pair of words stands at exactly the same distance, like the corners of a perfectly symmetric figure.
Exactly the same distance is also the new problem. Ardour is now precisely as different from zeal as from zebra: the representation contains no similarity information at all, for anyone. It identifies words the way a locker number identifies a student, saying nothing about them.
There is a practical objection too. These vectors are enormous, and almost all of their content is zeros: 100,000 numbers per word, of which one is informative.
The numbered list crammed every word onto one axis and invented differences; the one-hot vector gives every word its own axis and erases all resemblance.
This is the screen the next chapter answers. Do not name embeddings yet if séance 2 is running to time; the requirement is enough to end the session on.
Si les mots doivent devenir des nombres, le premier réflexe est d’en faire une liste : un dictionnaire dont les entrées sont numérotées.
ananas = 1
ange = 2
animal = 3
ardeur = 4
...
zapper = 99 997
zèbre = 99 998
zèle = 99 999Chaque mot a maintenant un nombre, et la conversion se fait sans effort dans les deux sens. Mais, comme le montre la Figure 1figure 1, trois problèmes précis apparaissent, où de tels nombres passent à côté de ce qui les rendrait utiles.
- L’arithmétique sur ces nombres n’a aucun sens. Un plus deux font trois : un ananas (1) et un ange (2) donneraient donc un animal (3) ? Tout calcul effectué sur ces codes manipule une position alphabétique, qui n’a rien à voir avec le sens des mots.
- Les nombres ne rapprochent pas les mots apparentés plus que les mots sans rapport. Ardeur (4) et zèle (99 999) sont des quasi-synonymes séparés par environ 99 000, plus loin l’un de l’autre que chacun ne l’est d’animal. Un système de traduction a besoin exactement de l’inverse : des mots de sens proches devraient avoir des représentations proches.
- Un seul nombre par mot introduit un ordre en douce. 99 998 est plus grand que 1, mais un zèbre n’a rien de plus qu’un ananas. Un modèle nourri de ces codes risque de prêter un sens à la taille du nombre, alors que la seule chose derrière elle est l’ordre alphabétique.
Parcourir les trois sur la figure : ananas (1) plus ange (2) font animal (3), ardeur et zèle séparés par 99 000, zèbre « plus grand » qu’ananas. Les trois reviennent à la même chose : les nombres identifient un mot sans rien en dire.
Le mot vecteur a l’air plus technique que ce qu’il désigne.
[2, 3] se lit comme des indications sur une carte : deux pas le long de l’axe
horizontal, trois le long de l’axe vertical, et un point est marqué. Un vecteur
de trois nombres marque un point dans un espace à trois dimensions, et rien
n’empêche un vecteur d’avoir trois cents nombres ; l’espace ne peut alors plus
être dessiné ni imaginé, mais les mathématiques fonctionnent de la même façon.
Les points, contrairement à de simples numéros de code, ont une géométrie. Deux points peuvent être proches ou éloignés ; un ensemble de points forme un groupe ; une direction peut être suivie dans l’espace. Si chaque mot est placé en un point, la proximité dans l’espace devient disponible pour représenter la proximité de sens, ce qu’un seul nombre par mot n’avait aucun moyen d’exprimer.
La première représentation vectorielle des mots que le domaine ait réellement utilisée fonctionne comme une rangée d’interrupteurs dont un seul est allumé. Chaque mot d’un vocabulaire de 100 000 mots reçoit sa propre position et est représenté par un vecteur de 100 000 nombres : des zéros partout, sauf un seul 1 à la position de ce mot.
ananas = [1, 0, 0, 0, ..., 0, 0, 0]
ange = [0, 1, 0, 0, ..., 0, 0, 0]
animal = [0, 0, 1, 0, ..., 0, 0, 0]
ardeur = [0, 0, 0, 1, ..., 0, 0, 0]
...
zèle = [0, 0, 0, 0, ..., 0, 0, 1]L’ordre trompeur a disparu. Le vecteur d’un mot n’est jamais plus grand que celui d’un autre ; zèbre n’est plus « plus » qu’ananas. Dans la géométrie de l’espace, chaque mot possède désormais son propre axe, et chaque paire de mots se tient exactement à la même distance, comme les sommets d’une figure parfaitement symétrique.
Cette distance identique est aussi le nouveau problème. Ardeur est maintenant exactement aussi différent de zèle que de zèbre : la représentation ne contient aucune information de similarité, pour personne. Elle identifie les mots comme un numéro de casier identifie un étudiant, sans rien dire de lui.
Il y a aussi une objection pratique. Ces vecteurs sont énormes et leur contenu est presque entièrement fait de zéros : 100 000 nombres par mot, dont un seul est informatif.
La liste numérotée entassait tous les mots sur un seul axe et inventait des différences ; le vecteur 1 parmi n donne à chaque mot son propre axe et efface toute ressemblance. Ce qu’il faut se situe entre les deux : des vecteurs comptant un nombre modeste de dimensions, partagées par tous les mots, où les valeurs placent les mots de sens proches près les uns des autres.
C’est l’écran auquel le chapitre suivant répond. Ne pas nommer les plongements tout de suite si la séance 2 est juste dans le temps : la question suffit pour tenir jusqu’au lendemain.