Education

How artificial intelligence actually works

From a 1950s thought experiment to ChatGPT — the whole story of AI, machine learning and n-grams, told so anyone can get it. Click the timeline, train a tiny brain, and watch a computer predict the next word. No maths degree required.

  • History of AI
  • Machine learning
  • How machines learn
  • Neural networks
  • N-grams & language models

Everything below is interactive — scrub the timeline, drag the sliders, and make a real model finish your sentence.

Start here

So… what is artificial intelligence, really?

Artificial intelligence is just getting computers to do things that normally need human smarts — recognising a face, understanding a sentence, winning a game, suggesting the next word you'll type. For decades we tried to do that by writing down every rule by hand. It barely worked. The breakthrough was letting the computer figure out the rules by itself, from mountains of examples. That idea is machine learning, and it's the engine under almost every "AI" you hear about today.

Old way: hand-written rules

Humans spell out every "if this, then that". Fine for simple things, hopeless for messy reality like language or vision.

New way: learn from examples

Show the machine thousands of examples and let it adjust itself until it gets them right. It discovers the rules nobody could write down.

Today: predict the next thing

Modern AI is mostly a giant prediction machine — guess the next word, the next pixel, the next move — trained on the whole internet.

This guide walks the whole journey, in order: where AI came from, how a machine learns, what a neural network is, and the deceptively simple trick — n-grams — that still explains how ChatGPT-style models "talk". Each stop has something to click.

The epic backstory

70+ years of AI, in one scrubbable timeline

AI isn't new — it's older than the moon landing. It boomed, crashed (twice!), and roared back. Tap any year to see what happened, or press play and ride the whole story from Turing to ChatGPT.

The "AI winters"

Twice, AI over-promised and under-delivered — funding froze and the whole field went quiet (mid-1970s and late-1980s). Each winter ended when a new idea — better algorithms, more data, faster chips — thawed it out. Today's boom is the spring after the second winter.

The big shift

Machine learning: stop coding rules, start showing examples

Imagine writing a program to tell cats from dogs by listing rules: "pointy ears, whiskers, …". You'd give up fast. Machine learning flips it: you show the computer thousands of labelled photos and it learns the difference itself, tuning millions of tiny internal numbers until it's usually right. Flip the switch below to feel the difference.

The three classic flavours of learning

Almost all machine learning is one of these three. Hover or tap a card.

Supervised

Learn from examples that come with the right answer (the "label"). The classic workhorse.

Like: spam vs not-spam from emails you've already sorted.

Unsupervised

No labels — the machine finds hidden patterns and groups by itself.

Like: a shop clustering customers into "types" nobody named in advance.

Reinforcement

Learn by trial and error, chasing rewards and avoiding penalties.

Like: a program mastering a game by playing it a million times.
The learning loop

How does a machine actually "learn"? It rolls downhill.

Training is a loop: the model makes a guess, we measure how wrong it was (the "loss"), and we nudge its internal numbers to be a little less wrong. Repeat thousands of times. Picture the loss as a valley — the model is a ball trying to roll to the bottom, where it's least wrong. That roll is called gradient descent.

Drag the learning rate (how big each step is) and press Train. Too small and it crawls; too big and it bounces and overshoots; just right and it settles into the valley.

Step0
Loss (wrongness)—
Learning rate (step size) 0.10

That's the whole secret of training, scaled up: a model can have billions of those internal numbers (called weights), and gradient descent quietly nudges every single one, over and over, until the predictions are good.

The brain analogy

Neural networks: lots of tiny decisions stacked up

A neural network is built from artificial neurons, loosely inspired by brain cells. Each neuron is dead simple: it takes some inputs, multiplies each by a weight (how much that input matters), adds them up, and "fires" if the total clears a threshold. The magic isn't one neuron — it's millions of them, and the weights are exactly what gradient descent learns.

Meet one neuron deciding "should I go outside?". Flip the inputs on/off, drag how much each one matters, and watch the neuron fire — or not.

Firing threshold 1.0

Stack them into layers

