The World's Most Advanced Autocomplete Engine
When you type a message on your smartphone and your keyboard suggests the next word, you are using a tiny language model. If you type 'See you...', your phone predicts 'later', 'soon', or 'tomorrow'.
A Large Language Model (LLM) like OpenAI's GPT-4o, Anthropic's Claude 3.5, or Google's Gemini operates on that exact same principle—but scaled up by a factor of trillions.
An LLM does not possess feelings, consciousness, or a hidden brain storing pre-packaged answers to every question. Instead, it is a massive mathematical engine trained on billions of books, articles, code repositories, and web conversations to answer one fundamental question:
'Given all the words written so far in this conversation, what is the single most likely token to follow next?'
By answering that question 50 to 100 times per second, the AI generates fluid paragraphs, solves coding bugs, and writes poetry that feels remarkably human.
“An LLM doesn't look up answers in an encyclopedia. It generates answers on the fly by predicting the next most plausible word, over and over.”
The Core Mental Model
Think of an LLM as a master improvisor. It never pauses to think through an entire essay before writing line one. It starts speaking and continually chooses the best next word based on the full conversation history.
Step 1: Chopping Language into Tokens
Computers cannot read letters or words directly; they only understand numbers. Before an AI can process your prompt, it converts your text into small building blocks called tokens using a technique called Byte-Pair Encoding.
A token is not always a full word. Common English words like 'cat', 'walk', or 'apple' are single tokens. But longer or complex words are split into pieces: 'unbelievable' might become 'un', 'believ', and 'able'.
On average, in English, 1,000 tokens equals roughly 750 words.
This tokenization explains several quirky AI behaviors that confuse beginners:
• Why AI struggles to count letters: If you ask an LLM 'How many letters are in strawberry?', it often gets it wrong because it never sees the letters 's-t-r-a-w-b-e-r-r-y'. It only sees the numeric tokens representing the chunks.
• Why spelling words backwards is hard: The model has to deconstruct the token into individual characters, reverse their mathematical coordinates, and re-emit them without seeing the intermediate steps.
Step 2: Calculating Probabilities for the Next Token
Once your prompt is turned into tokens, it passes through dozens of neural network layers. At the very final layer, the model does not pick a single word outright. Instead, it assigns a probability score to every single token in its vocabulary (which typically contains 100,000 to 200,000 possible tokens).
For example, consider the sentence: *'The tired student drank a hot cup of...'*
The model's neural network might calculate the following probability distribution:
If the model always picked the #1 highest-probability token (a setting called 'Greedy Decoding'), its writing would quickly become robotic, repetitive, and dull. To make text feel natural and creative, developers introduce controlled randomness through a setting called Temperature.
- —• 'coffee': 62% probability
- —• 'tea': 24% probability
- —• 'cocoa': 8% probability
- —• 'water': 3% probability
- —• 'gasoline': 0.00001% probability
Step 3: What Does 'Temperature' Actually Do?
When software engineers call AI APIs, they adjust a parameter called Temperature, usually ranging from 0.0 to 1.0:
• Low Temperature (0.0 – 0.2): The model strictly picks the top 1 or 2 highest-probability words. The output is predictable, consistent, and factual. This is ideal for extracting data from receipts, writing SQL queries, or performing financial calculations.
• Medium Temperature (0.5 – 0.7): The standard setting used in consumer chatbots like ChatGPT and Claude. It selects words from the top 5% of plausible options, providing a natural balance of accuracy and conversational variety.
• High Temperature (0.8 – 1.2): The model ventures further down the probability distribution, occasionally picking surprising words. This produces inventive metaphors, fiction stories, and creative marketing angles—but increases the risk of hallucination and nonsense.
Step 4: The Transformer Secret: Self-Attention
Before 2017, computer models read text sequentially, word by word from left to right. When they reached the end of a long paragraph, they had already 'forgotten' the words at the beginning.
In 2017, researchers at Google published a landmark paper titled *'Attention Is All You Need'*, introducing the Transformer architecture.
Transformers introduced Self-Attention: the ability to process all words in a document simultaneously and calculate dynamic mathematical links between them.
Consider this sentence: *'The server crashed because it ran out of memory.'*
When the model evaluates the word 'it', the self-attention mechanism instantly connects 'it' to 'server' rather than 'memory'. This allows modern models to understand complex grammar, follow instructions across 100-page PDF documents, and keep track of characters across entire books.
| Generation Stage | What Happens | Real-World Impact |
|---|---|---|
| Tokenization | Text is divided into sub-word chunks (~4 characters) | Dictates how models count words, code, and non-English languages |
| Vector Embeddings | Tokens are mapped to points in multidimensional math space | Allows the AI to know that 'king' and 'queen' share semantic meaning |
| Self-Attention | Every token computes relationships with every other token | Enables the model to understand context and track pronouns across long essays |
| Probability Distribution | Final layer calculates likelihood scores for 100,000+ words | Provides candidate choices for what should be spoken next |
| Temperature Sampling | Randomness filter selects the winning next token | Controls whether the AI sounds like a strict calculator or a creative writer |