What Is a Model in AI?

What Is a Model in AI?

A plain-English guide to the most important word in artificial intelligence: what a model is, how it learns from data, what is stored inside it, how we judge it, and how it is built, deployed, secured, and watched in the real world.

Read any news story about artificial intelligence and one word keeps appearing: model. Companies release a new model, researchers train a model, a bank deploys a fraud model, a phone runs a model that recognizes your face. The word is used so casually that it can feel like everyone else understood it on day one while you are still guessing.

This guide fixes that. You will learn what an AI model really is, how it differs from an algorithm or an ordinary program, and how it learns patterns from examples. You will see what is physically stored inside one, the main families of models, and how to tell whether a model is good or merely memorizing. Then the guide follows a model through its whole life: preparing data, training, serving predictions to millions of users, defending it from attackers, and watching it for silent decay. Each idea comes with an everyday comparison and, where it helps, a real example from a company you know.

1What Is a Model in AI?

Start with the simplest honest answer, then build on it.

The definition in one sentence

An AI model is a mathematical description of a pattern, learned from data, that takes some input and produces a useful output such as a prediction, a decision, a label, or a piece of generated content. The model is what you are left with after learning is finished. It is the thing you can save to a file, copy to a server, and ask questions.

Three parts every model has

Part 1

An input

The information you give it: a photo, a sentence, a row of customer details, a sound clip, or the last month of sales figures.

Part 2

Learned numbers

Inside the model sits a collection of numbers, called parameters, that were tuned during training. They hold everything the model has learned about the pattern.

Part 3

An output

The answer it returns: “this email is spam”, “this house is worth this much”, “the next word is probably this one”, or a brand-new image.

Everyday analogy

Think of an experienced mango seller who can tell at a glance whether a mango is ripe. Nobody gave them a rulebook. They handled thousands of mangoes, noticed how color, smell, and softness related to taste, and gradually built an instinct. That instinct is their model. It lives in their head, it takes a mango as input, and it returns “ripe” or “not yet” as output. An AI model is that instinct, written down as numbers.

Why we need models at all

Some problems cannot be solved by writing rules by hand. Try writing exact instructions for recognizing a cat in a photograph: pointy ears, whiskers, fur, but also cats curled up, cats half hidden behind a sofa, cats in bad light. The rules multiply without end. Instead of writing the rules, we show a learning system a large number of labeled examples and let it find the pattern itself. The result of that process is the model.

1956
year the term “artificial intelligence” was coined at a workshop at Dartmouth
2012
year AlexNet’s image-recognition win started the deep learning boom
175 billion
parameters in GPT-3, one of the largest models of its time

Model, algorithm, program, and data: untangling the words

These four words get mixed up constantly. They are related, but each means something different.

WordWhat it isKitchen comparison
DataThe examples the system learns fromThe ingredients and the notes from many past meals
Learning algorithmThe step-by-step procedure that adjusts the numbers to fit the dataThe cooking method: taste, adjust, taste again
ModelThe learned result: structure plus tuned numbersThe finished recipe that came out of all that practice
Program or applicationThe software that loads the model and uses it for somethingThe restaurant that serves the dish to customers
i
Key idea

An algorithm is a process; a model is the product of that process. Train the same algorithm on different data and you get different models. Change the data and you change what the model knows.

2A Short History of Models

Models did not appear overnight. Each decade added a missing piece.

1943

The artificial neuron

Warren McCulloch and Walter Pitts described a simple mathematical neuron that adds up inputs and fires if the total is high enough. It is the ancestor of every neural network.

1950

Can machines think?

Alan Turing published a famous paper asking whether machines can think and proposed a test based on conversation. It put the question of machine intelligence on the scientific agenda.

1956

The field gets its name

A summer workshop at Dartmouth College, organized by John McCarthy and others, gave artificial intelligence its name and its first generation of researchers.

1958

The perceptron

Frank Rosenblatt built the perceptron, a single artificial neuron that could learn to sort inputs into two groups by adjusting its numbers from examples. This was one of the first true learning models.

1986

Backpropagation spreads

Rumelhart, Hinton, and Williams popularized backpropagation, a method for working out how to adjust every number in a multi-layer network. Training deeper models became practical.

1997

Deep Blue beats Kasparov

IBM’s chess computer defeated the world champion. Notably, it relied mainly on fast search and hand-crafted rules rather than learning, a reminder that not every impressive AI system is a learned model.

2012

Deep learning takes off

A neural network called AlexNet won an image-recognition contest by a wide margin, running on GPUs. Large datasets plus powerful chips turned out to be the missing ingredients.

2016

AlphaGo

DeepMind’s AlphaGo beat Lee Sedol, a top professional of the game Go, using models trained from human games and from playing against itself.

2017

The Transformer

Google researchers introduced the Transformer design, which handles sequences such as text very efficiently and scales to enormous sizes.

2020+

Foundation models

Very large models trained on broad data, such as GPT-3 and its successors, can be adapted to many tasks. A single model now writes, translates, codes, and describes images.

The story of AI models is the story of moving from writing rules to learning them.

3How a Model Learns

Learning sounds mysterious, but the core loop is simple enough to describe in four steps.

A model is a function with adjustable knobs