Wire the outputs of one row of neurons into the next. Early layers spot simple things (an edge, a curve); later layers combine those into bigger ideas (an eye, a face). Information flows forward, layer by layer.

"Deep" just means many layers

Deep learning is nothing mystical — it's a neural network with many layers stacked deep. More layers can capture more abstract patterns, which is why deep networks cracked vision and language once we had the data and the chips to train them.

The star of the show

N-grams: how a computer guesses the next word

Before neural language models, there were n-grams — and they're the clearest way to feel how a machine writes. The idea: to predict the next word, just look at the last few words and ask "in real text, what usually came next?". Count it up across a whole book and you can finish sentences. Your phone's keyboard does exactly this.

Build a baby language model — live

We trained a real model on the little story below by counting which words follow which. Pick how much context it gets, then click the predicted words (or hit autopilot) to write a sentence. Watch how bigger context = more coherent.

Most likely next word — click one to add it

Why bigger n is better… and harder

A unigram ignores context and picks common words — gibberish. A bigram looks 1 word back; a trigram, 2 words back — more context, more coherent. But each extra word of context needs far more text to have seen every combination. That trade-off (coherence vs. data) is the n-gram's whole life.

You use this every day

The word suggestions above your phone keyboard are basically an n-gram model trained on what people type. It's why it nails "see you later" but fumbles a sentence with a long-range twist — it only remembers the last word or two.

Quick game: can you beat the model?

Here's a sentence with the last word hidden. Guess it — then see what the bigram model predicted.

The leap

From counting words to ChatGPT

N-grams hit a wall: they only see a couple of words back, and they have no idea what words mean — "king" and "queen" are just different strings to them. Modern language models fixed both problems. First, text is chopped into tokens and turned into numbers a network can chew on.

Type anything — watch it get split into tokens (the chunks a model actually reads). Notice it often splits inside long or rare words. (Simplified for illustration.)

Each chunk becomes a number (an ID). Real models like GPT have a vocabulary of ~50,000–100,000 tokens, and a rule of thumb is ~4 characters ≈ 1 token.

The 2017 breakthrough: attention

The Transformer ("Attention Is All You Need", 2017) let a model weigh every earlier word at once and learn which ones matter — however far back. No more "last two words only". That's how a model keeps track of who "she" refers to three sentences ago.

Words become meaning

Instead of treating words as strings, the network learns a vector (a list of numbers) for each one, so related words sit near each other. Train this on much of the internet, at enormous scale, and you get a model that can chat, summarise and code.

Want to go one level deeper?

Those word-vectors, semantic search and how AI answers over your own documents are the whole story of our companion guide. Open “RAG & Vectors” →

Where we are now

AI today: amazing, useful, and not magic

Narrow, not general

Every AI today is narrow — brilliant at one thing (chat, chess, images). A single system as flexible as a human (AGI) doesn't exist yet.

It can be confidently wrong

A model predicts plausible words, not verified truth, so it can "hallucinate" — sound sure while being wrong. Always double-check.

It mirrors its data

A model learns from human text, so it can absorb our biases and mistakes. Good AI needs careful data and human oversight.

A tool for people

It already drafts text, translates, codes, spots tumours and powers your maps. At its best it's a power tool that makes humans faster — not a replacement for thinking.

In one breath

The whole journey, recapped

  1. AI = making computers do things that need human-like smarts.
  2. The big shift: stop hand-writing rules, start learning from examples — that's machine learning.
  3. Learning = guess, measure the error, nudge the numbers, repeat — rolling downhill via gradient descent.
  4. Neural networks stack millions of tiny "weigh-the-inputs-and-fire" neurons; deep = many layers.
  5. N-grams predict the next word by counting what usually follows — simple, and the soul of language models.
  6. Transformers (2017) added attention and meaning, scaling n-grams' idea into ChatGPT.
  7. Today's AI is powerful but narrow — it predicts, it doesn't truly "understand". Use it, and check it.
About this guide

A free, hands-on introduction to how AI works

This page explains artificial intelligence from the ground up for people with no background in maths or programming: students, teachers, parents, managers, and anyone who uses ChatGPT and wonders what is going on inside. It follows the story in order, from the first artificial neuron in 1943 to today's large language models.

