Large Language Models (LLMs) like ChatGPT work by breaking language into small units called tokens, assigning each a numerical value, and then predicting the most likely next token step by step — a process known as next-token prediction.
Tokenization is the first step: a sentence like "Hello, world!" might be split into tokens such as "Hello", ",", " world", and "!". Each token is converted into a number the model can process. During training, the model learns patterns from vast amounts of text to guess which token should follow a given sequence.
At inference, ChatGPT takes a prompt, tokenizes it, and then repeatedly predicts the next token based on the probabilities learned. This autoregressive approach generates coherent responses, though the model doesn't understand meaning in a human sense — it simply calculates the most probable continuation.
Understanding tokens also explains why context windows matter: each token consumes part of the model's capacity, so longer inputs may lead to truncated outputs.