At its heart, a model is a function: a machine that turns an input into an output. A very simple model might be “price equals size times a number plus another number”. The two numbers are the knobs, or parameters. If the knobs are set badly, the predicted prices are nonsense. If they are set well, the predictions are close to real prices. Learning is the process of finding good knob settings.

Everyday analogy

Imagine learning to throw darts blindfolded, with a friend who tells you how far off each throw landed. After each throw you adjust your aim a little: more to the left, a bit harder. After hundreds of throws, you land near the bullseye. The adjustments you made, stored in your muscles, are the model. The friend’s feedback is the error signal that drives learning.

The training loop

flowchart TD
    A["Training example: input and correct answer"] --> B["Model makes a prediction"]
    B --> C["Compare prediction with the correct answer"]
    C --> D["Calculate the error, called the loss"]
    D --> E["Adjust the parameters to reduce the error"]
    E --> F{"Good enough?"}
    F -->|"No"| A
    F -->|"Yes"| G["Save the trained model"]
Figure 1: The basic training loop shared by most learning models
1

Predict

The model takes an example and makes a guess using its current numbers. At the very start, the numbers are random, so the guesses are poor.

2

Measure the error

A loss function scores how far the guess was from the correct answer. A big miss gives a big loss; a close guess gives a small one.

3

Adjust

An optimization method, most commonly gradient descent, works out which direction to nudge each parameter to lower the loss, and nudges them all by a tiny amount.

4

Repeat

This happens over and over across thousands or millions of examples, often making many passes over the whole dataset. Each full pass is called an epoch.

Why the nudges are small

The size of each nudge is controlled by a setting called the learning rate. If it is too large, the model overshoots and bounces around like a ball thrown too hard down a hill. If it is too small, learning takes forever. Choosing it well is part of the craft of training.

A tiny worked example

Suppose you want a model that predicts the price of a flat from its size. You have three past sales: a 500 square foot flat sold for about 105 thousand dollars, a 1,000 square foot flat for about 195 thousand, and a 1,500 square foot flat for about 310 thousand. Your model is the simple formula “price equals size times a, plus b”. The two numbers a and b are the parameters.

At the start, a and b are both zero, so every prediction is zero and the error is huge. The training loop notices that predictions are too low and nudges a upward and b upward. After many rounds, a settles near 0.2 and b near 5. The model has found the line that best fits the sales. Now ask it about a 900 square foot flat: 0.2 times 900, plus 5, gives about 185 thousand dollars. That is a prediction for a flat the model never saw.

The model with two parameters and the language model with 175 billion parameters follow exactly the same principle. Only the size of the formula, the amount of data, and the amount of computing power are different. If you understand this small example, you understand the heart of machine learning.

Learning is not memorizing

The goal is not for the model to remember every training example. The goal is for it to capture the pattern behind the examples, so it can handle new inputs it has never seen. A model that does this well is said to generalize. Much of the rest of this guide is about achieving, measuring, and protecting that ability.

i
Remember

Training is the learning phase and happens once, or occasionally. Inference is the using phase, where the finished model answers new questions. They have very different costs and needs, as Chapter 10 shows.

4Ways a Model Can Learn

Models differ in what kind of feedback they get during training.

Style 1

Supervised learning

The model learns from examples that come with correct answers, called labels. Show it thousands of emails marked “spam” or “not spam” and it learns to sort new ones. This is the most common style in business.

Style 2

Unsupervised learning

There are no labels. The model looks for structure on its own, such as grouping customers with similar buying habits or spotting unusual transactions that fit no group.

Style 3

Self-supervised learning

The data supplies its own answers. A language model hides the next word in a sentence and tries to predict it. No human labeling is needed, which is why this style scales to huge datasets.

Style 4

Reinforcement learning

The model acts in an environment and receives rewards or penalties. Over many tries it learns which actions pay off. It is used for game-playing, robotics, and for tuning chat assistants with human feedback.

Everyday analogy

Supervised learning is studying with an answer key. Unsupervised learning is sorting a box of mixed buttons into piles by looking at them, with nobody telling you the categories. Reinforcement learning is training a puppy with treats: it tries things, and the treats shape its behavior.

Two common tasks

In supervised learning, most problems fall into two kinds. Classification means choosing a category, such as “fraud” or “not fraud”, or “cat”, “dog”, or “rabbit”. Regression means predicting a number, such as tomorrow’s temperature, the price of a house, or the number of items that will sell next week.

TaskOutput looks likeExample
ClassificationA label from a fixed listIs this transaction fraudulent?
RegressionA number on a scaleHow many riders will book a cab at 6 pm?
ClusteringGroup memberships discovered from dataWhich customers behave alike?
GenerationNew content such as text or imagesWrite a product description

5Families of Models

“Model” is a broad word. Under it live many families, from a one-line formula to systems with hundreds of billions of numbers.

Classic

Linear and logistic regression

The simplest models: they weigh each input and add the results. They are fast, easy to explain, and still widely used for forecasting and risk scoring.

Classic

Decision trees

A flowchart of yes-or-no questions, such as “Is income above this level?” Easy to read, because you can follow the path to any decision.

Classic

Random forests and boosted trees

Many trees voting together. They are strong on spreadsheet-style data and remain a favorite for fraud detection and credit scoring.

