A student spends years studying for a medical degree. That’s the slow, expensive part. Then, as a doctor, they see patients every day and apply what they learned, often in minutes. Studying happens once; using the knowledge happens over and over.
AI models have the same two phases. The learning phase is called training. The using phase is called inference. You never see training, but you trigger inference every time you ask a chatbot a question, unlock your phone with your face, or get a song recommendation. This guide explains what inference is, how it differs from training, and why it matters for speed and cost.
What is inference in AI?
Inference is the process of using a trained AI model to produce an output, such as an answer, a prediction or a label, from new input.
During inference:
- The model receives input: your question, a photo, a sound clip.
- It runs that input through its learned numbers, called weights (letter W).
- It produces an output: a reply, a label like “cat”, or a score like “92% likely to be spam”.
The key point: during inference, the model’s weights are frozen. They are read, not changed. The model doesn’t learn anything new from your question.
Training vs inference
| Training | Inference | |
|---|---|---|
| What it is | The model learns from data | The model is used on new input |
| What happens to the weights | They change, step by step | They stay frozen |
| How often | Once (plus occasional updates) | Every single time someone uses it |
| How long | Weeks to months for a large model | Usually seconds (sometimes minutes) per request |
| Needs | Huge datasets, huge computing power | The trained model and enough hardware to run it |
| Everyday comparison | Years of studying | Seeing a patient |
Training a large language model is a giant one-time effort (see what a large language model is for how it works). Inference is small per request, but it happens enormous numbers of times. A popular AI service may handle millions of requests a day, so over the life of a model, the total cost of inference can become very large.
What happens during inference in a chatbot
Here is what inference looks like when you send a message to an AI chatbot:
- Your text becomes tokens. Your message is cut into small pieces of text, called tokens (see tokens and embeddings).
- Tokens become numbers. Each token is turned into a list of numbers the model can work with.
- A pass through the model. Those numbers flow through the model’s layers. The model scores every possible next token.
- One token is chosen and added to the answer.
- Repeat. The model runs again with the new token included, and again, one token at a time, until the answer is complete.
That’s why you see chatbot answers appear word by word. Each new piece needs another pass through the model. A long answer needs many passes, which is why it takes longer and costs more.
Inference isn’t only for chatbots. A spam filter does inference on every email. Face unlock does inference on every glance. A self-driving system does inference many times per second on camera images.
Why inference speed and cost matter
Because inference happens every time anyone uses a model, it shapes the experience you get and the price companies pay.
- Speed (latency). How long you wait for a response. For a chatbot, people often care about how quickly the first words appear and how many tokens per second follow.
- Cost. Running big models needs powerful chips, usually GPUs or specialised AI chips, plus electricity and cooling. AI services often charge developers per token of input and output for this reason.
- Scale. A model that is cheap to run can serve far more people.
Bigger models usually give better answers but are slower and more expensive to run. A lot of AI engineering is about getting good answers with cheaper inference. Common techniques include:
- Smaller models for simpler tasks
- Quantization: storing the model’s numbers with less precision, so it needs less memory and runs faster (letter Q)
- Caching: reusing work that was already done for repeated text
- Batching: processing many users’ requests together on the same hardware
Where does inference run?
- In the cloud. Most big chatbots run on the provider’s servers. Your message travels over the internet, inference happens in a data centre, and the answer comes back.
- On your device. Smaller models can run directly on phones and laptops. Face unlock, keyboard suggestions and some photo features work this way. It can be faster, works offline, and keeps your data on your device.
- On your own computer, by choice. Tools such as Ollama let you download an open model and run inference locally. Our Run LLMs locally with Ollama series shows how.
- At the edge. Cameras, cars and factory machines often run models on built-in chips, because they need answers in milliseconds.
Common misconceptions
“The AI is learning while I use it.” During inference the weights are frozen. A chat app may store your conversation or settings, and companies may later use data to train new versions, but the model you’re talking to isn’t changing in real time.
“Training is the expensive part, so using AI is cheap.” Each request is cheap, but there are a lot of them. Over time, inference can cost more in total than training did.
“Inference means the AI is reasoning or deducing.” In AI, inference just means running the model. Whether the output involves anything like reasoning depends on the model and the task.
“You always need the internet for AI.” Only for cloud models. Many models run on-device or on your own computer.
Key takeaways
- Inference is using a trained model to turn new input into an output.
- Training changes a model’s weights; inference only reads them.
- Training happens once; inference happens every time someone uses the model.
- In an LLM, after reading your prompt, inference runs once per new token, which is why answers appear word by word.
- Inference decides speed and cost, and can run in the cloud, on your device, or on your own computer.
Frequently asked questions
What is inference in AI in simple words?
Inference is when an AI model is actually used: you give it something, and it gives you an answer based on what it learned during training.
What is the difference between training and inference?
Training is the learning phase, where the model’s numbers are adjusted using lots of data. Inference is the using phase, where those numbers stay fixed and the model answers new questions.
Is ChatGPT doing inference when I chat?
Yes. Every reply is produced by inference on OpenAI’s servers, using a model that was trained beforehand.
Why is AI inference expensive?
Large models have billions of numbers, and producing each token means doing calculations with them on powerful chips. Multiply that by millions of users and long answers, and the hardware and electricity add up.
Can I run AI inference on my own laptop?
Yes, for smaller models. Tools such as Ollama let you download an open model and run it locally, often without an internet connection once the model is downloaded.
Comments