PrintedImprimé le·aylart.github.io/learn·
CC BY-NC 4.0
Written in English. The French version was automatically generated
and I have not revised it.
Rédigé en anglais. La version française a été
générée automatiquement et je ne l'ai pas révisée.
Fine-tuning: from generator to assistantL'affinage : du générateur à l'assistant
For InstructGPT, Ouyang et al. (2022) fine-tuned GPT-3 in two stages, first on
examples and then with a reward learned from rankings. People comparing outputs preferred those of a
1.3-billion-parameter model fine-tuned this way to those of the original GPT-3
at 175 billion, more than a hundred times larger. On the kind of requests
users sent to the model, a small amount of behaviour data counted for more than
a hundredfold difference in size.
Gekhman, Z., Yona, G., Aharoni, R., Eyal, M., Feder, A., Reichart, R., & Herzig, J. (2024). Does Fine-Tuning LLMs on New Knowledge Encourage Hallucinations?. Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing, 7765–7784. https://aclanthology.org/2024.emnlp-main.444/
Jurafsky, D., & Martin, J. H. (2026). Speech and Language Processing: An Introduction to Natural Language Processing, Computational Linguistics, and Speech Recognition with Language Models. Online draft, 3rd edition. https://web.stanford.edu/~jurafsky/slp3/
Zhou, C., Liu, P., Xu, P., Iyer, S., Sun, J., Mao, Y., et al. (2023). LIMA: Less Is More for Alignment. Advances in Neural Information Processing Systems 36 (NeurIPS 2023). https://openreview.net/forum?id=KBMOKmX2he
Pour InstructGPT, Ouyang et al. (2022) ont affiné GPT-3 en deux étapes,
d’abord sur des exemples, puis avec une récompense apprise à partir de
classements. Des personnes comparant les
sorties ont préféré celles d’un modèle de 1,3 milliard de paramètres affiné de
cette façon à celles du GPT-3 d’origine, à 175 milliards, plus de cent fois plus
gros. Sur le genre de requêtes que les utilisateurs
envoyaient au modèle, une petite quantité de données de comportement a pesé plus
lourd qu’un écart de taille d’un facteur cent.
Gekhman, Z., Yona, G., Aharoni, R., Eyal, M., Feder, A., Reichart, R., & Herzig, J. (2024). Does Fine-Tuning LLMs on New Knowledge Encourage Hallucinations?. Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing, 7765–7784. https://aclanthology.org/2024.emnlp-main.444/
Jurafsky, D., & Martin, J. H. (2026). Speech and Language Processing: An Introduction to Natural Language Processing, Computational Linguistics, and Speech Recognition with Language Models. Online draft, 3rd edition. https://web.stanford.edu/~jurafsky/slp3/
Zhou, C., Liu, P., Xu, P., Iyer, S., Sun, J., Mao, Y., et al. (2023). LIMA: Less Is More for Alignment. Advances in Neural Information Processing Systems 36 (NeurIPS 2023). https://openreview.net/forum?id=KBMOKmX2he
The four stages from pretraining to assistantLes quatre étapes du préentraînement à l'assistant
From pretraining to deployment
Figure 1. From pretraining to the assistant you type into.
Jurafsky, D., & Martin, J. H. (2026). Speech and Language Processing: An Introduction to Natural Language Processing, Computational Linguistics, and Speech Recognition with Language Models. Online draft, 3rd edition. https://web.stanford.edu/~jurafsky/slp3/
Jurafsky, D., & Martin, J. H. (2026). Speech and Language Processing: An Introduction to Natural Language Processing, Computational Linguistics, and Speech Recognition with Language Models. Online draft, 3rd edition. https://web.stanford.edu/~jurafsky/slp3/
Response: Photosynthesis is how plants make their own food using sunlight.
Think of leaves as tiny factories that take in sunlight, water and air…
Training on enough of these teaches a pattern that pretraining rarely presented
so consistently:
an instruction is followed by a response to it. Thus, the text completion system becomes a question answering system.
The term instruction tuning was introduced by Wei et al. (2022), who fine-tuned a pretrained model on
more than 60 datasets phrased as instructions and found that it could then follow
instructions for tasks it had not seen.
Small data, chosen carefully
Figure 3. Where the two kinds of training data come from, and what each is judged on.
Pretraining text was written by people too, but not for this purpose, and it is
filtered in bulk. Instruction-tuning examples are chosen or written for the
behaviour wanted. For InstructGPT, that meant about 13 000 prompts
with answers written by hired labellers (Ouyang et al., 2022). Later sets also
reuse questions and answers from community sites (Zhou et al., 2023) and
instructions and answers generated by a model, then filtered (Wang et al., 2023).
Quality counts for more than quantity here: a thousand carefully chosen examples
can be enough: doubling their number did not improve the answers, and filtering
them for quality did (Zhou et al., 2023). The authors take this as a sign that
the model learns a manner rather than a subject.
Where the examples are written for the purpose, the work is often paid: Ouyang et al.
(2022) recruited and screened about 40 labellers for it.
Not quite the helpful assistant chatbot yet
After this stage the model answers questions and can keep up a
conversation. Its finer judgement goes only as far as its examples showed it: how long an
answer should be, when to say it is unsure, when a request should be declined. Those
qualities are easy to recognize in a response and hard to specify in advance.
Sources
Jurafsky, D., & Martin, J. H. (2026). Speech and Language Processing: An Introduction to Natural Language Processing, Computational Linguistics, and Speech Recognition with Language Models. Online draft, 3rd edition. https://web.stanford.edu/~jurafsky/slp3/
Wang, Y., Kordi, Y., Mishra, S., Liu, A., Smith, N. A., Khashabi, D., & Hajishirzi, H. (2023). Self-Instruct: Aligning Language Models with Self-Generated Instructions. Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), 13484–13508. https://aclanthology.org/2023.acl-long.754/
Wei, J., Bosma, M., Zhao, V. Y., Guu, K., Yu, A. W., Lester, B., Du, N., Dai, A. M., & Le, Q. V. (2022). Finetuned Language Models Are Zero-Shot Learners. International Conference on Learning Representations (ICLR 2022). https://openreview.net/forum?id=gEZrGCozdqR
Zhou, C., Liu, P., Xu, P., Iyer, S., Sun, J., Mao, Y., et al. (2023). LIMA: Less Is More for Alignment. Advances in Neural Information Processing Systems 36 (NeurIPS 2023). https://openreview.net/forum?id=KBMOKmX2he
Montrer au modèle à quoi ressemble une bonne réponse
Requête : Explique la photosynthèse à un enfant de 10 ans.
Réponse : La photosynthèse, c’est la façon dont les plantes fabriquent
leur propre nourriture avec la lumière du soleil. Imagine les feuilles comme
de petites usines qui captent la lumière, l’eau et l’air…
S’entraîner sur assez de ces paires enseigne une régularité que le
préentraînement présentait rarement de façon aussi constante : une instruction est suivie d’une réponse.
Le système qui complète du texte devient ainsi un système qui répond aux questions.
Le terme anglais instruction tuning a été introduit par Wei et al. (2022), qui ont affiné un modèle préentraîné sur
plus de 60 jeux de données formulés comme des instructions et constaté qu’il pouvait
ensuite suivre des instructions pour des tâches qu’il n’avait pas vues.
Peu de données, choisies avec soin
Figure 3. D'où viennent les deux sortes de données d'entraînement, et sur quoi chacune est jugée.
Le texte du préentraînement a lui aussi été écrit par des personnes, mais pas
dans ce but, et il est filtré en bloc. Les exemples de l’affinage par
instructions sont choisis ou rédigés selon le comportement recherché. Pour
InstructGPT, il s’agissait d’environ 13 000 requêtes accompagnées de
réponses rédigées par des étiqueteurs recrutés à cette fin (Ouyang et al.,
2022). Les ensembles plus récents reprennent aussi des questions et des réponses
de sites communautaires (Zhou et al., 2023) et des instructions et des réponses
générées par un modèle, puis filtrées (Wang et al., 2023).
Ici, la qualité compte plus que la quantité : un millier d’exemples
soigneusement choisis peut suffire. En doubler le nombre n’a pas amélioré les
réponses, alors que les filtrer selon leur qualité les a améliorées (Zhou et al., 2023). Les
auteurs y voient le signe que le modèle apprend une manière plutôt qu’un sujet.
Là où les exemples sont rédigés exprès, le travail est souvent rémunéré : Ouyang et
coll. (2022) ont recruté et sélectionné une quarantaine d’étiqueteurs pour cette
tâche.
Pas encore tout à fait l’agent conversationnel serviable
Après cette étape, le modèle répond aux questions et peut soutenir une
conversation. Son jugement plus fin ne va pas plus loin que ce que ses exemples lui ont
montré : quelle longueur donner à une réponse, quand dire qu’il n’est pas sûr, quand une demande devrait être
refusée. Ces qualités sont faciles à reconnaître dans une réponse et difficiles
à préciser d’avance.
Sources
Jurafsky, D., & Martin, J. H. (2026). Speech and Language Processing: An Introduction to Natural Language Processing, Computational Linguistics, and Speech Recognition with Language Models. Online draft, 3rd edition. https://web.stanford.edu/~jurafsky/slp3/
Wang, Y., Kordi, Y., Mishra, S., Liu, A., Smith, N. A., Khashabi, D., & Hajishirzi, H. (2023). Self-Instruct: Aligning Language Models with Self-Generated Instructions. Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), 13484–13508. https://aclanthology.org/2023.acl-long.754/
Wei, J., Bosma, M., Zhao, V. Y., Guu, K., Yu, A. W., Lester, B., Du, N., Dai, A. M., & Le, Q. V. (2022). Finetuned Language Models Are Zero-Shot Learners. International Conference on Learning Representations (ICLR 2022). https://openreview.net/forum?id=gEZrGCozdqR
Zhou, C., Liu, P., Xu, P., Iyer, S., Sun, J., Mao, Y., et al. (2023). LIMA: Less Is More for Alignment. Advances in Neural Information Processing Systems 36 (NeurIPS 2023). https://openreview.net/forum?id=KBMOKmX2he
Preference tuning: learning from rankingsLe réglage des préférences : apprendre à partir de classements
Ranking instead of writing
Some things about a good answer are easy to judge and hard to state. Asked
whether this response or that one is better, an annotator can answer quickly;
asked to write down the rule they applied, they would find it far harder.
Preference tuning uses that asymmetry. Rather than asking people to produce
the ideal answer, it asks them to put several of the model’s own answers in
order. The rankings are not perfectly consistent: the labellers of Ouyang et al.
(2022) agreed with each other on about 73% of comparisons. Each ranking is then
split into pairs: four answers in order give six pairs, each made of a better and
a worse answer.
Figure 4. It is often much easier to put concrete options in order, from best to worst, than to write the best possible answer yourself.
The two best-known methods are reinforcement learning from human feedback (RLHF)
and direct preference optimization (DPO) (Jurafsky & Martin, 2026).
Figure 5. ChatGPT asking whether a response was better or worse (screenshot, 10 September 2026). Figure 6. Gemini showing two answers to one request and asking which is more helpful (screenshot, 1 October 2026).
RLHF: a reward model stands in for the people
Figure 7. Post-training an LLM: instruction tuning, then RLHF.
The comparisons do not have to come from people: in a method its authors call
Constitutional AI, a model compares answers for harmfulness against a written list of principles,
and those comparisons, with human ones for helpfulness, train the reward model
(Bai et al., 2022a).
Figure 8. The same ranked pairs, used in two ways.
Sources
Bai, Y., Kadavath, S., Kundu, S., Askell, A., Kernion, J., Jones, A., et al. (2022a). Constitutional AI: Harmlessness from AI Feedback. arXiv:2212.08073 (preprint). https://arxiv.org/abs/2212.08073
Jurafsky, D., & Martin, J. H. (2026). Speech and Language Processing: An Introduction to Natural Language Processing, Computational Linguistics, and Speech Recognition with Language Models. Online draft, 3rd edition. https://web.stanford.edu/~jurafsky/slp3/
Certaines choses, dans une bonne réponse, sont faciles à juger et difficiles à
énoncer. Si on lui demande si cette réponse-ci ou celle-là est meilleure, un
annotateur peut répondre vite ; si on lui demande d’écrire la règle qu’il a
appliquée, la tâche est bien plus difficile.
Le réglage des préférences exploite cette asymétrie. Plutôt que de demander aux
gens de produire la réponse idéale, il leur demande de mettre en ordre plusieurs
des réponses du modèle lui-même. Les classements ne sont pas parfaitement
cohérents : les étiqueteurs d’Ouyang et al. (2022) concordaient sur environ
73 % des comparaisons. Chaque classement est ensuite découpé en paires : quatre
réponses classées donnent six paires, chacune formée d’une meilleure et d’une
moins bonne réponse.
Figure 4. Il est souvent bien plus facile de classer des options concrètes, de la meilleure à la pire, que de rédiger soi-même la meilleure réponse possible.
Les deux méthodes les plus connues sont l’apprentissage par renforcement avec
rétroaction humaine (ARRH) et l’optimisation directe des préférences (DPO)
(Jurafsky et Martin, 2026).
Figure 5. ChatGPT demande si une réponse était meilleure ou moins bonne (capture d'écran, 10 septembre 2026). Figure 6. Gemini affiche deux réponses à une même requête et demande laquelle est la plus utile (capture d'écran, 1er octobre 2026).
L’ARRH : un modèle de récompense remplace les personnes
Figure 7. Le postentraînement d'un GML : l'affinage par instructions, puis l'ARRH.
Les comparaisons ne viennent pas forcément de personnes : dans une méthode que
ses auteurs appellent l’IA constitutionnelle, un modèle compare des réponses
sur leur caractère nuisible d’après une liste écrite de principes, et ces
comparaisons, avec des comparaisons humaines pour l’utilité, entraînent le
modèle de récompense (Bai et al., 2022a).
Figure 8. Les mêmes paires classées, utilisées de deux façons.
Sources
Bai, Y., Kadavath, S., Kundu, S., Askell, A., Kernion, J., Jones, A., et al. (2022a). Constitutional AI: Harmlessness from AI Feedback. arXiv:2212.08073 (preprint). https://arxiv.org/abs/2212.08073
Jurafsky, D., & Martin, J. H. (2026). Speech and Language Processing: An Introduction to Natural Language Processing, Computational Linguistics, and Speech Recognition with Language Models. Online draft, 3rd edition. https://web.stanford.edu/~jurafsky/slp3/
Reinforcement learning: AlphaGo and move 37L'apprentissage par renforcement : AlphaGo et le coup 37
Go as a challenge for AI
Games have long been test cases for AI, chess being the best
known (see also the What counts as AI? page, in the Foundations of AI & NLP module) (voir aussi la page Ce qu'on appelle « IA », dans le module Fondements de l'IA et du TAL), and Go had long
been seen as the most challenging of the classic games (Silver et al., 2016). It
offers far more possible moves at each turn than chess, about 250 against about
35, and its games run longer (Silver et al., 2016). No program can work through
every possible continuation of a game of Go and pick the best one: it cannot
brute-force its way to a good move.
Between 2015 and 2017, Google DeepMind nonetheless built systems that played Go
well, and tested them in well-publicized matches against human champions.
Figure 9. Headlines from January to March 2016, from the announcement of the Fan Hui result to the end of the Lee Sedol match (Knight, 2016; Akpan, 2016; Reuters, 2016; Russell, 2016).
Learning from humans, then from itself
AlphaGo, the Go program, was trained in two stages much like a language model’s.
It began by learning from about 30 million positions from games between strong
amateur players on an online Go server, predicting the move such a player would
make (Silver et al., 2016). Imitation tends to cap a program near the level of the players it copies
(Silver et al., 2017).
In March 2016 AlphaGo played Lee Sedol, one of the strongest players in the
world, and won four games of five (Metz, 2016).
Figure 10. The position after move 37 of the second game, 10 March 2016. AlphaGo, playing black, has just played at P10. It is the first move that is four steps away from the border.
Of the match’s two commentators, one called it a very strange move and the other
thought it was a mistake. It proved central to winning the game, and AlphaGo won
the match about a decade before experts had expected such a win (Metz, 2016).
Learning from the rules alone
A later system, AlphaZero, was given no human games at all. It started from
the rules of the game and its own play, and it ended up stronger still
(Silver et al., 2018).
Silver, D., Huang, A., Maddison, C. J., Guez, A., Sifre, L., van den Driessche, G., et al. (2016). Mastering the game of Go with deep neural networks and tree search. Nature, 529(7587), 484–489. https://doi.org/10.1038/nature16961
Silver, D., Hubert, T., Schrittwieser, J., Antonoglou, I., Lai, M., Guez, A., et al. (2018). A general reinforcement learning algorithm that masters chess, shogi, and Go through self-play. Science, 362(6419), 1140-1144. https://doi.org/10.1126/science.aar6404
Silver, D., Schrittwieser, J., Simonyan, K., Antonoglou, I., Huang, A., Guez, A., et al. (2017). Mastering the game of Go without human knowledge. Nature, 550(7676), 354–359. https://doi.org/10.1038/nature24270
Le go, un défi pour l’IA
Les jeux, dont les échecs sont l’exemple le plus connu, servent depuis longtemps
de terrain d’essai à l’IA (see also the What counts as AI? page, in the Foundations of AI & NLP module) (voir aussi la page Ce qu'on appelle « IA », dans le module Fondements de l'IA et du TAL),
et le go était vu depuis longtemps comme le plus difficile des jeux classiques
(Silver et al., 2016). Il offre bien plus de coups possibles à chaque tour que
les échecs, environ 250 contre environ 35, et ses parties sont plus longues
(Silver et al., 2016). Aucun programme ne peut examiner toutes les suites
possibles d’une partie de go pour choisir la meilleure : il ne peut pas trouver
un bon coup par la force brute.
Entre 2015 et 2017, Google DeepMind a néanmoins construit des systèmes qui
jouaient bien au go, et les a mis à l’épreuve lors de matchs très médiatisés
contre des champions humains.
Figure 9. Des titres de presse de janvier à mars 2016, de l'annonce du résultat contre Fan Hui à la fin du match contre Lee Sedol, reproduits en anglais (Knight, 2016 ; Akpan, 2016 ; Reuters, 2016 ; Russell, 2016).
Apprendre des humains, puis de soi-même
AlphaGo, le programme de go, a été entraîné en deux étapes, tout comme un modèle de langue.
Il a commencé par apprendre à partir d’environ 30 millions de positions tirées
de parties entre de forts joueurs amateurs sur un serveur de go en ligne, en
prédisant le coup qu’un tel joueur jouerait (Silver et al., 2016). L’imitation tend à plafonner un programme près du niveau des joueurs qu’il copie
(Silver et al., 2017).
En mars 2016, AlphaGo a affronté Lee Sedol, l’un des plus forts joueurs du
monde, et a gagné quatre parties sur cinq (Metz, 2016).
Figure 10. La position après le coup 37 de la deuxième partie, 10 mars 2016. AlphaGo, qui joue les noirs, vient de jouer en P10. C'est le premier coup joué à quatre intersections du bord.
Des deux commentateurs du match, l’un a trouvé le coup très étrange et l’autre
l’a pris pour une erreur. Le coup s’est révélé décisif pour gagner la partie, et
AlphaGo a remporté le match une dizaine d’années avant ce qu’attendaient les
experts (Metz, 2016).
Apprendre à partir des seules règles
Un système ultérieur, AlphaZero, n’a reçu aucune partie humaine. Il est parti
des règles du jeu et de son propre jeu, et il a fini plus fort encore (Silver et
coll., 2018).
Silver, D., Huang, A., Maddison, C. J., Guez, A., Sifre, L., van den Driessche, G., et al. (2016). Mastering the game of Go with deep neural networks and tree search. Nature, 529(7587), 484–489. https://doi.org/10.1038/nature16961
Silver, D., Hubert, T., Schrittwieser, J., Antonoglou, I., Lai, M., Guez, A., et al. (2018). A general reinforcement learning algorithm that masters chess, shogi, and Go through self-play. Science, 362(6419), 1140-1144. https://doi.org/10.1126/science.aar6404
Silver, D., Schrittwieser, J., Simonyan, K., Antonoglou, I., Huang, A., Guez, A., et al. (2017). Mastering the game of Go without human knowledge. Nature, 550(7676), 354–359. https://doi.org/10.1038/nature24270
RLVR: learning from answers that can be checkedL'ARV : apprendre à partir de réponses vérifiables
Figure 11. The two pipelines line up stage for stage and part company at what is being optimized.
At the end of every game of Go, the rules say who won. That result is exact, it
costs nothing to check, and a program can play millions of games against itself
to collect more of it.
This is a crucial difference. Having a result you can check automatically
means you can keep optimizing without people, and each check costs almost
nothing. Whereas
being reliant on subjective references that require human involvement to create
is a considerable limitation in terms of how much you can optimize and what you
should consider good performance (see also the Evaluating language technology module) (voir aussi le module L'évaluation des technologies langagières).
Figure 12. The kinds of fine-tuning this chapter names, and which of them make up post-training.
Sources
Guo, D., Yang, D., Zhang, H., Song, J., Zhang, R., Xu, R., et al. (2025). DeepSeek-R1 incentivizes reasoning in LLMs through reinforcement learning. Nature, 645(8081), 633–638. https://doi.org/10.1038/s41586-025-09422-z
Jurafsky, D., & Martin, J. H. (2026). Speech and Language Processing: An Introduction to Natural Language Processing, Computational Linguistics, and Speech Recognition with Language Models. Online draft, 3rd edition. https://web.stanford.edu/~jurafsky/slp3/
Lambert, N., Morrison, J., Pyatkin, V., Huang, S., Ivison, H., Brahman, F., et al. (2025). Tulu 3: Pushing Frontiers in Open Language Model Post-Training. Conference on Language Modeling (COLM 2025). https://openreview.net/forum?id=i1uGbfHHpH
Figure 11. Les deux chaînes se correspondent étape pour étape et se séparent sur ce qu'elles optimisent.
À la fin de chaque partie de go, les règles disent qui a gagné. Ce résultat est
exact, il ne coûte rien à vérifier, et un programme peut jouer des millions de
parties contre lui-même pour en recueillir davantage.
C’est une différence cruciale. Disposer d’un résultat vérifiable automatiquement
permet de continuer à optimiser sans intervention humaine, et chaque
vérification ne coûte presque rien. Dépendre de références subjectives, dont la création exige une intervention
humaine, limite au contraire considérablement ce qu’on peut optimiser et ce
qu’on doit considérer comme une bonne performance (see also the Evaluating language technology module) (voir aussi le module L'évaluation des technologies langagières).
Figure 12. Les sortes d'affinage que nomme ce chapitre, et celles qui forment le postentraînement.
Sources
Guo, D., Yang, D., Zhang, H., Song, J., Zhang, R., Xu, R., et al. (2025). DeepSeek-R1 incentivizes reasoning in LLMs through reinforcement learning. Nature, 645(8081), 633–638. https://doi.org/10.1038/s41586-025-09422-z
Jurafsky, D., & Martin, J. H. (2026). Speech and Language Processing: An Introduction to Natural Language Processing, Computational Linguistics, and Speech Recognition with Language Models. Online draft, 3rd edition. https://web.stanford.edu/~jurafsky/slp3/
Lambert, N., Morrison, J., Pyatkin, V., Huang, S., Ivison, H., Brahman, F., et al. (2025). Tulu 3: Pushing Frontiers in Open Language Model Post-Training. Conference on Language Modeling (COLM 2025). https://openreview.net/forum?id=i1uGbfHHpH