Classic

Support vector machines

Models that draw the widest possible boundary between two groups of examples. Popular before deep learning, still useful on smaller datasets.

Deep

Convolutional neural networks

Specialists in images. They scan small windows of a picture and build up from edges to shapes to whole objects.

Deep

Transformers

The architecture behind modern language models. They use attention to relate every part of the input to every other part, and they work on text, images, audio, and code.

Generative

Diffusion models and GANs

Models that create images and audio. Diffusion models start from random noise and clean it up step by step into a picture.

Generative

Large language models

Very large Transformers trained to predict the next token of text, then tuned to follow instructions. They are a particular kind of model, not the whole category.

Inside a neural network

Neural networks deserve a closer look because they power most headline-grabbing AI. A neural network is built from layers of tiny units. Each unit multiplies its inputs by numbers, adds them, and passes the result forward. Early layers pick up simple features and later layers combine them into richer ideas. In an image model, the first layers might notice edges, the middle layers shapes, and the final layers whole objects.

flowchart LR
    A["Input: pixels of a photo"] --> B["Layer 1: edges and colors"]
    B --> C["Layer 2: simple shapes"]
    C --> D["Layer 3: object parts such as ears and eyes"]
    D --> E["Output: cat with high confidence"]
Figure 2: How an image model builds understanding layer by layer
Everyday analogy

An assembly line in a car factory. The first station bolts on the frame, the next adds the engine, the next the doors, and by the end a finished car rolls out. No single station builds the car, but together they do. Each layer of a network is a station that passes a slightly more finished idea down the line.

Choosing a family

Bigger is not always better. For a table of customer records with a few dozen columns, a boosted tree model often beats a huge neural network, trains in minutes, and can be explained to a regulator. For photos, speech, and free-form text, neural networks are usually the clear winner. A good practitioner starts with the simplest model that could work and upgrades only when the results demand it.

6Data: The Fuel of Every Model

A model can only learn what its data can teach it.

Features and labels

Data for a model is usually arranged as examples. Each example has features, which are the inputs describing it, and often a label, which is the correct answer. For a loan model, the features might be income, existing debts, and years in a job, and the label might be “repaid” or “defaulted”. Choosing and preparing good features, called feature engineering, can matter more than choosing a fancy model.

Everyday analogy

Data is to a model what ingredients are to a chef. A superb chef with spoiled vegetables still serves a bad meal. The old saying in computing, garbage in, garbage out, applies with full force: a model trained on wrong, biased, or narrow data will confidently repeat those flaws.

Splitting the data honestly

If you test a model on the same examples it studied, you learn nothing, because it may simply remember them. So the data is split into three groups before training begins.

flowchart TD
    A["All collected data"] --> B["Clean and prepare"]
    B --> C["Training set, about 70 percent"]
    B --> D["Validation set, about 15 percent"]
    B --> E["Test set, about 15 percent"]
    C --> F["Learn the parameters"]
    D --> G["Tune settings and compare models"]
    E --> H["Final honest score, used once at the end"]
Figure 3: Splitting data into training, validation, and test sets
SetPurposeExam comparison
TrainingThe model learns its parameters from these examplesThe textbook and practice problems
ValidationUsed to tune settings and pick between candidate modelsA mock test taken while still preparing
TestGives a final, unbiased score on unseen dataThe real exam, taken once

Where data comes from and how it gets labels

Training data comes from many sources: records a company already keeps, such as sales and support tickets; sensors and cameras; public datasets released by universities; and text, images, and code collected from the web. Each source brings its own questions about quality, permission, and privacy, so teams document where every dataset came from and what they are allowed to do with it.

Labels are often the costliest part. A medical imaging model needs scans marked by trained doctors. A spam filter needs messages marked by users who click the report button. Some labels come free from the real world, such as whether a customer actually repaid a loan. Where people must create labels, teams write clear guidelines and have several people label the same examples, then check how often they agree. If humans disagree on the answer, a model cannot be expected to find a single correct one.

Common data problems

  • Missing values: blank fields that must be filled sensibly or handled by the model.
  • Wrong labels: mistakes in the answer key teach the model mistakes.
  • Imbalance: if 99 out of 100 examples are normal and one is fraud, the model may learn to ignore the rare case.
  • Leakage: accidentally including information in the features that would not be known at prediction time, which makes test scores look unrealistically good.
  • Unrepresentative samples: data from one city, one age group, or one season that fails to reflect the real world.
!
Watch out

Data leakage is one of the sneakiest errors. A model that looks brilliant in testing can collapse in production simply because it was secretly given a hint during training that real life will never provide.

7What Is Actually Inside a Model?

A trained model is not magic. It is a recipe plus a very long list of numbers.

Two ingredients: architecture and parameters

If you open a saved model file, you find two things. The first is the architecture, which describes the shape of the model: how many layers, how they connect, what operations they perform. The second is the set of parameters, the learned numbers that fill that shape. Architecture is the blueprint of the building; parameters are the exact position of every brick.

Parameters versus hyperparameters

People often confuse these two. Parameters are learned automatically during training. Hyperparameters are settings chosen by humans before training starts, such as the learning rate, the number of layers, or how long to train.

