Level 3 · Building LLM systemsStage 11

Lesson 34 of 38 · Written learning

Serve models and improve inference

Balance latency, throughput, memory, and quality when a model answers real requests.

7 min read Free course lessonWeeks 29–31

A hosted inference service manages the model hardware for you; local inference gives more control but requires compatible compute and maintenance. Quantization stores weights at lower precision to reduce memory use. Batching processes requests together to improve throughput, while caching can avoid repeated work for identical inputs. Both techniques need careful handling of user-specific data.

Measure before optimizing

Latency is how long a request takes. Throughput is how much work the service completes over time. Streaming can show tokens as they arrive without necessarily reducing total generation time. Concurrency and rate limits constrain simultaneous requests. Measure realistic prompts, output lengths, hardware, and load before changing the architecture.

  • Choose a model that fits the memory and latency budget.
  • Track time to first token and total response time separately.
  • Do not cache sensitive responses across users or contexts.
  • Compare quality and failure modes after quantization or batching changes.

Return to the Deployment, inference, and optimization stage · Suggested timing is flexible; move at your own pace.