AI Lab

Machine learning you can poke

Three interactive demos written from scratch in vanilla JavaScript — no libraries, no API keys, no server. Everything trains and runs locally in your browser.

Neural networks from scratch k-means clustering TF-IDF retrieval Runs at 60fps

Neural network, trained live

A 2-input multilayer perceptron (tanh hidden layer, sigmoid output) trained with gradient descent on two synthetic Gaussian clusters. Watch the decision boundary form as the loss falls.

Loss0.693
Accuracy50%
Epoch0

Implementation: forward pass, backpropagation and SGD written by hand — no TensorFlow, no PyTorch.

k-means clustering, animated

Lloyd's algorithm running step by step on four synthetic clusters. Change k and watch the centroids converge — the inertia readout shows how much tighter the clusters get.

Iteration0
Inertia0.0

Same code path as a real clustering job: initialise centroids, assign, update, repeat until convergence.

A retrieval pipeline you can inspect

Paste any text. It gets chunked, indexed with TF-IDF, then ranked against your query with cosine similarity — the lexical half of a RAG system, before an LLM ever sees it.

Chunks0
Vocabulary0

Production RAG swaps TF-IDF for embeddings and a vector database; the chunking, ranking and prompt-assembly steps stay the same.

Ranked passages

Build the index, then ask a question.

CNN calculator & convolution visualiser

Size a convolutional stack layer by layer — output shapes, parameters, multiply-accumulates and receptive field — then watch a kernel actually slide across an image and produce a feature map.

input tensor
Layer Output shape Params MACs Receptive field
Total params0
Total MACs0
Final shape—
Receptive field—

Architecture

Convolution in motion

Input (6×6)

Kernel (3×3) over patch

Feature map (4×4)

Same arithmetic the calculator uses: one output pixel is the sum of kernel × patch at the current stride position. The highlighted cell is the position being computed right now.

Log parser → structured JSON

Paste mixed-format logs — app lines, JSON lines and nginx access lines. The parser pulls out timestamp, level, status, latency, service and path, so you get JSON you can query instead of a wall of text.

Parsed output


                    

Same job as a log analytics pipeline: regex for the known shapes, JSON for structured lines, and inferred severity when a line declares none (5xx → error, 4xx → warning).

Embedding similarity explorer

Each sentence becomes a vector through signed feature hashing, ranked against your query by cosine similarity — the mechanism behind semantic search, cheap and deterministic.

2-D projection of the corpus

Nearby points share vocabulary; your query lands close to the passages that overlap with it.

Gradient descent on a curved valley

A Rosenbrock-style loss surface: the steepest direction is not the direction to the optimum. Shrink the learning rate and watch it crawl; raise it and watch it diverge; add momentum and feel the difference.

Loss surface with the descent path

Loss—
Iterations0

Loss per iteration

The same loop that trains every model on this site: compute the gradient, step against it, repeat.

Prompt & token playground

Write the three parts of a grounded prompt, choose the output shape, and copy the finished scaffold. Token and cost figures are estimates for sizing, not billing truth.

Output shape

Est. tokens0
Words0
Est. input cost$0.0000

Checks

    Assembled prompt

    
                    

    Pricing shown is indicative only, for sizing — always check your provider's current rates.