ParametersHyperparameters
Who sets themThe training processThe engineer
ExamplesWeights in a neural network, split points in a treeLearning rate, number of layers, tree depth
WhenDuring trainingBefore training
Kitchen comparisonThe final taste of the dishThe oven temperature and cooking time
Everyday analogy

A piano has a fixed design: 88 keys, strings, hammers. That is the architecture. Tuning the piano sets each string to the right tension. Those tensions are the parameters. Choosing how long the tuner works and how fine the adjustments are is like choosing hyperparameters.

How big is a model?

Models range enormously. A simple regression model may have a handful of numbers. A model that recognizes handwritten digits may have a few hundred thousand. Modern language models have billions. Because each number takes memory, often two bytes, a model with 70 billion parameters needs around 140 gigabytes just to store its numbers. That is why the largest models run on clusters of specialized chips, while small ones fit on a phone.

Pre-trained models, transfer learning, and fine-tuning

Training a large model from nothing is extremely expensive, so most teams do not do it. Instead they start from a pre-trained model, one that someone else has already trained on a huge, general dataset. That model has already learned broadly useful patterns, such as what edges and textures look like in images, or how sentences are structured in a language. Reusing those learned patterns for a new job is called transfer learning.

The most common way to do this is fine-tuning. You take the pre-trained model and continue training it for a short while on a small, specialized dataset, such as photos of your own factory parts or support tickets from your own company. The parameters shift slightly to fit your task, while the broad knowledge stays in place.

Everyday analogy

A qualified doctor who wants to become a skin specialist does not go back to primary school. They build on years of general medical training and add a focused course. A pre-trained model is the general doctor, and fine-tuning is the specialist course.

ApproachWhat you doData neededRelative cost
Use as it isCall an existing model for a general taskNoneLowest
Guide with examplesGive a language model instructions and sample cases inside the requestA handful of examplesLow
Fine-tuneContinue training a pre-trained model on your own dataHundreds to many thousands of examplesMedium
Train from scratchBuild the whole model from random numbersVery large datasetsHighest

Model files and where they live

Trained models are saved in files and often shared through public hubs such as Hugging Face, or kept in a private model registry inside a company. A registry stores each version of a model with notes about its training data and scores, so teams can roll back if something goes wrong. Files come in several formats, and as Chapter 13 explains, some formats are safer to open than others.

i
Practical tip

When someone says they “downloaded a model”, they mean they downloaded the architecture description and the parameter values. Running it still requires software that knows how to load those numbers and compute with them.

8Overfitting and Underfitting

The central balancing act of machine learning: learn enough, but not too much.

Underfitting: too simple

An underfit model is too simple to capture the pattern. It performs poorly on the training data and on new data alike. Using a straight line to predict something that curves is a typical cause. It is like a student who skimmed the textbook and understood nothing.

Overfitting: too eager

An overfit model learns the training data so closely that it picks up noise and coincidences as if they were real patterns. It scores brilliantly on the examples it studied and badly on anything new. It has memorized instead of understood.

Everyday analogy

Two students prepare for an exam. One memorizes last year’s exact questions and answers. The other learns the concepts. If this year’s paper repeats last year’s questions, the memorizer shines. If the questions change, only the student who understood the concepts survives. The memorizer is overfit; the concept learner generalizes.

Signs of underfitting

  • Low scores on training data
  • Low scores on test data too
  • Model is too small or too simple
  • Training stopped too early

Signs of overfitting

  • Excellent scores on training data
  • Much worse scores on test data
  • Model is very complex for the amount of data
  • Predictions swing wildly on small input changes

How practitioners fight overfitting

Remedy

More and better data

The more varied the examples, the harder it is to memorize them all.

Remedy

Simpler models

Fewer parameters leave less room to memorize noise.

Remedy

Regularization

Adding a penalty for overly large or complicated parameter values, nudging the model toward simplicity.

Remedy

Early stopping

Watching the validation score and halting training when it stops improving.

Remedy

Dropout and augmentation

Randomly switching off parts of a network during training, or creating varied copies of examples such as flipped images.

Remedy

Cross-validation

Training and testing on several different splits of the data to get a more trustworthy score.

9How We Measure a Model

“It seems to work” is not good enough. Numbers tell the truth, if you pick the right ones.

Accuracy and why it can fool you

Accuracy is the share of predictions that were correct. It is simple, and sometimes dangerously misleading. Suppose only one transaction in a hundred is fraud. A lazy model that always answers “not fraud” is correct 99 percent of the time, and catches zero fraud. Its accuracy looks superb while its usefulness is nil. This is called the accuracy paradox.

Better questions: precision and recall

For tasks where one outcome is rare or costly, two other measures give a clearer picture. Precision asks: when the model raises an alarm, how often is it right? Recall asks: of all the real cases, how many did the model catch?

Everyday analogy

Picture a metal detector at an airport. High recall means it beeps for nearly every real weapon, but if it also beeps for belt buckles and coins, precision is low and the queue never moves. A detector that rarely beeps has high precision when it does, but may miss real threats. Designers must choose a balance that fits the stakes.

