A 5.86 M-parameter open-world model that runs inside a web page. You say or type what you want (a world, an item, a style, a change) and it answers with a small, checked spec that a 3D engine builds at once. No server, no GPU, no WASM: the int8 weights (6.17 MiB) load with the page and run in plain JavaScript, p50 191 ms per request.
"a snowy island at night with a lighthouse" · "add three horses" · "make it cartoon style" · "make it harder"
| Explore: say a world, walk it | Zombies: build up, they adapt |
|---|---|
| Pirates: hold the island | Scavenger hunt: name it, it appears (10/10) |
Recorded in the browser from the live model, no edits.
Try the demo · Code · also from slm4apps: Maris3D for Blender
Terraville turns a request into one spec in a closed vocabulary, so its output is always something the engine can build:
| kind | example request | what comes out |
|---|---|---|
| world | "a hilly forest with a lake and two camps at night" | biome, terrain, water, time, plants and density, features with counts, optional game |
| item | "make me a red fridge", "spawn 3 horses" | one of 1,461 library item names (+ colour, count, style) |
| style | "make it cyberpunk", "cartoon style" | one of 14 looks (voxel, toy brick, neon city, cartoon, low poly, realistic ...) |
| live change | "make it harder", "zombies faster", "more scrap" | aspect (difficulty, speed, health, damage, spawn, scrap, wave) + direction |
| tool | "dig a big hole here" | tool + size |
| chat | "what can you do?" | one of 12 fixed replies |
Nearest stand-in is a feature. Every item request gets an item: an unknown name becomes the closest library item, and the page says "Closest I have: X" instead of refusing. Verbs do not matter: add / make / spawn / place / get me a X mean the same.
The model is the product; games are one use case. The demo ships a thin, data-driven game runtime on top (packs in
packs/*.json): the model emits the same closed tokens, the pack decides what "harder" or "a turret" means in that game.
Code never parses language; the model never writes logic.
import { TinyLM } from './src/tinylm.js';
import { validate, setObjectNames } from './src/spec.js';
const lib = await (await fetch('./models/library.json')).json();
setObjectNames(lib.names); // item names the validator accepts
const lm = await TinyLM.load('./models/terraville-tiny'); // fetches terraville-tiny.json (manifest) + terraville-tiny.bin (int8 weights)
const { spec, tokens, ms } = lm.generate('a snowy island at night with a lighthouse');
const checked = validate(spec); // { ok, spec, errors }: never trust raw output, always validate
spec is plain JSON; build it with the demo's three.js world builder or your own engine.
| architecture | encoder-decoder transformer, pre-LayerNorm, GELU, learned positions, tied output embedding |
| size | d=256, 4 heads, FF 768, 4 encoder + 3 decoder layers; 5.86 M parameters |
| input / output | lowercase characters (45 symbols, up to 112) -> closed tokens (1,607 in the output vocabulary, up to 30 per answer) |
| weights | int8 per-tensor: terraville-tiny.bin 6,471,680 bytes (6.17 MiB, 5.81 MiB gzip); manifest terraville-tiny.json 41,962 bytes |
| runtime | src/tinylm.js, plain JS, greedy decoding; token parity with the PyTorch reference is tested |
| trained | from scratch (no base model), 8 epochs, AdamW lr 1.5e-3, batch 256, 2,301 s on one Apple-silicon laptop (MPS) |
Training recipe: TRAINING.md.
All synthetic, generated by tools/gen_tiny.py: 96,640 training rows (object 38,040, world 33,716, live change 9,000,
tool 6,758, patch 4,519, chat 4,607) and 660 validation rows. Templates crossed with biome / terrain / water / time / plant /
feature words and synonyms, conversational openers, typos, 67 item verbs crossed with all items (plus made-up verbs so the
verb never names the item), popular items weighted to half of the item rows. Held out on purpose and used only in tests:
whole sentence templates, 3 verbs (conjure, whip up, materialize), and a set of synonyms (woodland, alps, wetland, icy land ...).
The item library (1,461 names, 2,141 part-list designs, 265 KiB gzip) comes from two sources: designs converted from the parts data of Maris3D (Apache-2.0, same publisher), and designs drafted by large language models from item briefs and then checked and repaired by this project's scripts; all pass the same validator (sizes, part counts, colours).
Plain-JS engine on the int8 weights (the exact code the page runs), one CPU thread. Exact = the whole spec right; field = share of fields right; valid = passes the closed-vocabulary validator. Every split mixes worlds, items, live changes and patches (the seen split also chat and tools).
| test split | n | exact % | field % | valid % | keyword rules exact % |
|---|---|---|---|---|---|
| phrasings seen in training | 437 | 94.5 | 97.9 | 100 | 24.7 |
| phrasings never seen | 300 | 91.0 | 97.8 | 100 | 56.0 |
| synonyms never seen | 360 | 23.6 | 70.9 | 99.2 | 39.2 |
| all | 1,097 | 70.3 | 88.6 | 99.7 | 38.0 |
| by kind (all splits) | n | exact % | field % |
|---|---|---|---|
| world | 669 | 68.0 | 89.9 |
| object | 248 | 73.0 | 83.1 |
| live change (adjust) | 97 | 62.9 | 75.3 |
| patch (add / remove things) | 63 | 85.7 | 87.8 |
| chat | 9 | 100 | 100 |
| tool | 11 | 100 | 100 |
| check | n | result |
|---|---|---|
| same item, verbs used in training (make / add / spawn) | 60 items x 3 verbs | 97.8 % |
| same item, verbs never seen (conjure / whip up / materialize) | 60 items x 3 verbs | 88.9 % (80.0 / 98.3 / 88.3) |
| PyTorch vs JS: same decoded specs | 1,097 requests | yes; spec-exact gap 0.1 points |
| latency per request (JS, one thread, no GPU, Apple M3) | 200 requests | p50 191 ms, p90 739 ms, p99 1,326 ms |
| model load | 1 | 20 ms |
| download (gzip): weights + manifest + library + runtime | 6.08 MiB |
Reproduce: node tools/benchmark.mjs (writes models/BENCHMARK.md); the synthetic test sets are in data/tiny/.
In-browser and offline world building, game prototyping, voice-driven 3D toys, teaching what a tiny task model can do. Not for anything safety-relevant; outputs are always validated against the closed vocabulary before they are built.
Apache-2.0 for the weights, manifest, item library, code and docs (LICENSE, LICENSES/, NOTICE; details in
docs/LICENSING.md). No base model: Terraville is trained from scratch. The demo bundles three.js (MIT, its own licence file).
People can still type game-brand style words as request words; the page shows generic labels (voxel, toy brick, ...).