cd /news/large-language-models/tokentown-learn-how-llm-s-work-in-a-… · home topics large-language-models article
[ARTICLE · art-75314] src=laurentiugabriel.github.io ↗ pub= topic=large-language-models verified=true sentiment=· neutral

TokenTown –> Learn how LLM's work in a SimCity-like world

TokenTown, an interactive browser-based visualization, models a transformer language model as an isometric city where each district represents a stage of LLM inference, with a convoy carrying the hidden state through tokenization, embedding, attention, and sampling in real time. The project uses 12 dimensions, 2 attention heads, 2–12 layers, and a few hundred vocabulary words, with random weights blended with a bigram prior for readable output, and is inspired by PGSimCity.

read2 min views1 publishedJul 27, 2026

A language model laid out as a city, one token at a time

TokenTown is an isometric city where every district is one stage of a transformer language model. A convoy carries a hidden state along the roads: it is cut into tokens at the docks, cast into a vector at the foundry, stamped with its position, then driven around the layer ring (attention, residual, feed-forward, residual) once per layer, before the stadium turns it into a probability distribution and the sampler picks one token. That token drives back up the feedback highway and the whole city runs again.

Genuinely computed, live, in your browser: the tokenizer split; the embedding lookup; sinusoidal positional encoding; LayerNorm; multi-head scaled dot-product attention with causal masking over a real growing KV cache; the residual adds; a GELU feed-forward; and temperature / top-p sampling. The bars on the truck are the actual vector. The beams over the warehouse are the actual softmax weights. Prefill really does process every prompt token at once while decode really does process only one.

Scaled down: 12 dimensions instead of thousands, 2 attention heads instead of dozens, 2–12 layers instead of 80, and a vocabulary of a few hundred words instead of 100k+.

Deliberately faked: the weights are random, and nothing here was trained, so a random-weight model would emit noise. To keep the output readable, the final logits blend the real hidden-state projection with a bigram prior built from a small fixed corpus. The attention scores are also sharpened, and given a small first-token ("sink") and recency bias, so the map looks like the patterns trained models actually produce. Treat the text this city writes as scenery; treat the mechanism as the lesson.

The first time the convoy reaches a district it stops long enough to read that district's explanation, between 9 and 26 seconds depending on how much there is to say. A progress bar under the panel text shows how long the stop has left. Once every district has been explained the city runs at a watchable pace instead of a readable one, and the repeated layers fast-forward because they are the same road with different weights. Space holds any stop indefinitely, S steps one stage at a time, and the Speed slider scales everything, including the reading stops, from 0.4× to 8×. Reset (⟲) replays the slow tour from the beginning; Run keeps what you have already read.

Inspired by the idea behind PGSimCity (a city-shaped model of PostgreSQL); all code, art and copy here are original.

── more in #large-language-models 4 stories · sorted by recency
── more on @tokentown 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/tokentown-learn-how-…] indexed:0 read:2min 2026-07-27 ·