MetricPlain meaningCare most about it when
AccuracyShare of all predictions that are rightClasses are balanced and mistakes cost about the same
PrecisionOf the cases flagged, how many were truly positiveFalse alarms are expensive, such as blocking a good customer
RecallOf all true positives, how many were foundMissing a case is dangerous, such as a disease screening
F1 scoreA single number blending precision and recallYou need a balance and have uneven classes
Mean squared errorAverage squared gap between predicted and real numbersYou predict quantities like price or demand
LatencyTime taken to produce one predictionUsers or systems are waiting for the answer

The confusion matrix

A confusion matrix is a small grid that counts four outcomes for a yes-or-no model: true positives (correctly flagged), true negatives (correctly passed), false positives (flagged by mistake), and false negatives (missed). Nearly every metric above is calculated from these four counts, so looking at the grid itself shows exactly where the model goes wrong.

Judging models that generate content

Models that write text or create images are harder to score, because there is often no single correct answer. Teams combine several approaches: automatic checks for facts and format, benchmark question sets with known answers, ratings from human reviewers who compare outputs side by side, and tracking how real users respond, for example whether they accept a suggestion or edit it heavily. No single score tells the whole story, so careful teams look at several together.

Beyond the numbers

A good evaluation also checks performance across different groups of people, across seasons or regions, and on hard edge cases. A model with a strong overall score can still fail badly for one group, and that failure is hidden by the average.

i
Practical tip

Before training, decide which mistake is worse for your use case, a false alarm or a miss. That answer tells you which metric to optimize, and it should be written down before anyone sees a score.

10From Idea to Production: The Life of a Model

Training a model is only a small part of the job. Most of the work comes before and after.

The lifecycle

flowchart TD
    A["Define the problem and success measure"] --> B["Collect and label data"]
    B --> C["Prepare features"]
    C --> D["Train candidate models"]
    D --> E["Evaluate on unseen data"]
    E --> F{"Good enough?"}
    F -->|"No"| C
    F -->|"Yes"| G["Deploy to production"]
    G --> H["Monitor performance and drift"]
    H --> I{"Performance dropping?"}
    I -->|"Yes"| B
    I -->|"No"| H
Figure 4: The machine learning lifecycle, shown as a loop that never really ends

The diagram is a loop on purpose. A model is not finished when it is deployed. The world changes, new data arrives, and the model must be watched and refreshed. Teams that treat a model as a one-time project usually end up with one that quietly decays.

Training versus inference

Training builds the model and is heavy: many GPUs, hours to months, large datasets. Inference uses the model to answer one request and is light by comparison, but it happens constantly, so its total cost can exceed training over time. Many companies spend far more computing on inference than on training because millions of users trigger it every day.

Serving a model to millions of users

To make a model useful, it is wrapped in a service that applications can call over the network. A typical production setup looks like this.

flowchart TD
    A["Mobile app or website"] --> B["API gateway"]
    B --> C["Load balancer"]
    C --> D["Model server 1"]
    C --> E["Model server 2"]
    C --> F["Model server N"]
    G["Feature store"] --> D
    G --> E
    G --> F
    H["Model registry with versions"] --> D
    H --> E
    H --> F
    D --> I["Prediction returned to the app"]
    E --> I
    F --> I
    D --> J["Logs and metrics"]
    E --> J
    F --> J
    J --> K["Monitoring and alerts"]
Figure 5: A simplified architecture for serving a model in production
Component

API gateway

The front door: checks who is calling, enforces limits, and routes requests.

Component

Load balancer

Spreads requests across many model servers so none is overwhelmed and one failure does not stop the service.

Component

Model servers

Machines, often with GPUs, that hold the model in memory and compute predictions.

Component

Feature store

A shared, consistent source of input values, so training and serving use the same definitions.

Component

Model registry

A catalog of model versions with their scores, so teams can deploy a chosen version or roll back quickly.

Component

Logs and metrics

The record of inputs, outputs, timing, and errors that feeds dashboards and alerts.

Making models fast and affordable

When millions of people use a product, even a small saving per prediction adds up to a large amount. Engineers therefore use several techniques to make models cheaper and faster without losing much quality.

Technique

Quantization

Storing each parameter with fewer bits, for example eight instead of sixteen. The model shrinks and runs faster, usually with only a small drop in quality.

Technique

Distillation

A small student model is trained to imitate a large teacher model, capturing most of its skill in a much lighter package.

Technique

Pruning

Removing parameters that contribute very little to the output, making the model smaller and quicker.

Technique

Batching and caching

Grouping requests so hardware stays busy, and storing answers to repeated questions so they need not be recomputed.

Teams also scale horizontally, which means adding more identical model servers behind the load balancer as traffic grows, and removing them when traffic falls. This keeps response times steady during busy hours without paying for idle machines overnight.

Batch or real time?

ModeHow it worksGood for
BatchPredictions are computed in bulk on a schedule and stored for later useNightly demand forecasts, weekly recommendation lists
Real timeA prediction is computed the instant a request arrives, usually within milliseconds to secondsCard fraud checks, search ranking, voice assistants
On-deviceThe model runs on the phone or device itself, with no network tripFace unlock, keyboard suggestions, privacy-sensitive tasks
Everyday analogy

Batch prediction is baking a tray of bread overnight so it is ready when the shop opens. Real-time prediction is making a fresh dosa the moment a customer orders. On-device prediction is the customer having a small stove at their own table. Each choice trades freshness, speed, and cost.

