AI inference is the process of running a trained model on an input to obtain an output. That output might be a classification, an embedding, a generated image, or a text response. Inference happens whenever a model is used, even when you never see a chat window.

For a text assistant, the experience looks simple: type a question, receive an answer. Underneath, the application assembles context, runs the model, and decides how to display or act on the result.

Follow a text request

  1. Assemble the input. The application combines instructions, the user’s request, relevant history, and possibly retrieved material.
  2. Tokenize and process the context. The input becomes token IDs. The model computes representations of the supplied sequence, often called the prefill stage.
  3. Generate the continuation. In a typical autoregressive model, decoding produces successive tokens. A key-value cache can reuse attention information from earlier tokens.
  4. Return the result. The application may stream text, validate a structured response, or process a proposed tool call.

Longer input can increase time before the first token. Longer output requires more decoding work. Concurrency, hardware, batching, and implementation also affect the experience. Hugging Face inference optimization

Why two requests can behave differently

The model is only one part of the setup. A different prompt, context length, quantization, or decoding configuration can alter results. Temperature and other sampling controls influence token selection; they do not directly measure truthfulness. A lower temperature does not turn an unsupported statement into a sourced fact.

Do not assume exact repeatability across different devices and software versions, even with an identical seed. For an important comparison, record the model identifier, relevant settings, input, and runtime version, then use multiple representative examples.

Local and remote inference

Local inference runs the model on hardware you control. Remote inference sends a request to a server, which may belong to your organization or an external provider. A browser interface can use either arrangement.

Choose based on the whole task: information handling, available memory, required quality, maintenance effort, and response time. A local model that cannot complete your task accurately is not automatically a better choice. A remote model also needs an acceptable data-handling arrangement.

Model weights are only part of memory consumption. Runtime buffers and the context cache add overhead. Multiple requests can further increase demand. This is why a model file that fits on disk may still fail to load or run comfortably.

Measure the experience that matters

For a document-summary task, record time to the first visible output, total completion time, and human review time. Also score whether key facts were preserved. Comparing tokens per second alone misses the cost of correcting a fast but inaccurate summary.

Try this small experiment: summarize the same fictional notes with a short output limit, then with a much longer one. Record whether extra text adds useful information or merely increases review work. Keep the source and model constant so the comparison has a clear interpretation.

Check your understanding

A chatbot feels slow before it begins answering but then streams quickly. Which measurement describes the initial delay?

See the explanation

Time to first token. Queueing, input processing, retrieval, or other application work may contribute. Fast token generation after that point does not explain the entire delay.

To try inference on your own computer, follow the Ollama guide.