Tech, ExplainedSemiconductors and devices
Concept

Training vs inference

Taught once, run billions of times.

HOW IT WORKSEngineers gathera very largeset of examplesTraining: thousands oflinked chips adjustthe model's numbers,over weeksThe finishedmodel is saved asa file of numbersInference: themodel runs on eachnew request andreturns an answerThis repeats billionsof times a day, sospeed and energy peranswer matterA model is trained once but run endlessly, so the cost of running it soon becomes the larger bill.HOW IT WORKSEngineersgather a verylarge setof examplesTraining:thousandsof linkedchips adjustthe model'snumbers,over weeksThe finishedmodel issaved asa fileof numbersInference:the modelruns on eachnew requestand returnsan answerThis repeatsbillions oftimes a day,so speed andenergy peranswer matterA model is trained once but run endlessly, so the cost of running it soon becomes the larger bill.HOW IT WORKSEngineers gather a verylarge set of examples↓Training: thousands of linked chipsadjust the model's numbers, over weeks↓The finished model issaved as a file of numbers↓Inference: the model runs on each newrequest and returns an answer↓This repeats billions of times a day, sospeed and energy per answer matterA model is trained once but run endlessly, so the cost ofrunning it soon becomes the larger bill.
Training adjusts a model's numbers once, over weeks, on thousands of linked chips; inference then runs the finished model on every request, billions of times a day.
opens a page inside this one a page in the same scene a page in another scene a concept page a label only, with no page

Training vs inference is the difference between the two jobs that every AI model needs. Training teaches the model, once, using a huge amount of data and thousands of chips working together. Inference is running the trained model to answer each request, which happens billions of times a day across all its users. Training needs raw computing power. Inference needs each answer to be fast, and to use as little energy and money as possible.

Here is how training works. An AI model is a very large set of numbers, called weights or parameters. At the start, the numbers are random, and the model's answers are useless. Engineers feed it examples. For a large language model, the examples are trillions of words of text. For each example, the model makes a guess, such as the next word in a sentence. The guess is compared with the right answer, and every number is adjusted very slightly to make the next guess better. This repeats an enormous number of times. Training a large model takes weeks or months on thousands of linked GPUs, the chips built for this kind of arithmetic. It can cost hundreds of crores of rupees. The result is a file of numbers: the trained model. Fine-tuning is a shorter, cheaper round of training that adapts a trained model to one task.

Here is how inference works. The trained model's file is loaded onto a chip. A request arrives, such as a question typed into a chatbot. The chip runs the request through the model's numbers and produces the answer. The numbers do not change. Each answer costs very little, but there are billions of answers. So, across a year, inference becomes the larger bill. What matters most here is latency, the time the user waits for the answer, and the energy each answer uses. Many companies shrink a model before running it, so that each answer needs fewer calculations.

The two jobs suit different chips. Training needs the most powerful chips, linked so that thousands can work as one machine. Inference can run on cheaper chips built only for running models, such as many AI accelerators. It can even run on small chips inside phones and devices, which is called edge AI.

Take, for example, a chatbot that answers in Hindi. Its model was trained once, over months. Each reply to each user is a separate inference that takes a second or two.

Consider a pair of wireless earphones that react when the wearer says a wake word. The small model was trained in a data centre. Inference runs on a tiny chip inside the earphone, with no internet connection.

Say a bank uses a model to catch fraud. The bank retrains the model every week on the newest fraud cases, and the model scores each card payment, by inference, in a few milliseconds, as part of payment fraud detection.

How is training different from giving a model information at the moment of the question? Training and fine-tuning change the model's numbers. Retrieval-augmented generation (RAG) does not. It looks up passages in a company's documents and hands them to the model with each question, during inference. So a company can keep a model's answers up to date without training it again.

Appears in

Data platforms and AI
Semiconductors and devices
Tech, Explained is a part of ingrid.fyi. Every page explains one piece of technology in plain words.