11Models at Work: Real-World Examples

You already depend on dozens of models every day.

Netflix: predicting what you will want to watch

Recommendation models learn from viewing history, ratings, and the behavior of millions of similar viewers. Netflix famously ran an open contest from 2006 to 2009, the Netflix Prize, offering one million dollars to anyone who could improve its recommendation accuracy by a set margin. The contest helped popularize many techniques now common in the field.

Gmail: sorting spam from real mail

Spam filters are classification models trained on huge numbers of messages marked as spam or legitimate by users. They look at wording, sender patterns, links, and many other signals, and they must keep adapting because spammers keep changing tactics.

Credit card networks: catching fraud in milliseconds

Payment companies such as Visa and Mastercard score transactions in real time with models that compare each purchase against typical behavior. The decision must arrive fast enough that the customer at the checkout counter never notices.

Google Translate: from phrase tables to neural networks

In 2016 Google moved its translation service to neural machine translation, using one large neural model to translate whole sentences instead of stitching together separate phrase-level pieces. Quality improved noticeably for many language pairs.

Apple Face ID: a model on your phone

Face ID uses neural networks running on the device to compare a depth map of your face with the one you enrolled. Keeping the model and the face data on the phone helps protect privacy and avoids a network round trip.

Amazon: suggesting products you may like

Amazon described its item-to-item collaborative filtering approach in a research paper in 2003. The idea is to recommend items that are often bought or viewed together, a pattern a model can learn from purchase history at massive scale.

Waymo and other driverless projects: seeing the road

Self-driving systems combine many models that detect vehicles, pedestrians, lane lines, and traffic lights from camera, radar, and lidar data, and then predict how everything is likely to move in the next few seconds.

i
Pattern to notice

Behind each of these products stands the same lifecycle: lots of data, careful training, honest evaluation, scalable serving, and continuous monitoring. The model is only one box in a much larger system.

12Limits, Bias, and Trade-offs

Models are powerful, but they are not oracles. Knowing their weak spots is part of using them well.

A model only knows its training world

A model learns from the data it was shown. Ask it about situations that look nothing like that data and it will still answer, often with confidence, but the answer may be meaningless. A weather model trained only on tropical climates has nothing sensible to say about blizzards. This failure on unfamiliar inputs is one of the most important limits to remember.

Bias in, bias out

Data reflects the society that produced it, including its unfairness. In 2018 it was widely reported that Amazon had abandoned an experimental recruiting tool after finding that it favored male candidates, because it had learned from past hiring data dominated by men. The model did exactly what it was trained to do, and that was the problem.

Everyday analogy

A model is like a very diligent apprentice who learns only by watching their master. If the master has habits, good and bad, the apprentice copies them all, without ever asking whether they are fair or sensible.

Accuracy versus explainability

Simple models such as decision trees can be read by a person: you can trace why a loan was refused. Large neural networks are often more accurate but behave like sealed boxes, so explaining a single decision is hard. In areas such as lending, hiring, and healthcare, where people deserve reasons and regulators ask for them, this trade-off becomes critical. Explanation tools exist, but they give approximations, not full transparency.

Using models responsibly

Responsible use starts with asking whether a model should be used at all for a given decision. When a model affects a person’s job, loan, health, or freedom, the standard of care must be higher, because errors harm real lives. Good teams follow a few habits.

  • Check fairness on purpose. Measure results separately for different groups, and investigate any large gap instead of trusting the average.
  • Keep a person in the loop. For important decisions, let the model advise and let a trained human decide, with the ability to override it.
  • Be open about limits. Document what data the model learned from, what it is meant for, and what it should not be used for.
  • Offer a way to appeal. People affected by a model’s decision should be able to ask for a review.
  • Respect privacy. Collect only the data needed, protect it, and follow the laws that apply to personal information.

Common trade-offs

Trade-offOne sideOther side
Accuracy versus explainabilityComplex models score higherSimple models can be understood and audited
Accuracy versus speedLarger models give better answersSmaller models respond faster and cost less
Precision versus recallFewer false alarmsFewer missed cases
Fresh versus stableFrequent retraining tracks changeRare retraining keeps behavior predictable
Cloud versus deviceCloud models are bigger and easier to updateOn-device models are faster and more private

What models do well

  • Spot patterns in data far too large for people to inspect
  • Work tirelessly and consistently at scale
  • Handle tasks that are impossible to write rules for
  • Improve as more good data arrives

Where models struggle

  • Inputs unlike anything seen in training
  • Hidden bias inherited from the data
  • Explaining why a particular answer was given
  • Staying accurate as the world changes
!
A cautionary tale

In 2021, Zillow wound down its home-buying business after it struggled to price homes accurately in a fast-moving market, and the losses were large. A prediction model is only as dependable as the stability of the world it was trained on, so high-stakes decisions need human oversight and safeguards.

13Security and Privacy of Models

Models are software assets and they hold information, so they attract attackers.

Everyday analogy

Protecting a model is like protecting a bank vault that also contains a trained clerk. Thieves might bribe the clerk with false information, trick the clerk with clever disguises, copy the clerk’s expertise by asking endless questions, or interrogate the clerk until a secret slips out. Each attack has a counterpart in AI security.

