How Large Language Models Predict Words: Tokens, Patterns, and You
When you type a message to an AI chatbot, it does not look up the answer in a database. It does not know facts the way you know your own name. Instead it does something stranger and more interesting: it predicts, one chunk of text at a time, what word most likely comes next given everything that came before. This is called next-token prediction, and it is the engine inside every large language model (LLM) you have ever used โ ChatGPT, Claude, Gemini, Llama. Understanding how it works does not just explain AI. It reveals deep truths about the structure of human language itself, which is why linguists pay close attention to what LLMs can and cannot do.
What You'll Learn
By the end of this lesson, you will be able to: โข Define token and explain how LLMs split text into tokens before processing it โข Describe how training on large text corpora enables next-token prediction โข Explain what self-attention means in a transformer model and why context determines meaning โข Analyze what LLMs reveal about morphology, syntax, and semantics from a linguistics perspective
What Is a Token?
LLMs do not process text letter by letter or word by word. They split text into tokens โ chunks that are roughly parts of words, whole short words, or occasionally single characters. Real tokenization examples from GPT-4 (verifiable at platform.openai.com/tokenizer): โข 'The' โ one token โข 'unbelievable' โ three tokens: 'un', 'believ', 'able' โข 'ChatGPT' โ three tokens: 'Chat', 'G', 'PT' โข '2025' โ one token โข A single emoji can be 3 to 4 tokens Why does this matter? The model sees these pieces, not whole words. It learns that 'un-' often signals negation โ not because anyone explained that rule, but because 'un-' appears in front of negative concepts millions of times in training data. The prefix's meaning emerges from statistical pattern alone. Most LLMs use Byte Pair Encoding (BPE), which merges the most frequent character sequences into single tokens. GPT-4 operates with roughly 100,000 distinct tokens in its vocabulary.
Training: Learning Patterns From Enormous Text
An LLM is trained by feeding it enormous amounts of text โ the Common Crawl web corpus alone is over 270 billion words โ and having it do one repeated task: predict the next token. Given the tokens 'The', 'cat', 'sat', 'on', 'the', predict what comes next. The model guesses. If it is wrong, the error signal flows backward through the network (backpropagation) and adjusts billions of numerical weights very slightly. Repeat this 10 trillion times and the model learns: โข Grammar (verbs follow subjects) โข Collocations ('fast food,' not 'quick food') โข World knowledge ('the capital of France is' โ 'Paris') โข Conversational patterns ('How are you?' โ typical responses) All of this emerges from statistics over human-written text โ no rules were hand-coded. GPT-4 has an estimated 1.8 trillion parameters โ numerical weights that collectively encode these patterns. The scale makes human intuition about 'how big' nearly impossible to grasp.
When an LLM tells you Lincoln was born in Kentucky in 1809, that is correct. But when it cites a fake academic paper with real-sounding authors and a plausible journal name, that is a hallucination โ the model generated text that statistically looks like a citation without any actual citation existing. LLMs have no internal fact database to verify against. They only know what typically follows what. When uncertain, the model still produces confident-sounding text.
Attention: How Context Shapes Every Prediction
Before transformers โ the architecture introduced in Google's landmark 2017 paper 'Attention Is All You Need' โ language models processed text sequentially, losing earlier context. Transformers changed this with self-attention. Self-attention lets the model weigh the relevance of every previous token when predicting the next one. This solves a classic linguistics problem: lexical ambiguity. Consider the word 'bank': โข 'She sat by the river bank and read her book.' โ bank means riverbank โข 'She went to the bank to deposit her paycheck.' โ bank means financial institution The attention mechanism looks back at 'river' or 'deposit' and adjusts the representation of 'bank' accordingly. In linguistics this is called contextual disambiguation โ and humans do it effortlessly without thinking about it. Attention also resolves anaphora (pronoun reference): in 'The trophy did not fit in the suitcase because it was too big,' attention helps determine whether 'it' refers to the trophy or the suitcase. The presence of 'too big' in the context of fitting signals the trophy โ the suitcase would need to be 'too small.'
What LLMs Reveal About Human Language
LLMs have become unexpected tools for theoretical linguists. Here is what the models reveal: **Morphology:** LLMs correctly handle irregular plurals (mice, not mouses), irregular past tenses (went, not goed), and derivational suffixes (-ness, -tion, -ly) purely from frequency patterns โ without being given a single grammatical rule. This supports usage-based linguistics, which argues that language is learned from statistical exposure rather than innate rule systems. **Syntax:** LLMs pass many grammaticality judgments previously thought to require deep grammatical knowledge โ correctly flagging 'The children seems tired' as ungrammatical. However they struggle with deeply nested structures like 'The horse raced past the barn fell,' a garden-path sentence where humans also stumble at first. **Semantics:** LLMs learn word meanings from context โ distributional semantics. Linguist J.R. Firth wrote in 1957: 'You shall know a word by the company it keeps.' This is essentially the training objective of every LLM. Words appearing in similar contexts receive similar internal representations. **Limits:** LLMs struggle with grounding (connecting language to physical reality), pragmatics (understanding speaker intent beyond literal meaning), and consistent factual reasoning across long documents.
Flashcards โ click each card to reveal the answer
The word 'bank' has entirely different meanings in 'river bank' and 'savings bank.' How does a transformer model determine which meaning is intended in a given sentence?
Match each LLM or linguistics concept to its accurate description.
Terms
Definitions
Drag terms onto their definitions, or click a term then click a definition to match.
An LLM was trained on 270 billion words of web text. It correctly handles irregular verb forms like 'went' without ever being told the rule. Which linguistic framework does this BEST support?
Token Hunt and Attention Analysis
Go to platform.openai.com/tokenizer (free, no login needed). (1) Type the sentence: 'The unbelievable transformation of butterfly metamorphosis.' Count the exact number of tokens. Write down which words were split into multiple tokens and form a hypothesis about why. (2) Now write two sentences where the word 'light' carries a different meaning in each โ for example as a noun describing illumination and as an adjective meaning low weight. For each sentence, identify which surrounding tokens an attention mechanism would need to weight most highly to resolve the ambiguity. (3) Write one paragraph comparing how an LLM resolves word meaning through token statistics versus how you understand word meaning through lived experience.
Want to keep learning?
Sign up for free to access the full curriculum โ all subjects, all ages.
Start Learning Free