HomeScienceField NotesAI CourseVideosAboutJoin the course
Email · LinkedIn · X
AI & Technology

How a Language Model Writes a Sentence (and Why It Sometimes Makes Things Up)

Behind the fluent answers is one simple loop: predict the next word, add it, repeat. Understanding that loop makes you a much better user.

PROMPTThe cat sat on the?NEXT-WORD PROBABILITIES (ILLUSTRATIVE)mat46%floor21%sofa14%bed9%roof6%moon1%pick one,add it, repeat
Figure 1. Next-word prediction. The probabilities shown are illustrative, not from a specific model. The system samples one word, appends it and repeats.
In short
  • A language model estimates probabilities for the next token, picks one, and repeats.
  • Fluent text is not the same as true text, which is why models can state errors with confidence.
  • Precise context improves answers; anything important still needs checking against real sources.
  • Modern assistants add extra training and tools, but next-token prediction remains the engine.

Ask a modern AI assistant a question and it replies in fluent, confident paragraphs. It feels like talking to something that knows. Under the surface, the core mechanism is almost embarrassingly simple, and understanding it explains both why these tools are so useful and why they sometimes make things up.

One job: predict what comes next

A language model is trained on an enormous amount of text to do one thing: given the words so far, estimate how likely each possible next piece of text is. Take the start of a sentence, "The cat sat on the". A trained model gives a high probability to "mat", a lower one to "floor" or "sofa", and a tiny one to "moon".

The pieces it works with are called tokens. A token is often a whole common word, but rarer words are split into chunks, so a long word may be several tokens. The model does not read letters the way you do. It reads tokens, and it outputs a probability for each token in its vocabulary.

A sentence is built one token at a time

To write a sentence, the system picks a token from that probability list, adds it to the text, and then asks the same question again with the longer text. It repeats that loop until the answer is complete. A setting often called temperature controls how adventurous the pick is. Low temperature nearly always chooses the most likely token, which gives steady, predictable text. Higher temperature allows less likely choices, which gives more variety and more risk.

That is why you can ask the same question twice and get two different answers. Nothing is being looked up. The text is being sampled.

Where the intelligence comes from

If the job is only "predict the next token", why can the results write code or explain a physics problem? Because to predict text well across billions of examples, a model has to absorb a great deal about grammar, facts, reasoning patterns and how arguments are structured. The key technical step was an architecture called the transformer, introduced in 2017, which lets the model weigh every earlier token when deciding what comes next.1 Scaling that approach up produced systems that could pick up new tasks from just a few examples in the prompt.2

Today's assistants add further training on top. People rate answers, and the model is tuned to follow instructions and to be helpful and safe. Many can also call outside tools, such as a search or a calculator. But the engine underneath is still next-token prediction.

Why they make things up

This explains the best-known weakness. The model produces text that is plausible, which is not always the same as text that is true. If it has seen few examples of the topic, it may still continue with something that sounds right: a plausible citation, a believable statistic, a confident date. Researchers call these errors hallucinations, and they are an active problem.3 The model has no built-in alarm that rings when it is guessing.

What this means for how you use it

  • Give it context. A vague prompt leaves a wide spread of likely continuations. A precise one narrows it.
  • Verify anything that matters. Names, numbers, dates, quotations and references need checking against a real source.
  • Ask for reasoning in steps on problems with several parts, and check the steps.
  • Treat it as a fast, well-read collaborator, not as an authority. It is excellent at drafting, summarizing, explaining and brainstorming, and weaker where exact facts matter.
  • Protect private information. Do not paste in anything you would not want stored or seen by others.

In the course. These ideas, how to ask well, how to check the answers and how to use AI honestly, are the first part of the Neurovia One AI Course. See the course.

References

  1. Vaswani A, Shazeer N, Parmar N, et al. Attention is all you need. Advances in Neural Information Processing Systems 30 (NeurIPS 2017). Find it ↗
  2. Brown TB, Mann B, Ryder N, et al. Language models are few-shot learners. Advances in Neural Information Processing Systems 33 (NeurIPS 2020). Find it ↗
  3. Ji Z, Lee N, Frieske R, et al. Survey of hallucination in natural language generation. ACM Comput Surv. 2023;55(12):1–38. Find it ↗
Syed Kausar Abbas
Syed Kausar AbbasFounder, Neurovia One · MPhil Biochemistry scholar

Writes about the brain, biochemistry and learning, and teaches the live online Neurovia One AI Course.

About Syed →
Learn AI, live and online

25 sessions in English, starting 1 December 2026. From $39 for students and teachers.

See the course