Attack

Data poisoning

An attacker slips bad examples into the training data so the model learns the wrong lesson or a hidden backdoor. Microsoft’s Tay chatbot in 2016 learned abusive language from users and was taken offline within a day.

Attack

Adversarial examples

Tiny, carefully chosen changes to an input, often invisible to people, that make a model misclassify it. Researchers have shown that stickers on a stop sign can confuse some vision models.

Attack

Model extraction

By sending many queries and recording the answers, an attacker trains a copy of the model, stealing intellectual property that cost millions to build.

Attack

Membership inference and data leakage

Probing a model to find out whether a specific person’s record was in its training data, or coaxing it to reveal private details it memorized.

Attack

Unsafe model files

Some file formats, including Python’s pickle, can run code when opened. Loading an untrusted model file from the internet can therefore compromise a machine.

Attack

Prompt injection

For language models, hidden instructions inside the text they read can hijack their behavior and make them ignore their real instructions.

Defense in layers

1

Protect the data

Control who can add to training data, check sources, and look for strange or duplicated entries before training.

2

Vet what you download

Use models from trusted sources, scan them, and prefer safer file formats such as safetensors that store only numbers and cannot run code.

3

Limit access to the model

Require authentication, set rate limits, and watch for patterns of querying that look like copying.

4

Harden the model

Train with adversarial examples included, and validate inputs so that odd or malformed requests are rejected.

5

Protect privacy

Remove personal details from training data where possible, and use techniques such as differential privacy that limit what can be learned about any one person.

6

Keep humans in charge of high-stakes actions

Never let a model alone approve payments, medical decisions, or irreversible actions.

ANTI-PATTERN 01Avoid
What teams do

They download a pre-trained model from an unknown uploader on the internet and load it straight onto a production server because it scored well in a demo.

Why it fails

The file may contain hidden code, a planted backdoor, or training data they are not licensed to use. A strong demo score says nothing about any of those risks.

Better approach

Use trusted sources, prefer safe file formats, scan files, test in an isolated environment first, and record where every model came from.

14Monitoring, Logging, and Metrics

A model that worked on launch day will not keep working forever without attention.

Why models decay

The world changes and models do not. Customer habits shift, new products appear, fraudsters invent new tricks, and a pandemic can scramble every pattern at once. A model trained on last year’s reality slowly drifts out of date. This silent decay is called model drift.

Everyday analogy

A paper map is accurate on the day it is printed. Over the years, new roads open, old ones close, and shops move. The map never changes, but the city does, so it slowly becomes wrong. A model is a map of the data world at the moment of training.

Drift type

Data drift

The inputs change. For example, a lending model suddenly receives applications from a new region or a different age mix than it was trained on.

Drift type

Concept drift

The relationship between inputs and the right answer changes. What counted as a normal purchase pattern last year may look suspicious now.

What to track

AreaMetricWhy it matters
QualityAccuracy, precision, recall on recent labeled dataShows whether predictions are still good
Input healthDistribution of incoming feature values, missing valuesEarly warning of data drift or broken data pipelines
Output healthSpread of predicted classes or scoresA sudden shift can signal trouble before labels arrive
SpeedLatency per prediction, requests per secondSlow responses hurt users and can overload systems
ReliabilityError rate, timeouts, server healthReveals outages and capacity problems
CostCompute spent per thousand predictionsKeeps serving affordable as usage grows
FairnessScores broken down by user groupCatches harm hidden by averages

Logging with care

Good logs record the model version, the time, the inputs, the output, and an identifier that ties the pieces of one request together. That makes it possible to investigate a complaint months later. Because inputs may contain personal data, logs should be redacted where possible, access should be restricted, and a retention period should be set.

Closing the loop

Monitoring is only useful if it triggers action. Teams set alerts on key metrics, review samples of real predictions regularly, collect fresh labeled data, and retrain on a schedule or when drift is detected. New versions are often tested first on a small slice of traffic, in what is called a canary release, with a fast path to roll back if the numbers worsen.

i
Practical tip

Real labels often arrive late. A fraud outcome may take weeks to confirm. Until then, watch proxies such as input distributions and output scores, which can warn you far sooner than accuracy can.

15Best Practices, Common Mistakes, and Anti-Patterns

The same mistakes appear in project after project. Avoid them and you are already ahead.

Best practices

Do

Start with the problem

Write down what decision the model will support and how success will be measured before touching any data.

Do

Begin with a simple baseline

A basic model or even a simple rule gives you a score to beat. If a complex model barely beats it, the complexity is not worth it.

Do

Guard the test set

Use it once at the end. Peeking repeatedly turns it into another training set.

Do

Version everything

Track data, code, settings, and models so any result can be reproduced and any release rolled back.

Do

Test on realistic data

Evaluate on data that looks like what the model will face in production, including awkward edge cases.

Do

Plan for monitoring and retraining

Decide before launch who watches the model, what triggers an update, and how to roll back.

Common mistakes

  • Choosing a fancy model when a simple one would do, and then being unable to explain or maintain it.
  • Reporting accuracy on imbalanced data without checking precision and recall.
  • Letting information from the future or from the test set leak into training.
  • Training on convenient data instead of data that represents real users.
  • Treating deployment as the finish line and never looking at the model again.
