AI Engineering

LLM fundamentals

A real BPE tokenizer on English, Hindi, Hinglish and code; temperature/top-p on a toy distribution; prefill vs decode; KV-cache and GPU memory maths; structured output by token masking; SSE streaming; cosine similarity; a voice latency budget.

Real vs simulated: Token counts use a real o200k_base tokenizer. Sampling, streaming and the masked decoder run on toy distributions; the memory maths uses published model shapes.

Encoding
o200k_base: GPT-4o family. cl100k_base: GPT-4 / 3.5. Claude, Gemini and Llama use their own — counts differ.
Samples
Loading the o200k_base tokenizer…