Part IV · Ch. 21 — So… What Is AI/ML?

Part IV · Chapter 21 of 21

So… What Is AI/ML?

Zooming out: LLMs are one species in a big family


What did we build?

We built a large language model. Given tokens so far, it outputs a distribution over possible next tokens:

$$p(\text{next token} \mid \text{context})$$

In words: given the run of tokens so far, hand back the probability of every token that could come next. That distribution is the LLM's entire output.

Sampling picks a continuation. Training adjusts the function that produces those probabilities. Everything from embeddings to attention helps shape that function.

The same idea in every chapter

Function-fitting connects our chapters: choose a flexible function, measure its errors with a loss, then improve its parameters. For a differentiable model, our update was:

$$\theta \leftarrow \theta - \eta\,\nabla L$$

In words: take every number in the model, written $\theta$ (theta, all the parameters), and nudge it a small step of size $\eta$ (eta, the learning rate) in the direction that most reduces the loss. That direction is $\nabla L$, the gradient of the loss, and we walk against it. Then do it again.

Worked example: the same update, a smaller model

Let a line predict $y=wx$, with $w=2$ and loss derivative 4. At learning rate 0.1, gradient descent gives $w_{\text{new}}=2-0.1\times4=1.6$. The transformer updates many parameters by the same rule.

Other learning methods fit functions without gradients. A decision tree, for example, selects splits in the data. We should carry the general idea without insisting that every model uses our optimizer.

Four nested rings

Artificial intelligence (AI) includes hand-written rules and learned systems. Machine learning (ML) is the learning part. Deep learning (DL) uses layered neural networks. Our LLM belongs inside all three; the transformer is its architecture.

Four indented bands place our transformer LLM inside deep learning, machine learning, and artificial intelligence.
Our LLM sits inside three broader fields.

Three ways a machine can learn

Where the learning signal comes from
ApproachSignalExample
Supervised learningTargets paired with inputsClassification: spam or legitimate mail; regression: house price
Unsupervised learningStructure in unlabeled dataCluster customers or compress measurements
Reinforcement learning (RL)Rewards for actionsGame play or robot control

Self-supervised learning supplies its own targets. In language pretraining, the next token is already in the text. This provides a supervised prediction objective without someone labeling every position. Terminology sometimes places self-supervision within the broader unsupervised family.

Worked example: find the free labels

For “the cat sat,” two training pairs are “the” → “cat” and “the cat” → “sat.” The text supplies both answers. At inference we no longer have the next answer; we predict it.

Assistant training can add supervised demonstrations, then preferences. RLHF uses a reward signal; DPO fits preferences directly without a reinforcement-learning rollout loop. These are different ways to improve behavior, not mandatory stages for every LLM.

Match the tool to the shape of the data

Useful starting points, then compare on held-out data
DataCandidate familyUseful structure
Sequences: text, audioTransformers; recurrent networksOrder and relationships across positions
Grids: imagesConvolutional neural network (CNN); vision transformerRepeated local patterns
Graphs: roads, social or communications linksGraph neural network (GNN)Neighbors joined by edges
Tables: customers, measurementsClassical methodsFeatures in columns; trees are useful baselines
Data shape suggests a family; evaluation decides.
Data shapeCandidate familySister-book chapter
Sequence: text, audio; order mattersTransformerRemembering Machines
Grid: images; neighbors matterCNNSeeing Machines
Graph: linked entities; connections matterGNNNetworks of Relationships; link analysis
Table: rows and columnsTrees, forests, boosting; often strong hereThe Classical Toolbox

These are starting hypotheses. Dataset size, accuracy, interpretability, latency, and cost decide the useful model. CNNs and transformers can both process images; deep networks and trees can both process tables.

Your toolkit already travels

Carry the math; check each model's details
ToolOther jobs
Vectors and embeddingsRepresent image patches, graph nodes, or recommended items
Dot productsLinear scores, similarity, and some attention or kernel methods
MatricesLearned transformations in many neural networks
Loss, gradients, backpropagationTrain differentiable models for images, audio, or control
SoftmaxTurn competing category scores into probabilities

See it move

Watch (1:35): what to notice. Four rings are drawn from the outside in: AI, then machine learning, then deep learning, then this book’s model, with one example dropped into each. The three ways to learn are set side by side, and your own toolkit of vectors, dot products, matrices, loss and descent travels along an arrow into the image and speech rings.

Why the LLM cares

An LLM is one member of a larger field. We can inspect its objective, architecture, data, and deployment costs using the same questions we ask of other models. Knowing its arithmetic helps us choose when it fits the problem.

Where you're headed

AI/ML from the Ground Up widens the view: line-fitting, neurons, classical methods, CNNs, RNNs, GNNs, generative models, and reinforcement learning. Review its Math Toolkit as needed, then explore trees and forests, vision, sequences, graphs, or choosing a tool.

If we have already walked that route, How AI Makes Images points the same math at pictures. Its model learns to predict noise, and attention connects image generation to a text prompt. We arrive with useful tools.

What you now know

  • Our LLM belongs to AI, machine learning, and deep learning.
  • Training fits a function to an objective.
  • Learning signals include labels, data-derived targets, structure, and rewards.
  • Data shape suggests model families; evaluation chooses between them.
  • Vectors, matrices, losses, and gradients travel beyond language models.

Keep going

We can now compute attention by hand, read a loss curve, and explain where an answer comes from. Choose a question on either sister site and keep building.