Instead of long definitions, every idea comes with a small demo you can click or drag. You watch a ball roll down a loss curve to see how a model learns, you set the weights of a single neuron, and you write a sentence with a real n-gram model that counts words from a short story. The demos run in your browser and need no account.

What you can try on this page

  • History timeline: 18 milestones from 1943 to today, coloured by era, with a play button.
  • Rules versus learning: switch between a spam filter built from hand-written rules and one that learns from examples.
  • Gradient descent: pick a learning rate and watch training crawl, settle, overshoot or blow up.
  • An artificial neuron: three inputs, adjustable weights and a firing threshold.
  • A live n-gram model: unigram, bigram and trigram predictions with probability bars and an autopilot.
  • A guess game: finish a proverb and compare your answer with the model's.
  • A tokenizer: type any text and see it split into tokens, with character and token counts.
Step by step

How to use this guide

  1. Scrub the AI history timeline

    Tap a year or press play to walk through 18 milestones, from the first artificial neuron in 1943 through both AI winters to ChatGPT.

  2. Compare rules with learning

    Flip the switch in the machine learning section to see why hand-written rules break down and learning from examples does not.

  3. Train the gradient descent ball

    Drag the learning rate, press Train and watch the ball roll to the bottom of the loss curve, or bounce out when the steps are too big.

  4. Make the neuron fire

    Switch the inputs on and off, change how much each one matters and move the threshold until the neuron decides to go outside.

  5. Write a sentence with the n-gram model

    Choose unigram, bigram or trigram, click the predicted words or press Autopilot, then try the guess game and the tokenizer.

Good to know

Tips before you start

  • The demos are simplified on purpose. The n-gram model learns from one short story, the neuron has three inputs and the tokenizer only imitates real ones. The ideas match real models, the scale does not.
  • Use the topic bar under the header to jump straight to a section, for example N-grams if you only want to see how next-word prediction works.
  • Switch between English and Czech with the language button in the top bar. The n-gram demo then rebuilds itself from a Czech story.
Questions

Frequently asked questions

Do I need maths or programming to follow this guide?

No. Every idea is shown with a demo you click or drag, and the few numbers on the page are explained in plain words. If you can use a slider, you can follow it.

What is the difference between AI, machine learning and deep learning?

AI is the broad goal of making computers do things that need human-like smarts. Machine learning is the main way to get there today: the computer learns the rules from examples instead of being given them. Deep learning is machine learning with neural networks that have many layers.

What is gradient descent?

It is how most models learn. The model measures how wrong it is (the loss), works out which direction makes the loss smaller and takes a small step that way, again and again. The learning rate sets the step size: in the demo a tiny rate crawls, a large one overshoots, and above 1.0 the error grows instead of shrinking.

What is an n-gram model?

An n-gram model predicts the next word from the last few words by counting what followed them in its training text. A bigram looks one word back, a trigram two. The model on this page is built in your browser from a short story, so you can see exactly where its predictions come from.

Is ChatGPT just a big n-gram model?

No, but it does the same basic job: predicting the next token. An n-gram only sees a couple of words and treats words as plain strings. A transformer such as GPT uses attention to weigh every earlier token and learns vectors that capture meaning, which is why it stays coherent over long text.

What is a token?

A token is a chunk of text a language model actually reads: a whole word, part of a word or a punctuation mark. Each token becomes a number. The tokenizer on this page is a simplified illustration, so real tokenizers such as GPT's split text differently.

Why does AI sometimes make things up?

A language model is trained to produce likely text, not to check facts, so it can write a fluent answer that is wrong. This is called hallucination. Check important answers against a reliable source.

Is anything I type in the demos sent to a server?

No. All the demos, including the tokenizer, run as JavaScript in your browser, and nothing you type is sent anywhere. The guide itself only remembers your language choice, in your browser's local storage.

Is the guide free, and does it work on a phone?

Yes. It is free, needs no account or sign-up, and every demo works with touch on a phone as well as with a mouse on a computer. It is available in English and Czech.