Apex › Storage & databases
How attention works (transformers)
The core of every transformer and LLM. Each token emits a query, a key, and a value; a token attends to another by how well its query matches that key (a dot product), the scores are scaled and softmaxed into weights that sum to 1, and the token’s new representation is the weighted blend of everyone’s values. Real scaled dot-product attention over a 6-token toy: “river” attends to the water words, “money” to the finance words, and ambiguous “bank” to both. Pick the query token and watch the weights and the blended output.
More in Storage & databases
- B+tree index
- How a hash index grows (extendible hashing)
- How Git stores your code
- LSM-tree
- Page replacement
- MVCC isolation
- Write-Ahead Log
- Skip list
- Locking & deadlock
- When is an interleaving safe? (conflict serializability)
- Join algorithms
- How to join tables bigger than RAM (grace hash join)
- Query planner (cost)
- RUM amplification
- Trie (prefix tree)
- HAMT (persistent map)
- Hash table collisions
- Cuckoo hashing
- Cuckoo filter
- Robin Hood hashing
- Geohashing
- k-d tree (nearest neighbor)
- Union-Find
- Fenwick tree
- Sparse table (RMQ)
- Cartesian tree (RMQ=LCA)
- Roaring bitmaps
- Bitmap index
- Columnar storage (Parquet)
- Learned index
- Binary heap
- Pairing heap (mergeable)
- Segment tree
- Interval tree
- AVL tree
- Splay tree
- Treap (randomized BST)
- Piece table (text editor)
- Rope (text editor tree)
- Gap buffer (Emacs)
- The sort in your standard library (Timsort)
- Sorting algorithms
- Kadane (max subarray)
- Longest increasing subseq
- Quickselect (k-th)
- Median of medians
- Dutch national flag
- Shuffle bias (Fisher–Yates)
- Alias method (weighted sampling)
- Estimating π by throwing darts (Monte Carlo)
- Fitting a line through 50% outliers (RANSAC)
- KMP string search
- Rabin-Karp
- Aho-Corasick
- Boyer-Moore search
- Suffix array
- Manacher (palindromes)
- Z-algorithm
- Edit distance
- How diff works (git diff, code review)
- How fuzzy search finds typos (BK-tree)
- 0/1 Knapsack (DP)
- Topological sort
- A* pathfinding
- How a SAT solver works (DPLL)
- Max-flow / min-cut
- Minimum spanning tree
- Strongly connected comps
- 2-SAT (implication graph)
- Floyd-Warshall (all-pairs)
- Cycle detection (tortoise & hare)
- Bellman-Ford & arbitrage
- How Google first ranked the web (PageRank)
- How k-means finds clusters (unsupervised)
- Clustering any shape + finding outliers (DBSCAN)
- Soft clustering with Gaussians (GMM / EM)
- How PCA compresses data (principal components)
- How SVD compresses an image (low rank)
- The first neural net (perceptron & XOR)
- From a hard line to a probability (logistic regression)
- The widest street between classes (SVM)
- How a decision tree splits data (Gini)
- Why a forest beats one tree (bagging)
- Learning from residuals (gradient boosting)
- Newton's method
- How conjugate gradient beats zigzag descent
- How linear programming finds the best plan (simplex)
- Fast Fourier Transform
- Two oscillators, a thousand timbres (FM synthesis)
- Multi-resolution & compression (Haar wavelet)
- How a phone hears touch-tones (Goertzel)
- How a tuner hears pitch (autocorrelation)
- How to synthesize a plucked string (Karplus-Strong)
- The shape of every note (ADSR envelope)
- How reverb puts you in a cathedral (convolution)
- The filter inside every EQ (biquad)
- Fast inverse square root
- Kahan summation
- How calculators do trig (CORDIC)
- Karatsuba multiplication
- Simulated annealing
- How game AI searches (alpha-beta)
- How a neural network learns (backprop)
- How word embeddings work (word2vec)
- How vector search finds nearest embeddings (HNSW)
- Mixture of Experts (MoE)
- Speculative decoding
- KV cache & PagedAttention
- Weight quantization (int4/int8)
- Bresenham line drawing
- How curves are drawn (Bézier & de Casteljau)
- How ray tracing renders an image
- How a GPU rasterizes a triangle
- How 3D becomes 2D (perspective & the texture warp)
- How GPUs smooth jagged edges (MSAA)
- How game physics simulates rope & cloth
- How galaxies simulate gravity fast (Barnes-Hut)
- Why the weather is unpredictable (chaos)
- Why simulated orbits drift (symplectic integrators)
- How ray-marching renders with math (SDF)
- How 3D rotation really works (quaternions & slerp)
- Convex hull
- How games detect collisions (SAT)
- How games skip the n² collision test (spatial hash)
- Marching squares
- Voronoi diagram
- Delaunay triangulation
- Generating maps by constraints (wave function collapse)
- Perlin noise
- Poisson-disk sampling