Hub
ML
Marcelo Lorenzetti
The Mathematics Inside AI
Hub Responsible AI Accountability Mathematics Dashboard
SIMULATED DATA
Thought Leadership · Chapter 3 of 3

The Mathematics Inside AI

How language becomes mathematics — and how mathematics becomes behavior. A guided walkthrough of the transformations inside every modern AI system.

↓↓↓↓

Language is converted into numbers — embeddings that capture meaning.

Begin the Walkthrough Back to Hub
What you'll learn
~35 min
  • How language becomes numbers through tokenization and embeddings
  • How attention and neural networks turn numbers into predictions
  • How softmax converts logits into a probability distribution
  • How models learn by minimizing error with gradient descent
  • What the mathematics does — and does not — establish about AI behavior
Why it matters

Understanding the mathematics inside AI is the foundation for trusting, governing, and holding AI accountable.

What you'll be able to do

Trace a query from language to behavior through the core mathematical transformations.

SIMULATEDInteractive demonstrations use illustrative values
The Learning Journey

What AI calculations justify — and what still needs evidence and judgement

Six questions run through this chapter, in the order a project actually meets them: how information is represented, how a model learns, how it handles uncertainty, how it produces a prediction, how that prediction is evaluated, and how it is governed. Each question is answered by a mathematical foundation — and each foundation has a boundary.

01How AI represents informationVectors, matrices and transformationsHow text, images and other inputs become numerical representations.02How AI learnsDerivatives, gradients and the chain ruleHow training adjusts parameters to reduce a chosen error.03How AI handles uncertaintyConditional probability, Bayes’ rule and distributionsHow evidence changes probabilities — and why uncertainty remains.04How AI produces predictionsRegression and function compositionHow mathematical operations combine into a working model.05How we evaluate AIGuild Systems additionSampling, calibration and error decompositionHow to distinguish convincing output from dependable performance.06How we govern AIGuild Systems additionDecision theory, thresholds and bounded authorityHow evidence, consequences and permissions determine acceptable actions.

Representation, learning, uncertainty and prediction are built on established course foundations. Evaluation and governance are marked as additions — the calibration, threshold and control material an enterprise deployment needs on top of the mathematics.

Live Demo · The Disciplines in Sequence

From ingestion to retrieval — the mathematical disciplines in sequence

Follow a corpus of documents through the full data lifecycle. Each stage is a live, interactive application of a mathematical discipline: tokenization, inferential statistics, linear algebra, calculus, probability, and descriptive geometry — culminating in retrieval.

Hover the dotted terms above to see a plain-English definition.

The Mathematics of Data: Ingestion → Retrieval
Watch the mathematical disciplines act in sequence as data is ingested, transformed, and retrieved.
Stage 1 / 7 · Tokenize
1TokenizeIngestion Interactive

Raw data arrives as documents. Before any math can act, the text is split into tokens — the atomic unit of every transformation that follows. Click a document to include or exclude it from the corpus.

Corpus
Tokenize refund policy
refund policy
Language is now a bag of tokens. Every discipline that follows operates on these tokens.
Interactive Walkthrough

From language to behavior, one transformation at a time

Each stage is a fully interactive step in the AI pipeline. Move through the walkthrough to see how words become numbers, numbers become predictions, and predictions become the behavior we observe.

Live Demo

The Mathematics Inside AI

AI is not magic — it is a sequence of mathematical transformations. Follow one sentence through the math.

SIMULATED DATA
2Tokens

Input sentence: “Governance makes AI safer.”

The model cannot read text — it must first split it into tokens and assign each an identifier.

"Govern"
5143
"ance"
872
" makes"
2304
" AI"
9821
" safer"
7412
"."
13
Language becomes numbers before the model can process it.
At the core of modern AI
LANGUAGE→TOKENS→NUMBERS→VECTORS→MATRICES→ATTENTION→PROBABILITY→SELECTION→OUTPUT

Language becomes mathematics — and mathematics becomes behavior.

Interactive Notebook · Five Lessons

The arithmetic inside a neural network

Five hands-on lessons — vectors, matrices, a neuron, softmax, and gradient descent — each computed live in the browser. Drag the vectors, bend the matrix, fire the neuron, turn scores into probabilities, and walk a loss downhill.

A visual notebook

Math of AI

Five pictures of the arithmetic inside a neural network. Drag a vector, bend a matrix, fire a neuron, turn scores into probabilities, and walk a loss downhill.

Plane
-4-4-3-3-2-2-1-111223344xyrab

Copper is a. Teal is b. The dashed line is the projection of b onto a. The square marks a right angle, and r is the residual. Drag the arrow tips.

01 · Direction

Vectors and similarity

Two arrows from the origin. Length is magnitude, the sum of matching products is the dot product, and the cosine of the angle is how models score likeness.

