Skip to content

Serving Models Efficiently

For people

Reducing latency and cost of inference with batching, caching, quantisation, distillation and the right hardware.

Editorial team 2 min read

Share X LinkedIn Reddit Bluesky Email

Inference cost and latency often dominate the total cost of a machine learning system, especially for large models serving many users.

Measure First

Track latency percentiles, throughput and cost per prediction under realistic load before optimising.

Techniques

  • Batching: process several requests together to use hardware efficiently; dynamic batching groups requests arriving close together.
  • Caching: store results for repeated inputs, and cache expensive intermediate results such as embeddings.
  • Quantisation: store weights with fewer bits (for example 8-bit or 4-bit), shrinking memory and speeding inference with a small accuracy cost.
  • Distillation: train a smaller "student" model to mimic a larger "teacher".
  • Pruning: remove weights or components that contribute little.
  • Optimised runtimes: inference engines and compilers (such as ONNX Runtime or specialised LLM serving engines) are often much faster than training frameworks.
  • Right-sized hardware: CPUs for small models, GPUs or specialised accelerators for large ones; autoscale with demand.

For Language Models

Techniques such as key–value caching, continuous batching, prompt caching and streaming responses matter greatly. Routing simple requests to smaller models also saves cost.

Always Re-Evaluate

Every optimisation can change outputs. Re-run your evaluation set and compare quality, not just speed.

Consider Batch Where Possible

If predictions don't need to be real time, precomputing them in batch is usually far cheaper.

More in MLOps & deployment

All MLOps & deployment guides →
MLOps & deployment Guide · 2 min

What Is MLOps?

The practices that take machine learning from notebook to reliable production: versioning, automation, deployment and monitoring.

MLOps & deployment 2 min read 30 Dec 2025 For people

MLOps & deployment Guide · 2 min

Deploying Machine Learning Models

Batch scoring, real-time APIs, streaming and on-device inference: choosing how predictions reach users, and deploying safely.

MLOps & deployment 2 min read 29 Dec 2025 For people

MLOps & deployment Guide · 2 min

Monitoring Machine Learning Models in Production

What to monitor after deployment — data, predictions, outcomes and operations — and how to respond when things change.

MLOps & deployment 2 min read 28 Dec 2025 For people

MLOps & deployment Guide · 2 min

Model Registries and Versioning

Why every production model needs a version, metadata and lineage, and how a model registry manages promotion and rollback.

MLOps & deployment 2 min read 27 Dec 2025 For people

Discussion 0

Use @handle to bring somebody in, and #tag to file it.

Nothing here yet. Ask a question, or say how you used it.

Sign in to join the discussion. Sign in