All topics

Python

Every post tagged “Python”, newest first.

7 posts
Deep Learning 9 min

Cross-Entropy Loss Explained: From Logits to LLM Training

What is cross-entropy loss? Derive softmax and negative log-likelihood, work a 3-class example, and see why MSE fails for language model classification.

Deep Learning 11 min

Adam and AdamW Explained: How LLMs Update Their Weights

How does the Adam optimizer work? Derive momentum, RMSprop and bias correction, see why AdamW decouples weight decay, and walk a numeric update by hand.

Embeddings 15 min

Token Embeddings Explained: How LLMs Turn IDs Into Vectors

What is a token embedding? How LLMs map token IDs to learned vectors: the embedding matrix, gather vs one-hot matmul, and a from-scratch NumPy build.

Positional Encoding 12 min

Positional Encoding Explained: How Transformers Learn Order

What is positional encoding in transformers? Why attention is order-blind, learned vs sinusoidal embeddings, and a from-scratch NumPy implementation.

Tokenization 21 min

Byte Pair Encoding (BPE) Explained: How GPT Tokenizers Work

What is byte pair encoding (BPE)? How GPT tokenizers turn text into IDs: pretokenization, merge rules, byte-level vocab, and a from-scratch build.

Deep Learning 14 min

Numerical Gradient Checking: Debug Your Autograd Engine

What is numerical gradient checking? The central difference formula, why you never train with finite differences, and a grad checker that catches real bugs.

Deep Learning 31 min

Backpropagation from Scratch: Build an Autograd Engine

How does backpropagation work? Build a working autograd engine from scratch in ~80 lines of Python: computation graphs, chain rule, reverse-mode autodiff.