The Library of Babel
An infinite repository of knowledge, each page uniquely addressed by volume, chapter, and page number. Every address resolves to the exact same text — always — without a database. The meaning is hallucinated into existence by algorithmic intelligence within your browser.
The Index
Translate a thought into a permanent coordinate within the infinite library.
How It Was Built
The Library of Babel LLM Edition is a fully client-side application — no backend, no database, no server. Every room you explore, every page you read, and every note you hear is generated live in your browser from mathematical seeds. Here is a full breakdown of how each layer works.
Three.js Rendering
Built entirely with Three.js r128. Bookshelves, floors, pillars, spiral staircases, and passage arches are assembled from custom geometry builders as raw triangle meshes — no pre-made models used.
Procedural Room Generation
Each address is a Base-128,000 number encoded as Unicode characters. A Mulberry32 RNG seeded from it derives each room's radius, height, wall types (books, hallways, stairs), center structure, and book density — fully deterministic.
Raycasting Interaction
Clicks are handled by Three.js Raycaster against invisible hit meshes. A 5px drag threshold prevents camera orbiting from triggering selections. OrbitControls provide smooth camera rotation and zoom.
Deterministic Seed
The string chamber + vol + page passes through an
FNV-1a-inspired hash to produce a 32-bit integer. This seed
is injected into the LLM prompt so the same address always yields the same text, forever.
LLM Inference — Two Modes
Local:
WebLLM (MLC) runs a quantized model via WebGPU, cached in
IndexedDB. Nothing leaves your device.
API: Any
OpenAI-compatible endpoint (Cerebras, Groq, Ollama). Cerebras recommended for near-instant streaming.
Temperature = 0 Determinism
All calls use temperature: 0.001 and a fixed seed. The model always picks the same
tokens for the same prompt — making pages permanently reproducible despite being generated live.
Procedural Fallback
Without a model, a grammar-based engine uses XORShift32 seeded from the address to assemble Borges-esque prose from vocabulary dictionaries — deterministic, instant, and permanent.
Tone.js Audio Engine
All audio is assembled live using Tone.js 14 on top of the Web Audio API. There are no pre-recorded tracks — real instrument samples are streamed from a CDN soundfont and routed through a DSP chain in real time.
Three Instrument Layers
Choir drone — real choir samples held 15–25 s, shifting
randomly across a Dorian scale.
Ancient lyre — nylon guitar plucks at 25% probability per
quarter note.
Bone flute — rare phrases at 15% probability every two
measures.
Signal Chain
All signals pass through a 600 Hz low-pass filter (stone-muffled ambience) and a convolution reverb with 18-second decay, 85% wet — simulating a vast stone hall. BPM is fixed at 50. Mute state persists to localStorage.
"The Library exists ab aeterno. This truth, whose immediate corollary is the future eternity of the world,
cannot be doubted by any reasonable mind."
— Jorge Luis Borges, The Library
of Babel