5 of 42
ContentsPart I · Chapter 2

Chapter 2How does it work?

Predict, pick, repeat

It breaks your text into tokens, predicts a likely next token, adds it, and repeats. Training is what makes those predictions good.

  1. Predict, pick, repeat. For every possible next token the model scores how likely it is, picks one, adds it, and goes again. A temperature setting controls how adventurous the picks are.1
  2. Training in stages. First it reads a huge amount of text and practices predicting the next word (pretraining).2 Then it's coached with examples and with human (and AI) feedback to be a helpful assistant.34

Be the model

Illustration

A language model writes by repeatedly picking a likely next word, and a temperature setting controls how adventurous those picks are.

0 always picks the top word. Higher flattens the bars so unlikely words get picked more.

    Illustrative numbers, written for this page. Real models score every token in a vocabulary of tens of thousands or more (GPT-2's had 50,257), not six words.5

    Go deeper

    Attention. The transformer design lets every word "look at" every other word at once, so bank in "river bank" reads differently from bank in "bank account."6

    Thinking first. Newer models can work a problem through before answering, an idea rooted in research showing that writing out steps improves reasoning.78 Anthropic lets builders turn an effort setting up or down to trade speed for depth.9

    Facts

    • The transformer was introduced in "Attention Is All You Need" (June 2017).6
    • In 2022, people preferred answers from a 1.3-billion-parameter model trained with human feedback over the 175-billion-parameter GPT-3.3
    Notes (9)
    1. 1Ari Holtzman, Jan Buys, Li Du, Maxwell Forbes, and Yejin Choi, “The Curious Case of Neural Text Degeneration” (preprint, arXiv, April 22, 2019), https://doi.org/10.48550/arXiv.1904.09751.
    2. 2A. Radford et al., “Improving Language Understanding by Generative Pre-Training,” OpenAI, 2018, https://cdn.openai.com/research-covers/language-unsupervised/language_understanding_paper.pdf (accessed October 26, 2026).
    3. 3Long Ouyang, Jeff Wu, Xu Jiang, Diogo Almeida, Carroll L. Wainwright, Pamela Mishkin, Chong Zhang, et al., “Training language models to follow instructions with human feedback,” in Advances in Neural Information Processing Systems 35 (2022), 27730–27744, https://doi.org/10.52202/068431-2011.
    4. 4Yuntao Bai, Saurav Kadavath, Sandipan Kundu, Amanda Askell, Jackson Kernion, Andy Jones, Anna Chen, et al., “Constitutional AI: Harmlessness from AI Feedback” (preprint, arXiv, December 15, 2022), https://doi.org/10.48550/arXiv.2212.08073.
    5. 5Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever, Language Models are Unsupervised Multitask Learners (San Francisco: OpenAI, February 2019), https://cdn.openai.com/better-language-models/language_models_are_unsupervised_multitask_learners.pdf (accessed October 26, 2026). Cited at page 4.
    6. 6Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin, “Attention Is All You Need” (preprint, arXiv, June 12, 2017), https://doi.org/10.48550/arXiv.1706.03762.
    7. 7Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Brian Ichter, Fei Xia, Ed Chi, Quoc Le, and Denny Zhou, “Chain-of-Thought Prompting Elicits Reasoning in Large Language Models,” in Advances in Neural Information Processing Systems 35 (2022), 24824–24837, https://doi.org/10.52202/068431-1800.
    8. 8OpenAI, “Learning to reason with LLMs,” September 12, 2024, https://openai.com/index/learning-to-reason-with-llms/ (accessed October 26, 2026).
    9. 9Anthropic, “Choosing the right model,” Claude Platform Docs, https://platform.claude.com/docs/en/about-claude/models/choosing-a-model (accessed October 26, 2026).

    Chapter 2 · page 1 of 3

    Turn pages with the ← and → keys.

    Cite this page

    Using this book

    © 2026 Steve Sparks. All rights reserved. You're welcome to quote short passages and cite any page, with a link back. To reuse diagrams or larger parts, ask through GitHub.

    Quoted material and figures from other sources remain their owners'.