What matters in AI.

Subscribe

Learn / AI basics

Definition · AI basics

Inference

Inference is the use of a trained AI model to give results from new input. A classifier gives a class for an example it did not see in training. A language model gives a response to a prompt. Training sets the model weights. Inference uses those weights and does not change them. Each request uses processor time, memory and energy.

Last reviewed

Key points

  • Inference is the use of a trained model on new input. Training changes the model weights, and inference only reads them.
  • A language model does inference in two phases. Prefill reads all of the prompt, and decode makes the response one token at a time.
  • Memory is frequently the limit. For a 13B parameter model on one NVIDIA A100, the vLLM paper shows about 65% of memory for weights and near 30% for request data.
  • Each request has a cost. Google gives 0.24 Wh for the median Gemini Apps text prompt in May 2025, a figure no third party checked.
  • The inference interface is an attack surface. OWASP names cost abuse and model extraction through the model API as risks.

How inference works

Inference has three steps for each request:

  1. The application sends input to the model. For a language model, the input is a prompt cut into tokens.
  2. The model runs the input through its model weights. The weights do not change.
  3. The model gives a result: a class, a score, an image or text.

A language model gives text in two phases. DistServe (Zhong and others, 2024) names them:

Phase What it does Metric
Prefill Reads all the prompt tokens at one time Time to first token (TTFT)
Decode Adds one token after the last Time per output token (TPOT)
A language model reads the prompt one time in prefill, then adds one token in each decode step.
A language model reads the prompt one time in prefill, then adds one token in each decode step.

The model keeps data for earlier tokens in a KV cache. Thus decode does not read the full text again.

Why inference matters

Inference is where a model costs money, and where users and attackers touch it.

  • Memory: the weights and the KV cache must fit in the memory of the processor.
  • Energy: each request uses power in a data center.
  • Attack surface: each user who can send a request can try to misuse the model.

In practice

Memory sets the limit

For a 13B parameter model on one NVIDIA A100 with 40GB, the vLLM paper (Kwon and others, 2023) shows this layout:

  • About 65% of memory holds the weights.
  • Near 30% holds the data of the requests.
  • In the serving systems they tested, only 20.4% to 38.2% of KV cache memory held token data. The remaining memory was waste.

Their system, vLLM, gave 2 to 4 times the throughput at the same latency. Quantization and speculative decoding are other methods to make inference less costly.

Each request uses energy

The inference interface is an attack surface

OWASP LLM10:2025 “Unbounded Consumption” lists risks of an open inference interface:

  • Denial of Wallet: attackers use the “cost-per-use model” of cloud AI to make the bill large. See denial of AI service.
  • Model extraction: crafted queries to the model API let an attacker make a shadow model. See model extraction.
  • Resource floods: long inputs and costly queries use up processor time.

OWASP gives “rate limiting and user quotas” as one control.

Where definitions disagree

The word “inference” has four meanings near AI:

Source Meaning
Machine learning (Google glossary) Use a trained model on new input
Statistics A “somewhat different meaning” (Google glossary)
EU AI Act, Recital 12 Get outputs, and also “derive models or algorithms” from data
AI security (NIST) An attribute inference attack infers sensitive attributes of a training data record

The EU AI Act meaning is wide. Its “capability to infer” covers outputs, and also models or algorithms derived from inputs or data. Read the source before you compare two uses of the word.

Questions and answers

What is the difference between training and inference?

Training changes a model. In the NIST definition, the model learns parameters that make its error on training data as small as possible. Inference uses the trained model on new input to give a result, and the weights stay the same. Inference occurs for each request.

Is an inference attack an attack on inference?

Not always. NIST defines an attribute inference attack as an attack against machine learning models. It infers sensitive attributes of a training data record, given partial knowledge about the record. Here the target of the attack is the training data.

Sources

  1. Machine Learning GlossaryGoogle for Developers
  2. NIST glossary: training stage (from NIST AI 100-2e2025)NIST
  3. NIST glossary: deployment stage (from NIST AI 100-2e2025)NIST
  4. DistServe: Disaggregating Prefill and Decoding for Goodput-optimized Large Language Model ServingarXiv (Zhong et al.), 18 Jan 2024
  5. Efficient Memory Management for Large Language Model Serving with PagedAttentionarXiv (Kwon et al.), 12 Sep 2023
  6. Efficient Memory Management for Large Language Model Serving with PagedAttentionarXiv (Kwon et al.), 12 Sep 2023
  7. Measuring the environmental impact of AI inferenceGoogle Cloud, 22 Aug 2025
  8. Measuring the environmental impact of delivering AI at Google ScalearXiv (Elsworth et al.), 21 Aug 2025
  9. LLM10:2025 Unbounded ConsumptionOWASP GenAI Security Project
  10. EU AI Act, Recital 12Future of Life Institute (text of Regulation (EU) 2024/1689)
  11. NIST glossary: attribute inference attacks (from NIST AI 100-2e2025)NIST

Guides that use this term

In the news