Token LabSearch

← Token Lab
TOKEN LAB / LEARN BY DOING

Learn AI engineering by doing.

LLMs, RAG, agents, evals and inference. Predict a result, change one variable, run the experiment and inspect the evidence.

50Interactive labs500Practice questions0API keys

50 experiments use 10 reusable engines; each has a distinct hypothesis and preset.

01Attention & masking02Embedding geometry03KV cache & paging04Train a neural network05Bounded agent workflows06Hybrid retrieval & reranking07LLM judge audit08Model routing & fallbacks09Quantization & outliers10Request caching & TTL

Technical scenario notes, parameter names and reference answers are currently in English.

Attention & masking

Read the method, change one input, and compare the exported runs.

01

Causal baseline

Future positions must receive zero probability.

Local calculation / simulation · Open lab ↗
02

Bidirectional context

Removing the mask exposes future keys.

Local calculation / simulation · Open lab ↗
03

Sharp attention

Larger logits concentrate probability on the largest visible score.

Local calculation / simulation · Open lab ↗
04

Flat attention

Equal visible logits yield uniform weights.

Local calculation / simulation · Open lab ↗
05

Soft attention

A smaller scale moves weights toward uniform without changing visibility.

Local calculation / simulation · Open lab ↗

Embedding geometry

Read the method, change one input, and compare the exported runs.

06

Cosine nearest neighbors

A large document norm should not dominate cosine ranking.

Local calculation / simulation · Open lab ↗
07

Dot-product norm bias

The long vector may outrank a better-aligned short vector.

Local calculation / simulation · Open lab ↗
08

Query rotation

Rotating the query changes which document aligns best.

Local calculation / simulation · Open lab ↗
09

Opposite direction

Opposite vectors receive negative cosine scores.

Local calculation / simulation · Open lab ↗
10

Zero-vector edge case

The lab returns zero scores for an undefined cosine denominator.

Local calculation / simulation · Open lab ↗

KV cache & paging

Read the method, change one input, and compare the exported runs.

11

GQA baseline

Eight KV heads use one quarter the cache of 32 heads.

Local calculation / simulation · Open lab ↗
12

Multi-head cache

More KV heads scale cache bytes linearly.

Local calculation / simulation · Open lab ↗
13

Multi-query cache

One KV head sharply reduces logical cache size.

Local calculation / simulation · Open lab ↗
14

Long-context batch

Sequence and batch size multiply memory demand.

Local calculation / simulation · Open lab ↗
15

Page fragmentation

One extra token allocates an additional page per sequence.

Local calculation / simulation · Open lab ↗

Train a neural network

Train a tiny neural network and watch its decision boundary change.

16

Learn XOR quadrants

A nonlinear hidden layer can fit this non-linearly separable task.

Actual browser training · Open lab ↗
17

Underpowered hidden layer

One hidden unit limits the available decision boundaries.

Actual browser training · Open lab ↗
18

Slow learning

A lower learning rate may need more epochs.

Actual browser training · Open lab ↗
19

Circle classification

The hidden layer can approximate a curved boundary.

Actual browser training · Open lab ↗
20

Seed sensitivity

Initialization and sampled data affect the learning trajectory.

Actual browser training · Open lab ↗

Bounded agent workflows

Read the method, change one input, and compare the exported runs.

21

Human approval gate

A write pauses without the mock approval toggle.

Local calculation / simulation · Open lab ↗
22

Authorized mock write

Approval permits only the local mock write.

Local calculation / simulation · Open lab ↗
23

Tool allowlist

A disallowed calculator call stops the workflow.

Local calculation / simulation · Open lab ↗
24

Budget exhaustion

The second paid action is blocked before exceeding budget.

Local calculation / simulation · Open lab ↗
25

Memory truncation

Only the latest result survives FIFO truncation.

Local calculation / simulation · Open lab ↗

Hybrid retrieval & reranking

Read the method, change one input, and compare the exported runs.

26

Hybrid fusion baseline

Combining independent ranks can promote shared candidates.

Local calculation / simulation · Open lab ↗
27

Lexical only

Exact query words alone set the ranking.

Local calculation / simulation · Open lab ↗
28

Dense only

Only vector direction determines the ranking.

Local calculation / simulation · Open lab ↗
29

Oracle reranking ceiling

Perfect labels can improve ordering only inside the candidate pool.

Local calculation / simulation · Open lab ↗
30

Candidate starvation

Even an oracle cannot recover documents excluded before reranking.

Local calculation / simulation · Open lab ↗

LLM judge audit

Read the method, change one input, and compare the exported runs.

31

Mixed judge agreement

Agreement and order consistency measure different properties.

Local calculation / simulation · Open lab ↗
32

Perfect agreement

Perfect labels yield agreement and consistency of one.

Local calculation / simulation · Open lab ↗
33

Always choose first

Selecting the first position fails swap consistency.

Local calculation / simulation · Open lab ↗
34

Tie-heavy dataset

A large tie class can make aggregate agreement misleading.

Local calculation / simulation · Open lab ↗
35

Consistently wrong

A judge can be order-consistent and disagree with every human label.

Local calculation / simulation · Open lab ↗

Model routing & fallbacks

Read the method, change one input, and compare the exported runs.

36

Two-tier routing

Most traffic uses the cheap path; failures add strong-model cost.

Local calculation / simulation · Open lab ↗
37

All strong model

Strong-only routing provides a simple cost baseline.

Local calculation / simulation · Open lab ↗
38

Frequent fallback

High fallback frequency can erase routing savings.

Local calculation / simulation · Open lab ↗
39

Cheap model outage

Every request pays both cost and latency before successful fallback.

Local calculation / simulation · Open lab ↗
40

No primary failures

Expected cost is a weighted average without retries.

Local calculation / simulation · Open lab ↗

Quantization & outliers

Read the method, change one input, and compare the exported runs.

41

Four-bit baseline

Fewer representable values introduce rounding error.

Local calculation / simulation · Open lab ↗
42

Eight-bit reconstruction

More quantization levels usually reduce reconstruction error.

Local calculation / simulation · Open lab ↗
43

Two-bit stress test

Only three signed levels preserve little detail.

Local calculation / simulation · Open lab ↗
44

Outlier dominates scale

An outlier enlarges the global step and collapses small values.

Local calculation / simulation · Open lab ↗
45

All-zero tensor

The zero-range safeguard reconstructs all zeros exactly.

Local calculation / simulation · Open lab ↗

Request caching & TTL

Read the method, change one input, and compare the exported runs.

46

Locality baseline

Repeated keys can avoid repeated model work.

Local calculation / simulation · Open lab ↗
47

Capacity thrashing

A tiny cache evicts useful entries before reuse.

Local calculation / simulation · Open lab ↗
48

TTL expiry

Entries expire at the next request with this interval.

Local calculation / simulation · Open lab ↗
49

High reuse workload

Temporal locality improves the hit rate.

Local calculation / simulation · Open lab ↗
50

All unique requests

Unique keys provide no exact-match cache savings.

Local calculation / simulation · Open lab ↗

Tokenizers · RAG chunking · Sampling · Evals

Local educational experiment. No external API calls. Synthetic fixtures are not production measurements.