AI engineering

  1. Tokenisation (BPE): Train byte-pair encoding merge by merge on your own text, then see English, Hindi, code and numbers split into tokens.
  2. Embeddings: Hand-made word vectors you can read: cosine vs dot product vs distance, neighbours, analogies and semantic search, plotted with PCA.
  3. Attention: Scaled dot-product attention by hand: Q·Kᵀ, scaling, the causal mask, softmax row by row and two heads, as a heatmap.
  4. Sampling: Next-token logits through temperature, top-k, top-p and repetition penalty, then a seeded draw, with entropy.
  5. KV cache: Prefill vs decode step by step: what the KV cache saves, how its memory grows, time to first token and tokens per second.
  6. Retrieval and RAG: BM25 by hand, dense search, hybrid with Reciprocal Rank Fusion, reranking, chunking strategies and the RAG prompt with citations.
  7. HNSW vector search: Build a layered small-world graph from random points, then watch a search hop down the layers, against brute force.