
TL;DR
The short answer
AI works by learning patterns from examples instead of following rules a programmer wrote. The workhorse is a neural network: a huge pile of adjustable numbers called weights. Training shows it millions of examples, measures how wrong each guess is, and nudges every weight so the next guess is a little less wrong.
ChatGPT, Claude and Gemini are the same idea at an enormous scale: a network called a transformer, trained on trillions of words to predict the next piece of text, then tuned with human feedback to behave like a helpful assistant. Everything else (tokens, embeddings, attention, RAG, agents) is a fix for a specific problem along the way. Here they are, in the order they were found.
Rules did not scale, so we let machines learn
The term "artificial intelligence" was coined in 1955, in a proposal for a summer workshop at Dartmouth College. Its authors expected that "a significant advance" could be made on making machines use language and solve problems "if a carefully selected group of scientists work on it together for a summer." That summer lasted about seventy years.
For decades the main approach was to write the intelligence by hand. You want a program that diagnoses infections? Interview doctors, turn their knowledge into thousands of IF-THEN rules, and run them. These "expert systems" worked in narrow corners and were a real business in the 1980s. They also had a fatal bug: the world has more exceptions than anyone can write down.
Try writing the rules for "this photo contains a cat." Pointy ears? So do foxes. Whiskers? So do seals. A cat seen from behind, half hidden under a blanket, in bad light? You will be writing rules until you retire, and the program will still fail on the next photo.
Machine learning flips the job. You don't write the rules. You collect examples with the right answers (10,000 photos labeled "cat" or "not cat", a million emails labeled "spam" or "fine") and let the computer find the rules itself. The result of that search is called a model: a program nobody wrote line by line, which is both the magic and the problem of everything that follows.
1958: a machine that learns by doing
The first machine that learned from examples was built by psychologist Frank Rosenblatt at the Cornell Aeronautical Laboratory, with money from the US Navy. He called it the perceptron. Its hardware version, the Mark I, looked at the world through a 20 by 20 grid of 400 light sensors, and its "knowledge" lived in knobs: potentiometers that electric motors turned as it learned.
The idea was borrowed, loosely, from the brain. A perceptron is one artificial neuron. It takes inputs (here, how bright each of the 400 sensors is), multiplies each one by a weight that says how much that input matters, adds everything up, and fires if the total passes a threshold. Fire means "this is the letter X", silence means "it isn't."
The learning rule was beautifully simple. Show the machine an example. If it answers correctly, do nothing. If it's wrong, turn the knobs of the inputs that were active a little in the direction that would have made the answer right. Repeat. Show it enough letters and the knobs settle into positions that recognize them.
The press went wild. On July 8, 1958, The New York Times ran a short story with a headline that could have been written last week: "New Navy Device Learns By Doing."
“The Navy revealed the embryo of an electronic computer today that it expects will be able to walk, talk, see, write, reproduce itself and be conscious of its existence.”
It could, in practice, tell apart a few simple shapes. Keep this headline in mind every time you read that a new model "thinks." The gap between demo and promise is as old as the field.
1969: the bug that froze the field
In 1969 Marvin Minsky and Seymour Papert published Perceptrons, a book that proved, with real math, what a single perceptron can't do. The famous example is XOR, "exclusive or": answer yes if exactly one of two switches is on, no if both are on or both are off.
Why can't one neuron learn something that simple? Because a single neuron can only split the world with one straight line: everything on one side is "yes", everything on the other is "no." Put the four XOR cases on a square and you will see that no straight line separates the yeses from the nos. Don't take my word for it. Try:
Researchers knew that stacking several layers of neurons would get around this. The problem was that nobody had a practical way to train a stack. With one neuron, you know which knob to blame for a wrong answer. With three layers of neurons feeding each other, which of the thousands of knobs caused the mistake?
The book landed in a field already short on results, and it's often blamed for what came next. In 1973 a report for the British government by mathematician James Lighthill concluded that AI had failed to deliver on its "grandiose objectives," and funding in the UK and the US dried up. The 1970s became the first AI winter.
1986: let the error flow backwards
The fix for training a stack of neurons had been found more than once (in 1970 by Seppo Linnainmaa, in 1974 by Paul Werbos), but it became famous in 1986, when David Rumelhart, Geoffrey Hinton and Ronald Williams showed in Nature that it made multi-layer networks learn useful things. It's called backpropagation.
The idea: after a wrong guess, measure the error at the output, then pass it backwards through the network, layer by layer. At each connection, calculus tells you exactly how much that particular weight contributed to the error, and in which direction to nudge it. Every weight gets its share of the blame, all at once.
Backpropagation answers "which way should each knob turn?" The procedure that uses the answer is called gradient descent: take a small step in the direction that reduces the error, recompute, take another step. Picture walking down a mountain in thick fog. You can't see the valley, but you can feel which way the ground slopes under your feet, so you take a step downhill and feel again.
Now networks could have hidden layers, and hidden layers solved XOR and much more. In the 1990s, Yann LeCun's convolutional networks read handwritten digits on bank checks. And yet neural networks went back into the drawer for another twenty years. They needed far more data and computing power than anyone had, and simpler methods usually won the benchmarks.
The bug this time wasn't in the idea. It was in the hardware budget.
2012: the fix was data and video game chips
Two things changed in the 2000s. First, the internet produced labeled data on a scale nobody had imagined. Stanford professor Fei-Fei Li and her team built ImageNet, more than 14 million photos labeled by hand with what they show, and from 2010 ran a yearly contest on a 1,000-category subset of it.
Second, graphics cards. A GPU is built to do the same small calculation on millions of pixels at once for video games. The math of a neural network is the same kind of calculation: multiply lots of numbers, add them up, in parallel.
In 2012 Alex Krizhevsky, Ilya Sutskever and Geoffrey Hinton entered the ImageNet contest with a deep network trained on two consumer Nvidia GTX 580 graphics cards for five to six days. Their AlexNet got the right answer in its top five guesses for all but 15.3% of the test images. The second-best entry, built on years of hand-designed image features, missed 26.2%. In a field where people fought over fractions of a percent, that was a knockout.
Within a few years, deep learning ran photo search, speech recognition and translation. The lesson of 2012 shaped everything after it: the old idea was right, it just needed to be bigger. More data, more layers, more compute. Remember this, because it comes back in 2020 as a law.
Words are not pixels: meaning as numbers
Images are already numbers: each pixel is a brightness value. Words are not. To a computer, "cat" is three characters with no more in common with "kitten" than with "catapult." Before a network can learn anything about language, words need to become numbers that carry meaning.
In 2013 Tomas Mikolov and colleagues at Google published word2vec, which learned a list of a few hundred numbers for each word just by reading lots of text and predicting which words appear near which. These lists are called embeddings. Words used in similar contexts end up with similar lists, so in this space of numbers, "cat" sits next to "kitten" and far from "carburetor."
Then came the trick that made everyone sit up. Directions in that space mean something. Take the numbers for "king," subtract "man," add "woman," and the closest word to the result is "queen." Nobody told the model about royalty or gender. It found the pattern in how people write.
Embeddings are still everywhere. Every modern language model starts by turning its input into embeddings, and the "semantic search" behind most AI products (find documents that mean the same thing, even with different words) is a nearest-neighbor search in exactly this kind of space.
The memory bug: reading one word at a time
Language has order, and meaning depends on things far apart. In "The animal didn't cross the street because it was too tired," the word "it" means the animal. Change "tired" to "wide" and "it" means the street. To get that right, a model has to connect words across the whole sentence.
Through the 2000s and early 2010s, the standard tool was the recurrent neural network: read one word, update an internal memory, read the next word, update again. The best version, the LSTM of 1997, could hold on to information for a while. But it still had two bugs. Information from early words faded as the sentence went on, like a message passed down a long line of people. And reading word by word meant the computation couldn't be split across thousands of GPU cores. It was slow by design.
The first patch came in 2014: attention. While translating, let the model look back at all the words of the source sentence and decide which ones matter for the word it's writing right now. It worked so well that in 2017 eight researchers at Google asked the obvious next question in a paper with a cheeky title, Attention Is All You Need: what if we drop the word-by-word reading entirely and keep only attention?
The result is the transformer. In every layer, each word asks a question ("what am I referring to?"), every other word offers an answer ("I'm an animal, I'm a noun, I'm the subject"), and each word takes in a blend of the answers that match its question best. Do this in dozens of layers and the words gradually soak up the context they need.
Because every word is processed at the same time, transformers are perfect for GPUs. The paper's best translation model trained in three and a half days on eight graphics cards and beat everything that came before. Almost every famous AI system since (GPT, Claude, Gemini, Llama, the image and video generators) is built on this architecture.
Just predict the next word. Then do it bigger.
Here's the strange part. The task that produced ChatGPT is almost embarrassingly simple: given some text, predict what comes next.
It sounds like autocomplete, and it is. But think about what it takes to do it well. To continue "The capital of Japan is" you need geography. To continue a Python function you need programming. To continue a mystery novel's last chapter you need to follow the plot. Next-word prediction is a single task that rewards learning almost everything people write about. And it needs no human labels: every sentence on the internet is already a training example, with its own next word as the answer.
OpenAI ran with this. GPT-1 (2018) had 117 million weights and learned from about 7,000 unpublished books. GPT-2 (2019) had 1.5 billion, trained on 8 million web pages, and wrote such convincing paragraphs that OpenAI first released only smaller versions, citing misuse risks. GPT-3 (2020) had 175 billion and could do tasks it was never trained for, if you showed it a few examples in the prompt.
| Model | Year | Weights | What changed |
|---|---|---|---|
| GPT-1 | 2018 | 117 million | Pretraining on raw text, then a little task-specific training, beats custom models |
| GPT-2 | 2019 | 1.5 billion | Writes coherent paragraphs; staged release over misuse fears |
| GPT-3 | 2020 | 175 billion | Learns new tasks from a few examples in the prompt, no retraining |
In early 2020, OpenAI researchers led by Jared Kaplan measured something remarkable: the error of a language model falls in a smooth, predictable curve as you add weights, data and compute. These scaling laws turned AI progress from a research gamble into something closer to an engineering budget. Want a better model? Here's roughly how much bigger it needs to be. In 2022 DeepMind's Chinchilla paper corrected the recipe: most models were too big for the data they saw. A 70-billion-weight model trained on 1.4 trillion tokens beat models four times its size.
One detail matters for everything practical you'll do with these models: they don't read words. They read tokens, chunks of text from a fixed vocabulary of tens of thousands to a few hundred thousand pieces. Common words are one token, rare words get split, and a leading space is part of the token. The tokenizer below is the real one used by GPT-4o-class models. Type anything:
That last observation explains a famous embarrassment. For a long time chatbots couldn't count the r's in "strawberry." In the sentence "How many r's are in strawberry?" the word arrives as one token, number 101830. The model sees an ID, not ten letters, so it has to have learned the spelling of that token indirectly, from text about it. Tokens also explain why you pay per token, why the limit on a conversation is measured in tokens, and why some languages cost more to process than English.
The politeness bug: autocomplete is not an assistant
GPT-3 was brilliant and nearly useless to normal people. Ask a pure next-word predictor "How do I boil an egg?" and it might continue with "How do I poach an egg? How do I fry an egg?", because on the internet, a question is often followed by more questions: it has seen a lot of FAQ pages. It completes documents. It doesn't follow instructions, and it repeats whatever it saw, including the worst of the internet.
The fix came in stages, and it's the reason the chatbot you use feels like a person and not a search engine with stage fright.
- Pretraining. Next-token prediction on a huge pile of text. This is where nearly all the knowledge and nearly all the cost is. Meta's Llama 3, for example, was pretrained on more than 15 trillion tokens.
- Instruction tuning. Continue training on tens of thousands of example conversations written by people: a request, then a good answer. The model learns the format "someone asks, I help."
- Preference tuning. People compare pairs of answers and pick the better one. A second model learns to predict those preferences, and the main model is trained to produce answers that score well. This is RLHF, reinforcement learning from human feedback.
How much do the later stages matter? In OpenAI's InstructGPT paper (2022), people preferred answers from a tuned model with 1.3 billion weights over answers from the raw 175-billion-weight GPT-3. A model a hundred times smaller won because it had learned what people actually want.
On November 30, 2022, OpenAI put a model trained this way behind a chat box and called it ChatGPT. By January it had an estimated 100 million monthly users, according to a UBS analysis reported by Reuters, the fastest growth of any consumer app up to then. The technology was not new. The packaging was.
How ChatGPT answers you, one token at a time
Put the pieces together and here's what happens when you press Enter:
- Your message, plus the hidden instructions and the conversation so far, is split into tokens.
- Each token becomes an embedding, a list of numbers.
- The numbers flow through the transformer's layers. GPT-3, for scale, had 96 of them. In each one, tokens exchange information through attention and get transformed.
- Out comes a probability for every token in the vocabulary. For "The cat sat on the" that might be 41% "mat," 18% "floor," and tiny chances for everything else.
- The software picks one token from those probabilities, appends it to the text, and runs the whole thing again for the next token.
That loop runs once per token, which is why answers stream in word by word. The model doesn't plan a whole paragraph and then type it out. It writes one token, then re-reads everything, including what it just wrote, and writes the next.
Two settings shape that loop. Temperature controls how the token is picked: at a low temperature the model almost always takes the most likely token, which is good for facts and code; at a higher one, less likely tokens get a chance, which reads as more creative and also more error-prone. The context window is how much text the model can see at once. Popular models in 2026 handle from about 128,000 to over a million tokens. Anything outside the window doesn't exist for the model, which is why very long chats seem to "forget" their beginning.
The confidence bug: why AI makes things up
Now you can see where hallucinations come from. The model was trained to produce plausible text, and for well-known facts the most plausible continuation is also the true one. For rare facts (an obscure person's birthday, the title of a specific paper, a court case) the model has seen little or nothing, but the loop still has to pick a token, and a confident-sounding wrong answer is often more "plausible" than a hedge.
A September 2025 paper from OpenAI adds a second cause: the tests we grade models on. Most benchmarks only count right answers. A model that guesses a birthday has a 1-in-365 chance of scoring; a model that says "I don't know" scores zero every time. Train and rank models on such tests and you get confident guessers. The authors argue that the main evaluations need to stop punishing honest uncertainty.
A side branch: pictures from noise
Image generators work differently from chatbots. Most of them are diffusion models. During training, you take millions of images, add random noise to them step by step until they're pure static, and teach a network to undo one step of noise at a time. The 2020 paper that made this work well called them denoising diffusion models.
To generate a picture, you start from pure random noise and run the denoiser again and again. A text description steers each step, so the shapes that emerge from the static become "a house under the sun" and not something else. Stable Diffusion, released in August 2022, made the method cheap enough to run on a home computer by doing the denoising in a compressed version of the image (latent diffusion).
Thinking before answering
Because a model writes one token at a time, it can't "think" anywhere except in the text it writes. In 2022 Google researchers showed that simply asking for intermediate steps, chain-of-thought prompting, made large models much better at math word problems. The model gets more tokens, and so more computation, to work toward the answer.
Reasoning models build this into training. OpenAI's o1 (September 2024) was trained with reinforcement learning to produce a long hidden chain of thought before answering, and got better the longer it was allowed to think. In January 2025, the Chinese lab DeepSeek released R1 with open weights and described the recipe: reward the model on problems with checkable answers, such as math and code, and step-by-step reasoning emerges largely on its own. Most flagship models now have a reasoning mode. It costs more tokens and time, and it pays off on multi-step problems.
The last bugs: no fresh knowledge, no hands
Two limits remain, whatever the model's size. Its knowledge is frozen at the end of training, and it doesn't know your company's documents. And it can only write text: it can't check the weather, send an email or query a database.
The fix for the first is RAG, retrieval-augmented generation, named in a 2020 paper from Facebook AI. Before the model answers, your app searches your documents for passages related to the question (usually with embeddings, the 2013 idea again), pastes the best ones into the prompt, and asks the model to answer from them and cite them. The model reads instead of remembering, which cuts hallucinations and lets you update its knowledge by updating a folder.
The fix for the second is tool calling. You describe some tools to the model ("get_weather takes a city"), and instead of an answer, the model can reply with a structured request: call get_weather with "Lisbon." Your app, not the model, runs the tool and sends the result back. An AI agent is this in a loop: the model picks a step, the app executes it, the result goes back into the context, and the model picks the next step until the job is done. In late 2024 Anthropic released the Model Context Protocol, an open standard for connecting models to tools and data, and other AI companies adopted it within months.
Notice what didn't change. Under every agent is the same next-token predictor. It still only writes text. The "agent" part is ordinary software that turns some of that text into actions, which is also why an agent's safety depends on which tools you hand it.
The whole chain on one page
Here is the bug report in one table. Each row fixed the problem of the row above it, and each left a new one for the next.
| Idea | Year | What it fixed | What it left broken |
|---|---|---|---|
| Machine learning | 1950s | You can’t write rules for messy problems | One neuron can only draw a straight line |
| Backpropagation | 1986 | Training networks with hidden layers | Needed far more data and compute than existed |
| Deep learning on GPUs | 2012 | Data and compute, via ImageNet and graphics cards | Words aren’t numbers |
| Embeddings | 2013 | Meaning as numbers | Models read word by word and forget |
| Transformer | 2017 | Context across long text, in parallel | Needs huge training to be useful |
| Scaling (GPT-3) | 2020 | General ability from next-word prediction | Completes documents, ignores instructions |
| RLHF (ChatGPT) | 2022 | Follows instructions, talks like an assistant | Confidently makes things up |
| Reasoning models | 2024 | Multi-step problems | Knowledge is frozen and the model can’t act |
| RAG, tools, agents | 2020–2025 | Fresh knowledge and actions in the world | Reliability, cost and safety: today’s work |
What this means when you use AI
You don't need any of this history to type into a chat box. But knowing how the machine works changes how you use it:
- It predicts, it doesn't look things up. Unless a tool or document is involved, an answer is the model's best guess at plausible text. Check facts that matter.
- Context beats cleverness. The model knows only its training and what's in the window. Pasting the actual document, email or code gives far better answers than a perfectly worded prompt without it.
- Tokens are the unit of everything. Price, speed and memory limits are all counted in tokens. Long pasted logs cost money and push older context out.
- Use low temperature for facts and code, and save randomness for brainstorming.
- Ask for the steps on hard problems, or use a reasoning model. Thinking happens in tokens, so give it room.
- An agent is only as safe as its tools. The model writes requests; your software decides what actually gets executed.
If you want the same story with your hands on the controls, the free AI Fundamentals course goes through it in eight lessons with an interactive demo in each: you'll fit a model by hand, read real tokens, play with attention and temperature, and step through an agent loop.
FAQ
- How does AI work in simple terms?
- Modern AI learns patterns from examples instead of following rules written by a programmer. A neural network makes a guess, measures how wrong it was, and adjusts millions or billions of internal numbers (weights) to be a little less wrong next time. After enough examples, the weights encode the pattern: what a cat looks like, or which word is likely to come next.
- How does ChatGPT work?
- ChatGPT is a large language model: a transformer network trained on trillions of tokens of text to predict the next token, then fine-tuned on example conversations and human ratings so it follows instructions. When you send a message, it computes probabilities for the next token, picks one, adds it to the text and repeats until the answer is complete. It can also call tools such as web search when the app allows it.
- What is the difference between AI, machine learning and deep learning?
- AI is the broad goal of making machines do tasks that need intelligence. Machine learning is the approach of learning those skills from data instead of hand-written rules. Deep learning is machine learning with neural networks that have many layers, and it is the approach behind almost all modern AI, including ChatGPT, image generators and speech recognition.
- Does AI understand what it says?
- It depends on what you mean by understand, and researchers disagree. Language models build rich internal representations of concepts and can use them flexibly, which looks like understanding in many tests. But they have no direct experience of the world, they can be confidently wrong in ways people rarely are, and they generate text by prediction rather than by checking facts. Treat them as very capable pattern engines, not as minds.
- Where does AI get its information?
- A language model learns from its training data: public web pages, books, code and other text collected up to a cutoff date. That knowledge is stored in its weights, not as a database of documents, so it cannot quote sources reliably. Products add fresh information by searching the web or your documents and putting the results into the prompt, a technique called retrieval-augmented generation (RAG).
- Why does AI make things up?
- Because it is trained to produce plausible text, and for rare facts a plausible guess can be wrong. Research from OpenAI in 2025 also points to evaluation: most benchmarks reward a correct guess and give nothing for saying "I don’t know", so models learn to guess. Giving the model the source documents and asking it to cite them reduces this a lot.
Sources
- 01McCarthy et al., Dartmouth proposal (1955)
- 02Rosenblatt, The Perceptron (1958)
- 03The New York Times, “New Navy Device Learns By Doing” (1958)
- 04Minsky and Papert, Perceptrons (1969)
- 05Rumelhart, Hinton and Williams, backpropagation, Nature (1986)
- 06Hochreiter and Schmidhuber, LSTM (1997)
- 07ImageNet
- 08Krizhevsky, Sutskever and Hinton, AlexNet (2012)
- 09Mikolov et al., word2vec (2013)
- 10Bahdanau, Cho and Bengio, attention (2014)
- 11Vaswani et al., Attention Is All You Need (2017)
- 12OpenAI, GPT-1 (2018)
- 13OpenAI, GPT-2 (2019)
- 14Brown et al., GPT-3 (2020)
- 15Kaplan et al., Scaling Laws (2020)
- 16Hoffmann et al., Chinchilla (2022)
- 17Ouyang et al., InstructGPT (2022)
- 18OpenAI, Introducing ChatGPT (2022)
- 19Reuters, ChatGPT sets record for fastest-growing user base (2023)
- 20Kalai et al., Why Language Models Hallucinate (2025)
- 21Ho, Jain and Abbeel, Denoising Diffusion (2020)
- 22Rombach et al., Latent Diffusion (2022)
- 23Wei et al., Chain-of-Thought Prompting (2022)
- 24OpenAI, Learning to Reason with LLMs (2024)
- 25DeepSeek-AI, DeepSeek-R1 (2025)
- 26Lewis et al., Retrieval-Augmented Generation (2020)
- 27Anthropic, Model Context Protocol (2024)


