How AI Works: Interactive Mechanics Lab
An interactive software engineering laboratory demystifying the core mathematical operations inside modern artificial intelligence: autoregressive logits & softmax sampling, high-dimensional vector embeddings, and JSON-RPC tool-calling handshakes.
Autoregressive Softmax Sampling Simulator
When a Transformer outputs raw logits $z_i$, they must be converted into normalized probability distributions via Softmax: $P(w_i) = \frac{\exp(z_i / T)}{\sum_j \exp(z_j / T)}$. Manipulate Temperature $T$, Top-P (nucleus), and Top-K to observe how sampling parameters alter determinism vs. creativity.
High-Dimensional Vector Space & Semantic Arithmetic
Embedding models project discrete words and sentences into continuous vector spaces $\mathbb{R}^d$. Concepts sharing semantic relationships cluster together. Semantic distance is measured via Cosine Similarity: $\cos(\theta) = \frac{\mathbf{u} \cdot \mathbf{v}}{\|\mathbf{u}\| \|\mathbf{v}\|}$.
Tool Calling & JSON-RPC Handshake Protocol
Large Language Models cannot directly access external APIs or databases. They interact with tools through a formal four-step structured JSON-RPC protocol handshake. Step through the execution lifecycle below.