Learn AI in Bits

081 - How Does AI Inference Work?

Learn AI in Bits

Show Notes

When you type a question into an AI assistant and watch the answer appear word by word, what's happening underneath is inference: the process of running a trained model to produce that answer. This episode follows one request through the full inference path, from tokenization to the KV cache to production serving.

A prompt is first assembled with any system instructions, conversation history, and context, then converted by a tokenizer into token IDs. The model processes that token sequence through its transformer layers, including attention, producing logits, which are scores for every possible next token. A decoding step turns those scores into a choice, whether through greedy decoding, which picks the top score, or sampling methods shaped by settings like top-k, top-p, and temperature. The model generates output one token at a time this way, rather than retrieving a complete answer from a database.

The episode explains the prefill and decode split: prefill processes the input prompt and builds attention state, while decode generates output tokens one at a time, reusing that state through the key-value cache, or KV cache, so the model doesn't have to recompute previous context on every step. It distinguishes time to first token from inter-token latency, and explains how the KV cache becomes a major memory consideration as conversations and concurrent requests grow, which is why serving systems manage cache allocation, batching, and sometimes prefix reuse across requests.

Zooming out to production, the episode covers how inference engines schedule and batch requests across accelerators, how quantization trades precision for memory and speed, and why practical performance is measured in latency, throughput, memory use, and cost per token rather than benchmark scores alone. It also distinguishes the model's inference step from the rest of an application's pipeline, including retrieval, safety filters, and multimodal input encoding, and closes with a key clarification: running inference on a deployed model doesn't mean it's learning from your conversation as it happens, since that depends entirely on the service's own data and training policies.

Sources & References NVIDIA TensorRT Model Connect: Inference Fundamentals — https://github.com/NVIDIA/TensorRT-Model-Connect/blob/main/website/docs/getting-started/inference-fundamentals.md vLLM: Inside vLLM: Anatomy of a High-Throughput LLM Inference System — https://vllm.ai/blog/2025-09-05-anatomy-of-vllm vLLM Documentation: Disaggregated Prefilling (experimental) — https://docs.vllm.ai/en/latest/features/disagg_prefill/ NVIDIA Technical Blog: Optimizing Inference for Long Context and Large Batch Sizes with NVFP4 KV Cache — https://developer.nvidia.com/blog/optimizing-inference-for-long-context-and-large-batch-sizes-with-nvfp4-kv-cache

Voice narration is AI-generated.

More from Learn AI in Bits

Oct 23, 2026

A wave of cybersecurity disclosures has made this week feel like a turning point, with people calling it "Black October." This episode treats it as a cluster of high-impact incidents, not proof that one AI-driven campaign caused them all, and separates where AI was directly involved from where the failures were conventional.

Oct 20, 2026

Recursive self-improvement is the idea that an AI can improve the very process it uses to improve itself, and this episode separates what's been demonstrated so far from the dramatic predictions often attached to the term. It draws a clear line between self-correction (revising one answer), automated optimization (keeping the best of several tested variants), and true recursive improvement, where the system changes the process that generates future improvements, so the next round starts with a better improver.

Oct 19, 2026

This week's AI News Sunday Wrap-Up covers a week where the industry moved on several fronts at once: new flagship and open models, enterprise agent governance, a serious safety warning, legal pressure, and the physical infrastructure limits behind the AI race.

Oct 16, 2026

Meta's Muse story is moving fast, and this episode takes a closer look at Muse Spark, the multimodal reasoning model family behind Meta's push into AI agents, including yesterday's release of an open-weight version for developers.

Oct 15, 2026

When a large language model generates text one token at a time, even a fast GPU hits a sequential bottleneck. This episode explains speculative decoding, an inference technique that prepares several tokens at once and checks them together, and when the extra computation pays off.

See all episodes →