a · b = aₓbₓ + aᵧbᵧ proj_a b = ((a · b) / (a · a)) a r = b − proj_a b

a and b are the arrows. The dot product adds the matching products. proj_a b is the orthogonal projection of b onto a. r is the residual, and the square marks a · r = 0. cos θ = (a · b) / (‖a‖ ‖b‖).

a · b = (2.40)(0.80) + (1.20)(2.20) = 1.92 + 2.64 = 4.56 proj_a b = (0.63) a = (1.52, 0.76) r = (-0.72, 1.44), a · r = 0.000 cos θ = 4.56 / (2.68 × 2.34) = 0.726

In a model, cosine similarity ranks embeddings: arrows that point the same way count as related meanings.

‖a‖
2.683

magnitude

‖b‖
2.341

magnitude

a · b
4.560

dot product

cos θ
0.726

43.5°

Cosine, orthogonal projection, the map y = Wx + b, ReLU, sigmoid, stable softmax, entropy, and each gradient step θ ← θ − η∇L are computed in the browser. Nothing is loaded from the network.
Foundations, Limits & Controls

How it works, why it fails, and what the limits require

Three ideas carry most of modern AI: representing meaning as vectors, learning by descending a gradient, and reasoning under uncertainty. Each gets the same five-part treatment — plain-English meaning, the equation with every symbol explained, a live demo, what the calculation cannot establish, and what a team should therefore test, monitor or review.

Executive view leads with implications and questions to ask. Technical view adds assumptions and implementation notes. The equation is always available either way.

Representation · Retrieval

Vector similarity

A model turns a piece of text into a list of numbers — a vector. Meaning becomes position: documents about the same subject end up pointing in the same direction. Similarity is simply the angle between two of those arrows, which is how a search or retrieval step decides what is worth showing.

Try it
D-207D-318D-114D-402D-515D-621query
Ranked by similarity (mathematics)
1Expense policy — stale draftD-207 · similarity 100.0%unverified
2Compensation band memoD-318 · similarity 99.9%restricted
3Travel policy 2024D-114 · similarity 99.4%authoritative
4Customer onboarding guideD-402 · similarity 72.4%authoritative
5Vendor security addendumD-515 · similarity 54.3%authoritative
6Facilities maintenance logD-621 · similarity -18.9%unverified
Top match
D-207
100.0% similar
After access rules
D-207
no rule intervened

Nothing intervened here, but note D-207: it ranks second while being a stale draft. Similarity measures representational closeness — not currency, truth or authority.

Optimization

Gradient descent and the learning rate

Training is a search. The loss function scores how wrong the model is, the gradient says which way is downhill, and the learning rate says how big a step to take. Too small and training never arrives; too large and it overshoots the minimum or diverges entirely.

Try it
cobalt = training data · amber = held-out data · black = fitted line
loss, log scale · 60 steps
Run status
converged
Training loss
0.0071
Held-out loss
0.0961
best 0.0059 earlier in the run

Watch the two curves separate: training loss keeps falling while held-out loss bottoms out and rises. The optimization is working exactly as specified and still makes the model worse on new documents — which is why a falling training loss is not a release decision.

Inference under uncertainty

Bayes’ rule

Bayes’ rule turns a conditional probability around. If you know how often evidence appears when a hypothesis is true, you can infer how likely the hypothesis is given the evidence. It is the reason a rare condition can produce mostly false alarms even with an accurate test.

Try it
True positives (10)False positives (50)Missed cases (0)Correctly cleared
P(a condition | flagged)
16.7%
the posterior
Flags per 1,000
60
review volume this threshold creates
False flags per true case
5.0

At 1.0% prevalence the same test yields a posterior of 16.7%: most flags are false alarms, and someone has to review them. Raise prevalence and the identical test looks far better. That is why a high score is only dependable once the base rate and the calibration behind it are known.

The Limits Library

What this does — and does not — prove

The six results below are the ones most often asked to carry more weight than they can. Keep the right-hand column beside the claim whenever a dashboard, a vendor or a pitch deck presents a number as proof.

Usable as a review checklist

Ask which column the evidence actually occupies before a deployment decision is taken.

Mathematical result
What it supports
What it does not establish
High vector similarity
Representational closeness
Factual correctness
Low training loss
Fit to the training objective
Reliable performance on new situations
High test accuracy
Performance on a particular evaluation sample
Equal performance across every subgroup or scenario
High predicted probability
A model’s numerical prediction
A dependable probability without calibration evidence
An optimal solution
Best result under specified assumptions and constraints
That the objective or constraints are appropriate
A generated explanation
An explanation that can be examined
A faithful account of the model’s internal computation
Use this panel as an audit habit rather than a warning: every result above is genuinely useful, and each one stops short of the claim it is usually asked to carry. Naming the gap is what turns a measurement into a control.
Evolution Timeline · 40 Entries

From threshold neurons to agentic systems

