AI / LLM Python

LLM Inference Playground

A hands-on system that exposes what most LLM APIs deliberately hide.

PyTorchFastAPITransformersReact

01 Background

Most LLM APIs hide the mechanics: you set a temperature slider and get text back. But understanding what's happening in the logit space (how temperature reshapes the probability distribution, why top-K and nucleus sampling behave differently in edge cases) is essential for anyone building serious LLM applications. This playground was built as an educational tool to expose these mechanics explicitly: no HuggingFace generate() defaults, manual implementations of each sampling strategy, and live tracking of time-to-first-token (TTFT) and throughput.

02 How It Works

01

Manual Logit Processing

After the forward pass, raw logits are processed manually: temperature scaling, top-K filtering, and nucleus (top-p) sampling are implemented from scratch, not using library defaults.

02

Token Generation Loop

The autoregressive generation loop tracks TTFT (latency to first token) and throughput (tokens per second) at each step, surfacing where bottlenecks occur.

03

FastAPI Backend

A FastAPI server exposes endpoints for model loading, parameter configuration, and generation, allowing the React frontend to issue real-time inference requests.

04

React Interface

The React frontend provides interactive sliders for temperature, top-K, and top-p parameters. Generated text and performance metrics update in real time, enabling side-by-side comparison of sampling strategies.

03 Results & Impact

Educational tool used to demonstrate LLM decoding mechanics in classroom settings

Manual sampling implementations reveal subtle behavioral differences vs library defaults

TTFT tracking enables fine-grained latency analysis across model sizes

React UI makes sampling strategies intuitively comparable through live parameter tuning