Pre-training on text
A large language model begins life by reading. It is shown an enormous collection of text from books, websites, articles, code and other sources, and trained on a single task: predicting the next piece of text. Each time it guesses wrong, its parameters are adjusted. To get good at this across billions of examples, the model has to absorb grammar, facts, writing styles, common reasoning steps and relationships between ideas. This stage, called pre-training, requires vast computing power and can take months.
Tokens, not words
Models do not read letters or whole words directly. Text is split into tokens, which may be whole common words, parts of longer words or punctuation. In English a token averages roughly three-quarters of a word. Each token is turned into a list of numbers called an embedding, which captures aspects of its meaning learned during training. Languages with less training data, or written in scripts the tokenizer handles less efficiently, may need more tokens for the same content, which can make them slower and costlier to process.
The transformer and attention
Most language models use the transformer architecture, introduced by Google researchers in a 2017 paper titled Attention Is All You Need. Its key mechanism, attention, lets the model weigh how relevant each earlier token is to the one it is about to produce. In the sentence the trophy did not fit in the suitcase because it was too big, attention helps the model link it to trophy. Stacked layers of attention let models track context across long documents, which earlier designs struggled to do.
Choosing the next token
At each step the model produces probabilities for every token in its vocabulary. The system then picks one, sometimes the most likely, sometimes sampling among likely options to make text more natural and varied. A setting called temperature controls this randomness. The chosen token is added to the text, and the whole process repeats until the reply is complete. This is why answers appear on screen word by word, and why asking the same question twice can produce different wording.
From predictor to assistant
A model trained only to predict internet text would continue a question rather than answer it, and might produce harmful content. To make it a helpful assistant, developers fine-tune it on examples of good conversations and use techniques such as reinforcement learning from human feedback, in which people rate responses and the model learns to prefer the better ones. Other methods train models against written principles. This stage shapes the assistant's tone, helpfulness, honesty and safety behaviour.
Context windows and memory
A model can only consider a limited amount of text at once, known as its context window, measured in tokens. Early chatbots could handle a few thousand tokens, a few pages. By 2024 some models could take in hundreds of thousands or even a million tokens, enough for several books. Within a conversation, the model rereads the whole history each time it replies; it does not remember past chats unless a product feature stores and supplies that information.
Beyond text
Many modern models are multimodal: they can read images, charts and handwriting, listen to speech and sometimes watch video, converting these inputs into tokens that the same network can process alongside text. That lets an assistant describe a photo, read a scanned receipt, explain a graph or hold a spoken conversation. Some can also generate images or speech. The underlying principle remains prediction, applied to a richer set of inputs and outputs.
Reasoning and tools
Newer models are trained to think through problems step by step before answering, spending more computation on difficult questions, which improves performance in maths, coding and science. Many assistants can also use tools: searching the web, running code, reading files or calling other software. This lets them check facts, perform precise calculations and work with up-to-date information, reducing some of the weaknesses of pure prediction.
What this means for users
Knowing that chatbots predict likely text explains their strengths and quirks. They write fluently because fluent text is what they learned. They can make up facts because a plausible continuation is not always a true one. They respond to how a question is framed, which is why clear instructions and examples produce better answers. Used with that understanding, and with important facts checked, they are among the most versatile tools ever built.
Sources & further reading
- Vaswani et al. · Attention Is All You Need (2017) ↗
- OpenAI · What are tokens and how to count them ↗
- Wikipedia · Large language model ↗
Simplified explanation; products differ in their details. Photograph: original AI-generated illustration (Adobe Firefly). Reference organisations do not endorse this website.



