Fundamentals

How machines learn

From hand-written rules to systems that train themselves: the core ideas behind machine learning, neural networks, and the large language models powering today’s chatbots.

01 · The shift

Two ways to tell a computer what to do

Classical programming is a recipe: a human writes explicit instructions, and the machine follows them exactly. That works brilliantly when the rules are known — sorting a list, calculating taxes. But try writing rules for recognizing a cat in a photo, and the project collapses: whiskers may be hidden, lighting varies, breeds disagree, and no one can fully explain how they knew it was a cat at all.

Classical programming

Input plus hand-written rules produces the output. Every behavior was anticipated and coded by a person. Predictable and auditable — and brittle at tasks we cannot fully explain, like vision or language.

Machine learning

Input plus expected outputs produce learned rules — the model. The system generalizes from examples to cases it has never seen. Powerful, but only as good as its data and its training.

Everything on this site — from image classifiers to chatbots — is machine learning. The rest of this page traces how it works, in five steps and one picture.

02 · The engine

The training loop, in five steps

  1. Gather data

    Collect many examples: labeled photos, text corpora, game positions, sensor readings. Data quality sets the ceiling on model quality.

  2. Initialize a model

    Pick an architecture — how artificial neurons connect — and fill its parameters (the tunable numbers) with random values. At first, the model is wrong about everything.

  3. Measure the error

    A loss function compares the model’s prediction with the correct answer and returns a single number: how wrong it was.

  4. Nudge the parameters

    Gradient descent computes which direction each parameter should move to shrink the error, then takes a small step downhill. The 1986 backpropagation paper (Rumelhart, Hinton and Williams, Nature) made this efficient for deep networks.

  5. Repeat, a lot

    Modern training runs this loop billions of times over trillions of words of text. The error falls, the patterns emerge, and capability appears.

In one sentence

Training is descent down an error landscape: measure how wrong you are, step downhill, and repeat until good enough.

03 · The architecture

A neural network, visualized

Artificial neurons are tiny calculators: multiply each input by a weight, add the results up, and pass the total through a simple non-linear function. Connect them layer by layer and the magic appears — early layers detect simple features, deeper layers combine them into abstract ones. In images, that means edges, then textures, then objects. In language, it might be characters, then words, then meaning.

Diagram of a small feed-forward neural network: three input nodes connected to a hidden layer of four nodes, which connects to two output nodes, with weighted lines between every node.
A small feed-forward network. Every connection carries a learnable weight; training adjusts all of them at once.

“Deep” learning simply means many layers. Depth is what let networks escape the limits that stalled earlier approaches — and it became practical once GPUs and backpropagation made the gradient computations tractable at scale.

04 · The headline act

From next-word prediction to chatbots

Large language models (LLMs) are the current crown jewels of this recipe. They are trained on a staggering amount of text, chopped into tokens — word fragments the model reads as plain numbers. The training objective is deceptively simple: given the tokens so far, predict the next one.

tokens in → embeddings → attention layers → next-token probabilities → sample → append → repeat

The pivotal idea is attention, introduced in the 2017 paper “Attention Is All You Need” (Vaswani et al.). Instead of reading a sentence word by word, attention lets every token look at every other token and decide what matters — which is how a model can resolve what “it” refers to across a whole paragraph, or keep track of a character over pages of a story.

Prediction alone produces a text-completion engine. Chat behavior comes afterward: fine-tuning on curated dialogues and human-feedback training (RLHF) shape the raw model into an assistant that follows instructions, declines harmful requests, and admits uncertainty — sometimes.

Why chatbots confabulate

An LLM is optimized to produce plausible continuations, not verified truths. When it lacks knowledge, the same machinery can generate fluent, confident nonsense — the “hallucination” problem. Treat outputs as drafts to verify, not answers to trust blindly.

05 · The vocabulary

Key terms, decoded

Model
The trained artifact: an architecture plus millions to billions of learned parameter values.
Parameters
The internal numbers a model adjusts during training. GPT-3 (2020) had 175 billion of them.
Training
The loop of predicting, measuring error, and updating parameters over a dataset.
Inference
Using the trained model. Every chat reply is a fresh inference pass.
Token
The chunk of text a language model reads: a word, part of a word, or punctuation.
Attention
The mechanism that lets a model weigh which earlier tokens matter for the next prediction.
Fine-tuning
Continuing training on a smaller, focused dataset to specialize or align a model.
RLHF
Reinforcement learning from human feedback: people rank outputs, and the model learns to prefer the preferred ones.
Multimodal
Models that handle more than text — images, audio, video — in a single system.
Hallucination
A confident but false output; a byproduct of optimizing for plausibility over truth.