{"course":{"slug":"ai-actually-explained","title":"AI, Actually Explained","url":"https://addaly.com/learn/ai-actually-explained","level":"beginner","track":"start"},"lesson":{"slug":"the-next-word-game","title":"One chunk at a time, and it cannot take it back","url":"https://addaly.com/learn/ai-actually-explained/the-next-word-game","position":22,"of":92,"minutes":9,"answer":"An autoregressive decoder conditions later output on the available prefix, often using cached calculations. An emitted error can influence later text; correcting the context and independently checking the result are useful responses.","keyIdea":"An autoregressive decoder conditions later output on the available prefix, often using cached calculations. An emitted error can influence later text; correcting the context and independently checking the result are useful responses."},"body":{"format":"markdown","text":"## The whole loop\n\nHere is a simplified five-step description of autoregressive text generation. It describes the output loop, not every architecture, cache, tool or verification step around it.\n\n1. Prepare the available input tokens: instructions, the selected conversation and any other supplied material.\n2. Compute next-token scores over the model’s vocabulary, using the current prefix.\n3. A decoding procedure selects a token, either greedily or by another strategy such as sampling.\n4. Append the selected token to the sequence.\n5. Continue until a stopping condition is reached, usually reusing cached calculations where supported.\n\nFor a toy illustration, a model might assign a high next-token probability to ` Paris` after “The capital of France is”. Those hypothetical scores describe a continuation, not confidence in a fact. After the token is appended, the next prediction depends on the extended prefix.\n\n**Autoregressive** means generating later output conditioned on the preceding sequence. Several useful consequences follow, with important qualifications.\n\n## The prefix matters, and calculations can be cached\n\nA standard decoder’s next prediction depends on its available prefix, but it need not recalculate that prefix from scratch for every new token. A key-value cache retains earlier attention calculations during generation. This is computational state, not a new training update or a verified store of facts.\n\nHugging Face’s cache documentation describes this reuse explicitly. Caching changes computation and memory use. API input accounting and cached-input discounts are separate provider-specific rules, so the loop is not a literal description of every bill.\n\nA longer selected context can require more resources, but an application may summarise, retrieve, truncate or cache parts of a conversation. Products can also store memories outside the model and include them later. The model’s weights, its current computational cache and the product’s saved records are three different things.\n\n## Generating a sequence is not a guarantee of a plan\n\nThe next token is chosen from the current computation, rather than by selecting a complete finished answer in this simple loop. That does not mean the model cannot represent a plan, generate an outline or use a tool that checks a proposed solution.\n\nEarly wording can guide later wording. After “There are three reasons. First,” a second and third item are natural continuations. A model can also be asked to produce an outline first. Neither an implied structure nor an explicit outline guarantees that the final response follows it.\n\nExact counts and endings can still fail: a list may contain the wrong number of items or a poem may miss its intended ending. Check these constraints explicitly. Such a failure does not prove that no counting or planning took place.\n\n## The most useful idea in this lesson: it commits\n\nOnce a token has been emitted in a streaming pass, a later token cannot erase those already displayed bytes. The model can correct itself later, and an application can generate drafts or replace a response, but that is different from changing the earlier stream.\n\nA wrong number in the prefix can influence what follows, including a fluent explanation built around the mistake. The model may instead correct it. You cannot diagnose stubbornness, dishonesty or a particular internal cause from the continuation alone; verify the calculation.\n\nThree practical moves can help, depending on the task:\n\n- **Remove or clearly correct a misleading prefix.** Editing and regenerating can remove an earlier error where the interface supports it. A fresh, explicit correction can also work; verify the new result.\n- **Ask for checkable working when useful.** Intermediate steps can improve some tasks, but a plausible explanation can still be wrong or unfaithful. Use a calculator, source or independent check where accuracy matters.\n- **Compare options against criteria.** Ask what would change the recommendation and which assumptions it depends on, rather than treating its first recommendation as settled.\n\n## Why \"thinking\" helps at all\n\nGenerating intermediate tokens can provide additional computation before a final answer. It is one way to spend more effort, not the only one: systems can use tools, search, repeated attempts or verifiers. The amount of work per token and per request also depends on the architecture and serving system.\n\nThe 2022 chain-of-thought prompting paper reported improvements on tested arithmetic, commonsense and symbolic-reasoning tasks using worked examples. That is an empirical result for particular models and prompts, not proof that asking every model to “think step by step” always helps, or that its written working faithfully exposes its internal process.\n\nSystems described as reasoning models often allocate additional work before answering. Their methods, latency, prices and strengths vary. Judge a specific version on the task you need, and check the final answer rather than assuming that longer working means a better result."},"check":{"question":"A model gives a wrong total, then produces a detailed justification of it after a correction. Which explanation describes a relevant risk, without pretending to diagnose every internal cause?","options":[{"text":"The model is optimised to defend its answers, because users rated confident responses more highly.","correct":false,"tempting":"Preference optimisation can affect behaviour, but this example does not identify it as the cause of the repeated wrong total. The earlier text and the calculation still need checking."},{"text":"The model has cached the earlier calculation and is retrieving it rather than recomputing.","correct":false,"tempting":"A computational cache reuses intermediate calculations; its presence does not establish that a verified arithmetic result was stored and retrieved."},{"text":"The earlier wrong total remains in the context and can influence later output, so an explanation may be consistent with the mistake. The calculation still needs checking.","correct":true},{"text":"The user's correction was too polite, and a firmer instruction would trigger a recalculation.","correct":false,"tempting":"A clearer correction can help, but firmness is not a special switch that guarantees recalculation."}]},"prev":{"slug":"words-into-tokens","title":"Text is chopped up before the model sees it","url":"https://addaly.com/learn/ai-actually-explained/words-into-tokens"},"next":{"slug":"attention-what-it-does","title":"Attention, without a single equation","url":"https://addaly.com/learn/ai-actually-explained/attention-what-it-does"},"authorship":"Founder and series editor: Dr Mustafa Mun. Written by AI models to a written standard. Source and assessment review continues. Academic review invited.","review":{"status":"Draft, open for academic review"},"cite":"Addaly (2026) 'One chunk at a time, and it cannot take it back', in AI, Actually Explained. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/ai-actually-explained/the-next-word-game (Accessed: 29 November 2026).","licence":{"name":"CC BY-NC-SA 4.0","url":"https://creativecommons.org/licenses/by-nc-sa/4.0/"},"reader":{"schema":1,"title":"One chunk at a time, and it cannot take it back","courseTitle":"AI, Actually Explained","module":{"index":3,"slug":"how-a-chatbot-works","title":"What a chatbot is actually doing"},"answer":null,"keyIdea":"An autoregressive decoder conditions later output on the available prefix, often using cached calculations. An emitted error can influence later text; correcting the context and independently checking the result are useful responses.","hero":{"kind":"plate","image":null,"alt":null,"caption":null},"blocks":[{"t":"h2","id":"the-whole-loop","runs":[{"text":"The whole loop"}]},{"t":"p","runs":[{"text":"Here is a simplified five-step description of autoregressive text generation. It describes the output loop, not every architecture, cache, tool or verification step around it."}]},{"t":"ol","start":1,"items":[[{"text":"Prepare the available input tokens: instructions, the selected conversation and any other supplied material."}],[{"text":"Compute next-token scores over the model’s vocabulary, using the current prefix."}],[{"text":"A decoding procedure selects a token, either greedily or by another strategy such as sampling."}],[{"text":"Append the selected token to the sequence."}],[{"text":"Continue until a stopping condition is reached, usually reusing cached calculations where supported."}]]},{"t":"p","runs":[{"text":"For a toy illustration, a model might assign a high next-token probability to "},{"text":" Paris","code":true},{"text":" after “The capital of France is”. Those hypothetical scores describe a continuation, not confidence in a fact. After the token is appended, the next prediction depends on the extended prefix."}]},{"t":"p","runs":[{"text":"Autoregressive","b":true},{"text":" means generating later output conditioned on the preceding sequence. Several useful consequences follow, with important qualifications."}]},{"t":"h2","id":"the-prefix-matters-and-calculations-can-be-cached","runs":[{"text":"The prefix matters, and calculations can be cached"}]},{"t":"p","runs":[{"text":"A standard decoder’s next prediction depends on its available prefix, but it need not recalculate that prefix from scratch for every new token. A key-value cache retains earlier attention calculations during generation. This is computational state, not a new training update or a verified store of facts."}]},{"t":"p","runs":[{"text":"Hugging Face’s cache documentation describes this reuse explicitly. Caching changes computation and memory use. API input accounting and cached-input discounts are separate provider-specific rules, so the loop is not a literal description of every bill."}]},{"t":"p","runs":[{"text":"A longer selected context can require more resources, but an application may summarise, retrieve, truncate or cache parts of a conversation. Products can also store memories outside the model and include them later. The model’s weights, its current computational cache and the product’s saved records are three different things."}]},{"t":"h2","id":"generating-a-sequence-is-not-a-guarantee-of-a-plan","runs":[{"text":"Generating a sequence is not a guarantee of a plan"}]},{"t":"p","runs":[{"text":"The next token is chosen from the current computation, rather than by selecting a complete finished answer in this simple loop. That does not mean the model cannot represent a plan, generate an outline or use a tool that checks a proposed solution."}]},{"t":"p","runs":[{"text":"Early wording can guide later wording. After “There are three reasons. First,” a second and third item are natural continuations. A model can also be asked to produce an outline first. Neither an implied structure nor an explicit outline guarantees that the final response follows it."}]},{"t":"p","runs":[{"text":"Exact counts and endings can still fail: a list may contain the wrong number of items or a poem may miss its intended ending. Check these constraints explicitly. Such a failure does not prove that no counting or planning took place."}]},{"t":"h2","id":"the-most-useful-idea-in-this-lesson-it-commits","runs":[{"text":"The most useful idea in this lesson: it commits"}]},{"t":"p","runs":[{"text":"Once a token has been emitted in a streaming pass, a later token cannot erase those already displayed bytes. The model can correct itself later, and an application can generate drafts or replace a response, but that is different from changing the earlier stream."}]},{"t":"p","runs":[{"text":"A wrong number in the prefix can influence what follows, including a fluent explanation built around the mistake. The model may instead correct it. You cannot diagnose stubbornness, dishonesty or a particular internal cause from the continuation alone; verify the calculation."}]},{"t":"p","runs":[{"text":"Three practical moves can help, depending on the task:"}]},{"t":"ul","items":[[{"text":"Remove or clearly correct a misleading prefix.","b":true},{"text":" Editing and regenerating can remove an earlier error where the interface supports it. A fresh, explicit correction can also work; verify the new result."}],[{"text":"Ask for checkable working when useful.","b":true},{"text":" Intermediate steps can improve some tasks, but a plausible explanation can still be wrong or unfaithful. Use a calculator, source or independent check where accuracy matters."}],[{"text":"Compare options against criteria.","b":true},{"text":" Ask what would change the recommendation and which assumptions it depends on, rather than treating its first recommendation as settled."}]]},{"t":"h2","id":"why-thinking-helps-at-all","runs":[{"text":"Why “thinking” helps at all"}]},{"t":"p","runs":[{"text":"Generating intermediate tokens can provide additional computation before a final answer. It is one way to spend more effort, not the only one: systems can use tools, search, repeated attempts or verifiers. The amount of work per token and per request also depends on the architecture and serving system."}]},{"t":"p","runs":[{"text":"The 2022 chain-of-thought prompting paper reported improvements on tested arithmetic, commonsense and symbolic-reasoning tasks using worked examples. That is an empirical result for particular models and prompts, not proof that asking every model to “think step by step” always helps, or that its written working faithfully exposes its internal process."}]},{"t":"p","runs":[{"text":"Systems described as reasoning models often allocate additional work before answering. Their methods, latency, prices and strengths vary. Judge a specific version on the task you need, and check the final answer rather than assuming that longer working means a better result."}]}],"check":{"question":[{"text":"A model gives a wrong total, then produces a detailed justification of it after a correction. Which explanation describes a relevant risk, without pretending to diagnose every internal cause?"}],"options":[{"text":[{"text":"The model is optimised to defend its answers, because users rated confident responses more highly."}],"correct":false,"tempting":[{"text":"Preference optimisation can affect behaviour, but this example does not identify it as the cause of the repeated wrong total. The earlier text and the calculation still need checking."}]},{"text":[{"text":"The model has cached the earlier calculation and is retrieving it rather than recomputing."}],"correct":false,"tempting":[{"text":"A computational cache reuses intermediate calculations; its presence does not establish that a verified arithmetic result was stored and retrieved."}]},{"text":[{"text":"The earlier wrong total remains in the context and can influence later output, so an explanation may be consistent with the mistake. The calculation still needs checking."}],"correct":true,"tempting":null},{"text":[{"text":"The user’s correction was too polite, and a firmer instruction would trigger a recalculation."}],"correct":false,"tempting":[{"text":"A clearer correction can help, but firmness is not a special switch that guarantees recalculation."}]}],"order":[3,2,1,0],"why":null},"prev":{"slug":"words-into-tokens","title":"Text is chopped up before the model sees it","minutes":9},"next":{"slug":"attention-what-it-does","title":"Attention, without a single equation","minutes":9}}}