AI Foundations

Large Language Models: What They Are and How They Generate Text

What large language models are, how they predict and generate text one piece at a time, and the typical limits that make checking their output wise.

On this page
  1. The short version
  2. Tokens: the pieces of text
  3. How training works
  4. How text is generated
  5. The context window
  6. What they do well
  7. Typical limitations
  8. Does it understand?
  9. Practical advice

The short version

A large language model, often abbreviated LLM, is a program trained on very large amounts of text to predict what text is likely to come next. Given a beginning, it estimates which piece of text should follow, adds it, and repeats. Chained together, that simple operation can produce paragraphs, answers, summaries, translations and code.

The word “large” refers to the size of the model, meaning the number of adjustable internal settings (often called parameters), and to the volume of training text. Exact figures vary between systems and change quickly, so they are not worth memorizing.

Tokens: the pieces of text

Models do not read whole words the way people do. Text is first split into tokens, which may be whole short words, parts of longer words, punctuation or spaces. Each token is converted to a list of numbers that the model can process. Output is generated as a sequence of tokens that are then turned back into readable text.

This detail explains some odd behaviors. A model can find it harder to count letters in a word or work with unusual spellings, because it sees tokens rather than individual characters.

How training works

Training has a main stage and usually some follow-up stages.

Learning from text. The model is shown enormous amounts of text with the next token hidden and asked to guess it. When it guesses poorly, its settings are adjusted a little. Over many repetitions it becomes good at capturing grammar, style, common facts, and patterns of reasoning that appear in writing. This is machine learning applied to language, using neural networks.

Refinement. Developers often continue training so the model follows instructions, answers helpfully and avoids certain kinds of output. People may rate or compare responses, and those judgments are used to steer the model. Details differ across providers and are not always public.

Throughout, the choice of source material matters. The discussion of training data explains how what goes in influences what comes out.

How text is generated

When you type a prompt, the model processes it and calculates a probability for each possible next token. It then picks one. Always choosing the single most likely token tends to produce flat, repetitive text, so systems usually introduce controlled randomness. Settings that adjust this randomness let a tool be more predictable or more varied. This is why asking the same question twice can produce different wording, or even different answers.

The chosen token is appended to the text, and the process repeats until the model produces an end signal or reaches a length limit.

A key component in modern designs is a mechanism that lets the model weigh which earlier parts of the text are most relevant for the next choice. This helps it keep track of context across a long passage, for example linking a pronoun back to the person it refers to.

The context window

A model can only consider a limited amount of text at once, called its context window. It includes your prompt, any documents you paste in, and the conversation so far, plus the reply being written. Anything outside the window is not available to the model. Windows have grown over time but remain finite, and models can handle details in the middle of very long inputs less reliably than those at the edges.

Unless a tool is specifically built to store information, the model does not remember previous conversations. What looks like memory is typically the earlier text being supplied again.

What they do well

  • Drafting, rewriting and adjusting the tone of text
  • Summarizing and extracting key points
  • Translating between many languages
  • Explaining concepts in different levels of detail
  • Assisting with code and structured formats
  • Answering general questions on widely documented topics

This overlaps with the field of natural language processing, in which language models are now a central technique. They also sit within the broader category of generative AI.

Typical limitations

Fabricated details. Because the goal is to produce likely text, not verified truth, a model can write confident statements that are wrong, including invented sources or quotes. The mechanics are explained in the article on AI hallucinations. Important claims should be checked.

Knowledge cutoffs. A model’s knowledge reflects the text it was trained on up to some point. Without access to up-to-date sources, it may be unaware of recent developments.

Sensitivity to wording. Small changes in a prompt can change an answer. Asking for step-by-step explanations may help, but it does not guarantee correctness.

Weak spots in exact work. Arithmetic, precise counting and long chains of logic can go wrong. Tools that connect models to calculators or search can reduce some of these errors but add their own failure modes.

Inherited bias. The model reflects patterns in its text sources, including stereotypes and imbalances, a form of algorithmic bias.

Limited transparency. It is hard to say why a model produced a specific sentence, which is part of why explainable AI is an active research area.

Does it understand?

Experts disagree. These systems clearly capture a great deal about how language and the world are described in text, and they can perform tasks that seem to require reasoning. They also fail in ways that people rarely do. Describing them as either “just autocomplete” or as genuinely thinking can both oversimplify. A cautious position is that they are powerful text-pattern tools whose inner workings are still being studied.

Practical advice

Treat outputs as drafts. Verify names, figures, dates and citations. Avoid pasting sensitive personal or confidential information into a tool unless you know how the provider handles it, a concern covered under AI privacy. For decisions that affect people, keep human oversight in place. And remember that fluent writing is a sign of good language modeling, not a sign of accuracy.

The complete guide to ai foundations

What Is Artificial Intelligence? A Plain-Language Introduction
Read the guide

Keep exploring

Guides from other topics

All topics →