Gradient LabStart the lesson

Lessons › Chapter 14: ML in practice

Deploying models

Training ends with a file full of weights. Nobody benefits until it’s put somewhere that can answer real requests. That’s deployment.

Watch it move. This lesson is interactive on Gradient Lab: every step is an animated scene you can replay.

Start the interactive lesson

Step by step

Story

Going live

The fraud model must score every card payment while the customer waits at the till.

Concept

A model file does nothing alone

Training ends with a file full of weights. Nobody benefits until it’s put somewhere that can answer real requests. That’s deployment.

Key idea

Wrap it in an API

Put the model behind an api on a server. Apps send a request (a transaction) and get a score back in milliseconds.

Build

Batch and on-device

Not everything needs instant answers. A batch job can score millions of records overnight. And small models can run right on a phone, which is fast, works offline and keeps data on the device.

Real life

In real life: a card payment in a blink

When you tap your card, the payment is sent to a fraud model behind an API and scored before the terminal beeps. The whole round trip has to fit into a fraction of a second, millions of times a day.

Quick check: Which deployment style answers each request instantly?

An API serves predictions on demand; batch jobs run on a schedule.

Pseudocode

model = load("fraud-model-v7")

api = a web service:
    on request(transaction):
        score = model.predict(transaction)
        return score                    # answers in milliseconds

batch job: score all of yesterday's data overnight
on-device: a small model runs right on the phone

Key terms

deployment
Putting a trained model where it can make predictions for real users.
api
A way for other programs to send a request to your model over the network and get an answer back.

Build it: Serve your model as a web API (40 min, runs in your browser)

See the project

In the news

Recent models and papers that build on this idea: