Reading in both directionsLire dans les deux sens
TRA6008 S2 · in classS2 · en classe
Before or after
Where does the word that settles the ambiguity sit? Sometimes before the ambiguous word: in fishing from the bank is prohibited, fishing has settled the sense by the time bank arrives. Sometimes after it: in the bank issued new regulations, the deciding word only comes once bank has been read.
Reading both ways
ELMo already used both sides, but shallowly: one model read the sentence left to right, a second read it right to left, and their outputs were joined at the end, so the two directions were never combined during training (Devlin et al., 2019).
BERT is the model that put the two together.ELMo and BERT set a fashion, and the acronyms that followed were bent to land on Sesame Street characters: ERNIE, Grover, Big Bird.
Training a language model normally means predicting the next word, and that forces a single direction: a model allowed to see what follows would simply be handed the answer. BERT changes the exercise. It hides about 15 per cent of the tokens token²jeton textuel² language modelsmodèles de langue A unit of text that a language model processes or generates.Unité de texte qu'un modèle de langue traite ou génère. Un jeton peut correspondre à un mot entier, à une partie de mot, à un signe de ponctuation ou à une séquence plus petite de caractères ou d'octets. in a text and trains the model to restore each one from everything around it, on both sides (Devlin et al., 2019). Nothing is being generated here, so nothing is spoiled by reading ahead.
Every layer of the model therefore draws on both sides at once. The architecture underneath makes that possible (see also the Attention & transformers chapter) (voir aussi le chapitre Attention et transformeurs).
BERT reported new best results on eleven language-processing tasks, and this methodology became the standard: pretrain one model on raw text, then fine-tune it for each task. For translation, where the whole source text is there before any output is produced, reading it in both directions is the natural design.
What it costs
Two things.
- Computation. A fresh vector per occurrence, from the whole sentence, costs far more than looking up a stored one, so these models need serious hardware.
- Inspection. A static embedding table could at least be examined word by word. Contextual representations exist only inside a running model, one more step away from anything a person can read (see also the From neural networks to large language models chapter, in the Foundations of AI & NLP module) (voir aussi le chapitre Des réseaux de neurones aux grands modèles de langue, dans le module Fondements de l'IA et du TAL).
The field judged the accuracy worth both.
Avant ou après
Où se trouve le mot qui lève l’ambiguïté ? Parfois avant le mot ambigu : dans fishing from the bank is prohibited, fishing a déjà fixé le sens quand bank arrive. Parfois après lui : dans the bank issued new regulations, le mot décisif ne vient qu’une fois bank lu.
Lire dans les deux sens
ELMo utilisait déjà les deux côtés, mais superficiellement : un modèle lisait la phrase de gauche à droite, un second la lisait de droite à gauche, et leurs sorties étaient réunies à la fin, si bien que les deux sens ne se rencontraient jamais pendant l’entraînement (Devlin et al., 2019).
BERT est le modèle qui a réuni les deux.ELMo et BERT ont lancé une mode, et les acronymes qui ont suivi ont été tordus pour tomber sur des personnages de Sesame Street : ERNIE, Grover, Big Bird.
Entraîner un modèle de langue veut normalement dire prédire le mot suivant, et cela impose un sens unique : un modèle autorisé à voir ce qui suit se verrait simplement donner la réponse. BERT change l’exercice. Il masque environ 15 % des jetons token²jeton textuel² language modelsmodèles de langue A unit of text that a language model processes or generates.Unité de texte qu'un modèle de langue traite ou génère. Un jeton peut correspondre à un mot entier, à une partie de mot, à un signe de ponctuation ou à une séquence plus petite de caractères ou d'octets. d’un texte et entraîne le modèle à rétablir chacun d’eux à partir de tout ce qui l’entoure, des deux côtés (Devlin et al., 2019). Rien n’est produit ici, donc rien n’est gâché si le modèle lit plus loin.
Chaque couche du modèle puise donc des deux côtés à la fois. L’architecture sous-jacente rend cela possible (see also the Attention & transformers chapter) (voir aussi le chapitre Attention et transformeurs).
BERT a établi de nouveaux records sur onze tâches de traitement de la langue, et cette méthodologie est devenue la norme : préentraîner un modèle sur du texte brut, puis l’affiner pour chaque tâche. En traduction, où tout le texte de départ est là avant qu’aucune sortie ne soit produite, le lire dans les deux sens est la conception naturelle.
Ce que cela coûte
Deux choses.
- Le calcul. Un vecteur neuf par occurrence, à partir de toute la phrase, coûte bien plus cher que d’en consulter un déjà rangé : ces modèles exigent donc du matériel sérieux.
- L’inspection. Une table de plongements statiques pouvait au moins s’examiner mot à mot. Les représentations contextuelles n’existent qu’à l’intérieur d’un modèle en train de tourner, un cran plus loin encore de ce qu’une personne peut lire (see also the From neural networks to large language models chapter, in the Foundations of AI & NLP module) (voir aussi le chapitre Des réseaux de neurones aux grands modèles de langue, dans le module Fondements de l'IA et du TAL).
Le domaine a jugé que la précision valait les deux.
Sources
- Devlin, J., Chang, M.-W., Lee, K., & Toutanova, K. (2019). BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers). https://doi.org/10.18653/v1/N19-1423
- Peters, M. E., Neumann, M., Iyyer, M., Gardner, M., Clark, C., Lee, K., et al. (2018). Deep Contextualized Word Representations. Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers). https://doi.org/10.18653/v1/N18-1202
Sources
- Devlin, J., Chang, M.-W., Lee, K., & Toutanova, K. (2019). BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers). https://doi.org/10.18653/v1/N19-1423
- Peters, M. E., Neumann, M., Iyyer, M., Gardner, M., Clark, C., Lee, K., et al. (2018). Deep Contextualized Word Representations. Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers). https://doi.org/10.18653/v1/N18-1202