Forty concrete examples trace the mathematical ideas behind modern AI — from 1940s neuron models to today's tool-using agents. Historical entries illustrate established methods; near-term entries describe plausible improvements, not promised capabilities; the final three address claims without a defensible date.

Click any entry to see the concrete example and its realistic boundary.

Historical25
Near-term12
Undated3
HISTORICAL EVOLUTIONNEAR-TERMNO DATE1940s1950s1960s1970s1980s1990s2000s2010s2020s2030s
Click any dot to read the entry. Sparse early decades give way to dense 2020s systems — the visual shape of progress.
Select a dot above to see its concrete example and realistic boundary.
Historical evolution
Established methods · 25 entries
Realistic near-term enhancements
Plausible improvements · 12 entries
Without a defensible date
Hypothetical claims · 3 entries
One Example, End to End

A document-routing assistant, from vector to governance

A simulated document-routing assistant sorts incoming correspondence into categories and decides which items can be handled automatically. Follow it through seven steps. Cobalt marks the mathematical operation; amber marks the business rule, threshold or control that surrounds it. The mathematics never decides on its own — it supplies a number that a rule acts on.

Simulated example
Mathematical model
Business rule & control
Step 1 · the mathematics

The document is tokenized, and an embedding model maps it to a vector.

the model ends here
Step 1 · the business rule

Nothing leaves the model here — but choosing which text is included (and excluded) is a business decision.

Steps 1–4 are computation: representation, ranking, prediction and measurement. From step 5 onward the decisions belong to people — the threshold, the review path and the monitoring obligation are choices, not outputs of the model.
Adaptation, Corrections & Sources

Where the material comes from, and what we corrected

The course material was used as a foundation for original explanations, demonstrations and diagrams — not reproduced. Two conditions are stated explicitly here because they are the ones most often compressed into a misleading shorthand.

Rank

Rank is the number of linearly independent columns (equivalently, rows) of a matrix — not a count of non-zero entries.

Rank is bounded by min(rows, columns) and equals the number of non-zero singular values. A matrix is invertible only when it is square and full rank; a rectangular matrix can be full rank for its shape and still have no inverse. We state the rank conditions explicitly wherever they matter.

Eigendecomposition

An eigendecomposition A = QΛQ⁻¹ requires a square matrix that has a full set of linearly independent eigenvectors.

Not every square matrix is diagonalizable, and only symmetric real matrices are guaranteed an orthonormal decomposition A = QΛQᵀ. For a general matrix the reliable construction is the singular value decomposition A = UΣVᵀ, which exists for any shape. The dimensionality reduction demonstrated in this chapter uses symmetric covariance and Gram matrices, where the orthonormal case does hold.

Attribution

The sequence of topics on this page — sets and discrete mathematics, calculus, linear algebra and probability — follows the structure of an open AI mathematics course. All explanations, diagrams, interactive demonstrations and enterprise examples here are original to Guild Systems.

Adapted from open course material: Introduction to AI — Mathematics unit (ColumbiaX, CU.OC.AI001, 2024). Referenced for topic structure only. No affiliation with, sponsorship by, or endorsement from Columbia University or ColumbiaX is implied.

Finding and vetting further material
  • For statistics and calibration: require held-out samples, report confidence intervals, and check calibration per population before using scores as probabilities.
  • For linear algebra: prefer the singular value decomposition unless symmetry is guaranteed.
  • For probability: state priors explicitly, because the posterior is only as sound as the base rate behind it.

Judge a source by who published it and whether the assumptions are stated: course material from a university is usually more reliable than an unattributed blog post, and a result without its assumptions is not evidence.

Check your understanding
  1. 01What is the first transformation when turning language into something a model can use?

  2. 02What does the softmax function do?

  3. 03What does gradient descent minimize during learning?

Executive Summary

Three takeaways

The chapter, distilled for the reader in a hurry.

1Takeaway 1

Language becomes mathematics

Every AI system begins by converting text into tokens and vectors — meaning becomes geometry a computer can compute.

2Takeaway 2

Each discipline plays a distinct role

Statistics estimates, linear algebra represents, calculus optimizes, probability scores, geometry visualizes — the pipeline is a sequence of mathematical disciplines.

3Takeaway 3

Understanding the math enables trust

Knowing how predictions are made — and retrieved, audited, and explained — is the foundation the governance and accountability chapters build on.

Previous Chapter
Chapter 2
AI Liability & Accountability
Next Chapter
Chapter 1
Responsible AI as Competitive Advantage
The argument continues

Mathematics is the foundation — trust and accountability are the practice

Understanding how AI works internally is the beginning. Chapters 1 and 2 show how organizations turn that understanding into trustworthy, accountable practice.

Back to Thought Leadership Hub
Marcelo Lorenzetti
Author & Speaker · Guild Systems (professional affiliation)
Evergreen educational asset · Simulated demonstration data