ANTI-PATTERN 02Avoid
What teams do

They tune the model again and again against the same test set until the score looks excellent, then announce the final number as the expected real-world performance.

Why it fails

Each round of tuning quietly teaches the model about the test set. The reported score is optimistic, and production results disappoint.

Better approach

Tune against the validation set only, keep the test set locked away, and report the test score once, honestly, after all decisions are made.

ANTI-PATTERN 03Avoid
What teams do

They deploy a model, celebrate, and move the whole team to the next project, with no monitoring and no owner.

Why it fails

Drift sets in slowly. Months later, customers notice poor results before the company does, and nobody remembers how the model was built.

Better approach

Assign an owner, set up dashboards and alerts, schedule reviews, and document training data and settings so the model can be maintained and rebuilt.

i
A simple habit

Before trusting any model, ask three questions: what data taught it, how was it tested on things it had never seen, and what happens if it is wrong? If the third answer is “something serious”, add human review.

16Frequently Asked Questions

Short answers to questions that come up again and again.

Q1Is a model the same as an algorithm?
No. An algorithm is a procedure, such as the steps used to adjust numbers during learning. A model is the result of running that procedure on data. The same algorithm trained on different data produces different models.
Q2Is a model the same as artificial intelligence?
Not exactly. Artificial intelligence is the broad field. A model is one building block used in many AI systems. A full AI product usually combines one or more models with data pipelines, rules, interfaces, and safety checks.
Q3What is the difference between AI, machine learning, and deep learning?
Artificial intelligence is the widest idea: machines doing tasks that seem intelligent. Machine learning is the part of AI where systems learn from data instead of following hand-written rules. Deep learning is a part of machine learning that uses neural networks with many layers.
Q4Is ChatGPT a model?
ChatGPT is a product. The model inside it is a large language model from the GPT family, and the product adds the chat interface, safety checks, and other tools around that model.
Q5Does a model keep learning after it is deployed?
Usually not. Most deployed models have fixed parameters and only make predictions. To update one, the team collects new data and trains a new version. Some systems do update more continuously, but that is a deliberate design choice with extra risks.
Q6How much data does a model need?
It depends on the problem and the model. Simple models on tidy tables can work with a few thousand examples. Deep image and language models need far more. Quality and variety matter at least as much as quantity.
Q7What is a pre-trained model, and what is fine-tuning?
A pre-trained model has already learned general patterns from a large dataset. Fine-tuning continues its training on a smaller, specialized dataset so it adapts to a specific task. It saves enormous time and cost compared with training from scratch.
Q8Why do models sometimes give wrong answers with confidence?
A model’s confidence reflects patterns in its training data, not an understanding of truth. On unfamiliar or tricky inputs it can still produce a confident but wrong answer. This is why testing on varied data and keeping humans involved in important decisions both matter.
Q9What does it mean when a model has billions of parameters?
It means billions of learned numbers define its behavior. More parameters give a model more capacity to capture complex patterns, but also demand more data, computing power, and memory to train and run.
Q10Can I build a model without being a mathematician?
Yes. Modern libraries and cloud services handle most of the mathematics. What you need is a clear problem, good data, sound evaluation habits, and an understanding of the ideas in this guide so you can spot when something has gone wrong.
Q11What is a foundation model?
A foundation model is a very large model trained on broad data that can be adapted to many tasks, such as writing, translation, coding, and image description, often with little or no extra training.
Q12How do I know if my model is good enough?
Compare it to a simple baseline on data it never saw, using the metric that reflects the real cost of mistakes. Then check how it performs for different user groups and edge cases, and confirm it meets speed and cost needs. Good enough is defined by the use case, not by a universal score.

17Summary and Key Takeaways

The whole picture, from one idea to a living production system.

An AI model is a learned pattern captured as architecture plus numbers. It is created when a learning algorithm adjusts those numbers against data, and it is used when applications feed it new inputs and read back predictions. Models come in many families, from a short decision tree to a Transformer with billions of parameters, and the right one depends on the problem, the data, and the need to explain decisions. A model is judged by how well it handles examples it has never seen, using metrics that match the real cost of errors. It lives inside a larger system of data pipelines, servers, registries, and monitors, and it needs protection from attackers and attention from its owners long after launch.

Key Takeaways

  • A model is the result of learning. It is architecture plus learned parameters, produced by running a learning algorithm on data.
  • Data shapes everything. A model can only learn what its examples teach it, so quality, variety, and honesty of data decide the outcome.
  • Generalization is the goal. Split data into training, validation, and test sets, and watch for overfitting, where a model memorizes instead of understanding.
  • Choose metrics that match the stakes. Accuracy alone can mislead, so use precision, recall, and error measures that reflect the true cost of mistakes.
  • Training is a small part of the work. Serving, scaling, versioning, and monitoring are what keep a model useful in the real world.
  • Models can fail and be attacked. Bias, drift, poisoning, adversarial inputs, model theft, and unsafe files are real risks that need layered defenses and human oversight.
  • Start simple and keep watching. Begin with a baseline, upgrade only when needed, and treat every deployed model as something that needs an owner and regular review.