Canonical: https://weaveos.com/glossary/llm-inference

[Home](https://weaveos.com/)/[Glossary](https://weaveos.com/glossary)/[LLM fundamentals](https://weaveos.com/glossary/category/llm-fundamentals)/LLM inference

[LLM fundamentals](https://weaveos.com/glossary/category/llm-fundamentals)

# LLM inference

Also known as Language model inference

By WeavePublished September 10, 20262 min read

## Definition

LLM inference is the process of running a trained language model on an input to produce an output. For a text-generating model, it typically involves processing the input context and generating additional tokens according to a decoding strategy.

On this page

1. [Definition](https://weaveos.com/glossary/llm-inference#definition)
2. [A response has more than one stage](https://weaveos.com/glossary/llm-inference#article-a-response-has-more-than-one-stage)
3. [Why request shape matters](https://weaveos.com/glossary/llm-inference#article-why-request-shape-matters)
4. [Measure the task, not just the call](https://weaveos.com/glossary/llm-inference#article-measure-the-task-not-just-the-call)
5. [How this relates to Weave](https://weaveos.com/glossary/llm-inference#weave)
6. [Sources](https://weaveos.com/glossary/llm-inference#sources)
7. [Related terms](https://weaveos.com/glossary/llm-inference#related)

## A response has more than one stage

The serving system first processes the request's context. For many autoregressive language models, generation then proceeds token by token, with each new token influenced by the preceding context and generated output.

A token is not necessarily a whole word. Tokenization depends on the model, so identical text can produce different token counts across model families.

Inference normally uses existing model weights. It is distinct from training, which updates model parameters. Including examples in a prompt can influence a response without changing those weights.

## Why request shape matters

An illustrative coding request might contain a short question and several large files. Another might contain a small input but ask for a long implementation. Both can consume substantial resources for different reasons.

Input length, generated length, model architecture, hardware, batching, and caching all affect performance. Network and queueing delays also influence the time a user observes, even when the model's computation is unchanged.

## Measure the task, not just the call

A faster response is useful only if it meets the application's requirements. If a quick answer causes the agent to repeat its work, the complete workflow may become slower or more expensive.

Compare inference options using representative requests and a consistent outcome check. Record time to first output separately from the time to finish the response. For an agent, also include tool execution and any additional model calls needed to complete the task.

## How this relates to Weave

Weave Router chooses models for inference requests within coding-agent workflows. Understanding inference helps explain why the least expensive model per token is not always the least expensive way to finish a task. Input processing, generated output, and repeated attempts all contribute to the result.

[Explore Router](https://weaveos.com/products/router)

## Sources and further reading

1. [Text generation, Hugging Face Transformers](https://huggingface.co/docs/transformers/main/en/llm_tutorial)

## Related terms

### [Model routing](https://weaveos.com/glossary/model-routing)

[How model routing selects an AI model for each request, the tradeoffs between cost and quality, and where Weave Router fits into agent workflows.](https://weaveos.com/glossary/model-routing)

### [Context window](https://weaveos.com/glossary/context-window)

[What a language model's context window contains, how token limits affect requests, and why more context does not guarantee better answers.](https://weaveos.com/glossary/context-window)

### [Prompt caching](https://weaveos.com/glossary/prompt-caching)

[How prompt caching reuses prompt processing, what it does not cache, and why hit rates depend on request structure and provider rules.](https://weaveos.com/glossary/prompt-caching)
