AI-101 · Lesson 4 of 5 · 32 min
Today's AI systems and their limits
The AI systems people use today, chat assistants, coding tools, image generators, translation apps, voice assistants, are built on the ideas of Lesson 3, scaled up enormously. A modern language model is a neural network with billions or trillions of parameters, trained by gradient descent on a large fraction of the text humanity has written, then refined with human feedback. The result can be astonishingly capable and, in places, surprisingly unreliable.
This chapter explains how large language models work, how they are trained and turned into assistants and agents, what other kinds of AI systems are in wide use, how much computation they take, and where they fail. Using AI well, and building it responsibly, depends on understanding both sides.
Large language models
Tokens
Language models do not read letters or whole words. They read tokens: chunks of text from a fixed vocabulary of tens of thousands to a few hundred thousand pieces. Common words are single tokens; rarer words are split into pieces ("electro", "cardi", "ogram"). In English, a token averages roughly three-quarters of a word, so 1000 tokens is about 750 words. Prices, speed limits and memory limits for language models are all measured in tokens.
Predicting the next token
At its core, a language model does one thing: given a sequence of tokens, it outputs a probability for every possible next token. To generate text it picks a token, appends it, and repeats. The network computes raw scores called logits, and a function called softmax turns them into probabilities:
Here \(z_i\) is the score for token \(i\) and \(\tau\) is the temperature, a setting that controls randomness. Low temperature makes the most likely token dominate; high temperature spreads probability more evenly, giving more varied (and more error-prone) text.
Worked problem
Softmax and temperature
After "The transformer was rated at 2500", a model gives three candidate next tokens the scores \(z = (2.0, 1.0, 0.1)\) for "kVA", "kW" and "volts". Find the probabilities at temperatures 1 and 0.5.
Show solution
- \(\tau = 1\): \(e^{2.0} = 7.39\), \(e^{1.0} = 2.72\), \(e^{0.1} = 1.11\); sum 11.21. Probabilities 0.659, 0.242, 0.099.
- \(\tau = 0.5\): divide scores by 0.5: (4, 2, 0.2); \(e^4 = 54.6\), \(e^2 = 7.39\), \(e^{0.2} = 1.22\); sum 63.2. Probabilities 0.864, 0.117, 0.019.
Answer: At temperature 1: 66%, 24%, 10%. At 0.5: 86%, 12%, 2%. Lower temperature makes the output more predictable. Note that the model never "knows" the answer; it produces probabilities, and a 10% chance of a wrong unit is a 10% chance of a wrong document
Predicting the next token sounds trivial, but doing it well across all kinds of text requires a model to capture grammar, facts, styles, arithmetic, programming languages and patterns of reasoning, because all of these help predict what comes next. That is the bet behind language models, and it has paid off far beyond what most researchers expected.
The transformer inside
Nearly all language models use the transformer architecture (Lesson 2). Each token is turned into a vector of numbers (an embedding). The model then passes these vectors through dozens of layers. In each layer, an attention mechanism lets every token gather information from the earlier tokens most relevant to it (in "the pump that the technician replaced was noisy", "was noisy" needs to attend to "pump", not "technician"), and a feed-forward network processes each token further. The final layer produces the logits for the next token. The amount of text a model can attend to at once is its context window, now commonly hundreds of thousands of tokens for leading models.
From raw model to assistant
A model trained only to predict internet text will continue a question with more questions, or produce whatever is statistically likely, including falsehoods and toxic text. Turning it into a helpful assistant takes several stages.
- Pretraining: self-supervised next-token prediction on trillions of tokens of text (and often images, audio and code). This is where nearly all the computation goes and where the model acquires its knowledge and skills.
- Supervised fine-tuning: further training on curated examples of good responses to instructions, often written by people.
- Learning from feedback: people (or other models guided by written principles) compare pairs of responses, and the model is trained with reinforcement learning to produce responses that are judged better: more helpful, more honest, less harmful. This is commonly called reinforcement learning from human feedback (RLHF).
- Reasoning training: many recent models are also trained with reinforcement learning on problems with checkable answers, such as mathematics and code, so they learn to work through problems step by step before answering.
Deployed assistants are usually connected to tools. Retrieval-augmented generation (RAG) searches a document collection or the web and gives the model the relevant passages, so answers can be grounded in sources rather than memory. Tool use lets the model run code, call a calculator, query a database or operate software. An AI agent is a model that plans and carries out multi-step tasks with such tools, observing the results and deciding what to do next: the agent loop of Lesson 1, with a language model as the decision-maker.
How much computation?
A useful rule of thumb estimates training compute for a transformer: about 6 floating-point operations (FLOP) per parameter per training token.
where \(N\) is the number of parameters and \(D\) the number of training tokens. Generating each token afterwards costs about \(2N\) FLOP.
Worked problem
Training a 70-billion-parameter model
A model with \(N = 7 \times 10^{10}\) parameters is trained on \(D = 1.5 \times 10^{13}\) tokens. Estimate the training compute. How long would it take on 10,000 GPUs, each capable of \(10^{15}\) FLOP per second, running at 40% average utilization? If each GPU and its share of the server draws 1.2 kW and the data center's PUE is 1.3, how much electricity does the run use?
Show solution
- \(C = 6 \times 7 \times 10^{10} \times 1.5 \times 10^{13} = 6.3 \times 10^{24}\) FLOP.
- Effective speed = \(10^4 \times 10^{15} \times 0.4 = 4 \times 10^{18}\) FLOP/s. Time = \(6.3 \times 10^{24}/4 \times 10^{18} = 1.58 \times 10^6\) s ≈ 18.2 days (437.5 hours).
- Power = 10,000 × 1.2 kW × 1.3 = 15.6 MW. Energy = 15.6 MW × 437.5 h = 6,825 MWh.
Answer: About \(6 \times 10^{24}\) FLOP, 18 days and 6,800 MWh, roughly the electricity hundreds of homes use in a year. Frontier models today are trained with considerably more compute than this. Regulators have started to use compute as a threshold: the EU AI Act presumes general-purpose models trained with more than \(10^{25}\) FLOP pose systemic risk, and California's SB 53 applies to models trained with more than \(10^{26}\)
Inference (using a trained model) also adds up. Serving millions of users, each generating thousands of tokens a day, keeps large data centers busy around the clock, and reasoning models that "think" at length before answering generate many more tokens per question. This is the demand driving the data center boom described in DCE-200.
Beyond language models
Language models attract the headlines, but many other AI systems are in daily use:
- Image, audio and video generation, mostly with diffusion models, which learn to turn random noise step by step into a picture or sound that matches a description.
- Speech recognition and synthesis, now accurate enough for live captioning and natural-sounding voices.
- Computer vision for medical imaging, manufacturing inspection, agriculture, security and self-driving vehicles; robotaxis now carry paying passengers without a safety driver in several cities.
- Recommendation systems that decide what billions of people see in feeds, stores and streaming services; probably the most economically important AI of the past decade.
- Scientific AI such as AlphaFold, which has predicted structures for hundreds of millions of proteins, and models for weather forecasting, materials and drug discovery.
- Forecasting and optimization in industry: predicting electricity demand, scheduling maintenance, routing deliveries, controlling data center cooling.
Where today's systems fail
Every engineer using AI must know its failure modes. These are not rare glitches; they follow from how the systems are built.
Hallucination
Language models generate plausible text, not verified facts. When a model lacks knowledge, it may still produce a confident, fluent, specific answer that is wrong: a fake citation, an invented code clause, a wrong figure. These are called hallucinations (or confabulations). Retrieval with sources, tool use and training for honesty reduce them but do not eliminate them.
Worked problem
Is the model's confidence trustworthy?
An engineer collects 200 technical questions on which a model said it was "90% confident". It answered 150 correctly. Is the model well calibrated on these questions?
Show solution
- A well-calibrated model that says 90% should be right about 90% of the time: about 180 of 200.
- Observed accuracy = 150/200 = 75%.
Answer: No: it is overconfident, right 75% of the time when claiming 90%. Stated confidence should be checked against measured accuracy before anyone relies on it
Errors compound in long tasks
Agents perform many steps in a row, and a mistake at any step can derail the task.
Worked problem
Reliability of a multi-step agent
An agent completes each step of a task correctly with probability 0.98, independently. What is the probability that a 20-step task succeeds with no errors? What per-step reliability is needed for 90% success?
Show solution
- \(0.98^{20} = 0.668\): about 67%.
- For 90%: \(r^{20} = 0.9\), so \(r = 0.9^{1/20} = 0.9947\).
Answer: Only about two-thirds of 20-step tasks succeed at 98% per step; 90% success requires about 99.5% per step. This is why agents are designed to check their own work, recover from errors and ask for human review at important points
Other limits
- Brittleness and distribution shift: models can fail when inputs differ from their training data: a vision system trained in sunny weather meeting snow, or a model asked about events after its training cutoff.
- Adversarial inputs: small, deliberately crafted changes, such as stickers on a stop sign or hidden instructions in a web page (prompt injection), can make a model behave badly.
- Sensitivity to phrasing: rewording a question can change the answer.
- Bias: models learn patterns, including unfair ones, from their training data (Lesson 5).
- Opacity: it is hard to explain why a large network produced a particular output; interpretability research is still young (AI-430).
- Cost and energy: training and serving large models takes enormous computation, electricity and, in some data centers, water.
Using AI well
For engineers, a few habits follow from all of this:
- Treat AI output as a draft from a capable but unreliable assistant. Verify facts, figures and code before relying on them, especially in safety-critical work.
- Ground answers in sources: ask for citations and check them, or use retrieval over trusted documents.
- Use tools for exact work: calculators, solvers and tests, not the model's mental arithmetic.
- Measure performance on your own task with your own test cases, rather than trusting general benchmarks.
- Keep humans responsible for decisions with serious consequences. A licensed engineer who signs a drawing is responsible for it, whatever tools were used to produce it.
- Protect confidential data: know where the text you send to an AI service goes and how it is stored.
Common mistakes
MistakeAssuming a fluent answer is a correct answer.
InsteadFluency is what language models are trained for; correctness must be checked.
MistakeTrusting a model's stated confidence.
InsteadCheck calibration against measured accuracy on representative questions.
MistakeThinking a language model looks things up in a database.
InsteadUnless connected to retrieval or tools, it generates text from patterns stored in its parameters.
MistakeEstimating an agent's reliability from a single step.
InsteadErrors compound: per-step reliability r gives about rⁿ for n steps.
MistakeIgnoring the cost of inference.
InsteadServing a model to many users can use more total computation and energy over time than training it.
Summary and key terms
- Language models read tokens (about 0.75 English words each) and output a probability for the next token; softmax with temperature τ turns scores into probabilities.
- Transformers use embeddings, attention and feed-forward layers; the context window is how much text they can attend to.
- Assistants are built by pretraining, supervised fine-tuning, learning from feedback (RLHF) and often reasoning training; retrieval, tools and agent loops extend them.
- Training compute ≈ 6ND FLOP; generation ≈ 2N FLOP per token. Frontier training compute has grown about 5× per year since 2020.
- Other widely used AI: diffusion models, speech, computer vision, recommendation, scientific AI, forecasting and optimization.
- Failure modes: hallucination, overconfidence, compounding errors in agents, distribution shift, adversarial inputs and prompt injection, phrasing sensitivity, bias, opacity, cost.
- Use AI as a draft: verify, ground in sources, use exact tools, measure on your own task, and keep humans responsible.
- Token
- A chunk of text from a model's vocabulary; the unit language models read and write.
- Large language model (LLM)
- A large neural network trained to predict the next token on vast amounts of text.
- Softmax
- A function that converts scores into probabilities that sum to 1.
- Temperature
- A setting that controls how random a model's token choices are.
- Context window
- The maximum number of tokens a model can take into account at once.
- Pretraining
- The initial large-scale self-supervised training of a model on next-token prediction.
- Fine-tuning
- Further training of a pretrained model on a narrower dataset or task.
- RLHF
- Reinforcement learning from human feedback: training a model toward responses people judge better.
- Retrieval-augmented generation (RAG)
- Supplying a model with relevant retrieved documents so it can ground its answer.
- AI agent
- A system in which a model plans and carries out multi-step tasks using tools.
- FLOP
- Floating-point operation; the unit used to measure computation.
- Hallucination
- A fluent, confident output that is false or unsupported.
- Calibration
- Agreement between a model's stated confidence and its actual accuracy.
- Prompt injection
- Hidden or malicious instructions in content a model reads that try to change its behavior.
- Diffusion model
- A generative model that turns noise into an image or sound step by step.
Practice problems
Work each problem on paper first, then reveal the answer to check.
About how many tokens is a 3000-word English report?
Show answer
3000 ÷ 0.75 = 4000 tokens.
Scores (3, 1) for two tokens. Find the probabilities at temperature 1.
Show answer
e³ = 20.09, e¹ = 2.72; probabilities 20.09/22.81 = 0.881 and 0.119.
What happens to the probabilities in the previous question as temperature approaches 0? As it grows very large?
Show answer
Near 0 the top token gets probability near 1 (greedy choice); very large temperature makes the two nearly equal (0.5 each).
Estimate the training compute for a 7-billion-parameter model trained on 2 trillion tokens.
Show answer
6 × 7 × 10⁹ × 2 × 10¹² = 8.4 × 10²² FLOP.
How many FLOP does that 7-billion-parameter model need to generate a 500-token answer?
Show answer
2 × 7 × 10⁹ × 500 = 7 × 10¹² FLOP.
A model trained with 6.3 × 10²⁴ FLOP: does it exceed the EU AI Act's systemic-risk presumption threshold? California SB 53's threshold?
Show answer
Neither: it is below 10²⁵ and well below 10²⁶.
Explain why a language model might invent a citation.
Show answer
It generates text that is statistically plausible; a realistic-looking reference fits the pattern even when no such source exists in its knowledge.
An agent must complete 50 steps. With 99.5% reliability per step, what is the chance of an error-free run?
Show answer
0.995⁵⁰ = 0.778, about 78%.
Give two ways to reduce hallucinations in an engineering assistant.
Show answer
Retrieval over trusted documents with citations; requiring tool use for calculations and code execution; asking the model to say when it does not know; human review.
What is prompt injection, and why does it matter for AI agents that browse the web?
Show answer
Hidden instructions in content the model reads that try to change its behavior. An agent reading web pages could be tricked into leaking data or taking harmful actions, so agents need safeguards and limited permissions.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.