# Latent Space An interactive 3D browser explorer for massive image embedding collections (from **1 million** to **104 million** images), a 2D hexagon map of the same collections, and the clustering, layout, naming, and incremental-update pipelines behind both. Instead of rendering one undifferentiated point cloud or a rigid 3D voxel grid, Latent Space organises an embedding map into **two navigable levels**: balanced, named rooms shrink-wrapped around their own interior shapes at the top level, and flyable leaf galleries inside each room that stream sharp thumbnails on demand over HTTP byte ranges. ![Flying through 103.6 million MONET images organised into 1,790 3D rooms](docs/preview-104m.webp) ## Published worlds The viewer runs directly in the browser on GitHub Pages, with static data hosted on Cloudflare R2 (`https://assets.latent.download/hunt/20261127a/`): | World | Images | Rooms | What it shows | Direct hash | | --- | ---: | ---: | --- | --- | | **British Library** (`world-v3-voronoi`) | 1,080,814 | 138 | 19th-century book illustrations and plates (SigLIP 2), map-aligned Voronoi cut with refined 3D interiors | `#world=world-v3-voronoi` | | **MONET 104M** (`world-monet-104m-voronoi-flat`) | 103,649,675 | 1,790 | Full web-image corpus cut directly on its 2^20 placement centroids into 1,790 rooms and 292,994 interior leaves | `#world=world-monet-104m-voronoi-flat` | | **MONET 19.3M + 7 OOD domains** (`surgery-r6-e3dbal-flat`) | 20,277,544 | 1,891 | Local-surgery experiment: 7 arriving collections (engravings, Prelinger films, galaxies, histology, chest X-rays, RxRx1/RxRx3 microscopy) added without rebuilding existing rooms | `#world=surgery-r6-e3dbal-flat` | Live: `https://enjalot.github.io/latent-space/` (3D viewer; opens MONET 104M, British Library with `#world=world-v3-voronoi`) and `https://enjalot.github.io/latent-space/hexmap/` (2D hexagon map; opens MONET 103.6M with a switch to the same map plus 8 collections, British Library with `#map=bl1m`). --- ## Run locally in 10 seconds The 3D viewer ([`visualizer/world3d/`](visualizer/world3d/)) is plain ES modules with Three.js vendored (**no build step, no `npm install`**). By default, [`visualizer/world3d/config.js`](visualizer/world3d/config.js) streams world bundles and thumbnails directly from the public Cloudflare R2 release: ```bash git clone https://github.com/enjalot/latent-space.git cd latent-space/visualizer/world3d python3 -m http.server 8000 ``` Open `http://localhost:8000/` (MONET 104M) or `http://localhost:8000/#world=world-v3-voronoi` (British Library). On a host that also serves a copy of the data at `/hunt-lab/data/` (the LAN mirror), append `?local=1` to read it instead of R2. ### The 2D hexagon map [`visualizer/hexmap/`](visualizer/hexmap/) is a pan-and-zoom map of a collection drawn as hexagons: flat colours far out, region and family names in between, one thumbnail per cell near in, and a book of every picture in a cell. It is static files too (WebGL2, no libraries, no build step) and reads a *baked* bundle by HTTP range requests, so serve it with a server that answers `Range` (plain `python -m http.server` does not): ```bash cd latent-space/visualizer/hexmap npx http-server -p 8080 . # then set dataRoot in config.js to the folder holding your bundles ``` The public build at `/hexmap/` reads its bundles from R2 (see `deploy/README.md`); locally, point `config.js` at your own bundles (`config.example-r2.js` shows an object store). To build a bundle from your own embeddings, follow [`docs/hexmap-build.md`](docs/hexmap-build.md) (`python -m hexmap all --config .toml`; examples in [`configs/`](configs/)); the format is [`docs/hexmap-format.md`](docs/hexmap-format.md). --- ## Controls | Action | Desktop | Touch / Phone | | --- | --- | --- | | Look around | Drag | Drag anywhere | | Fly | `W A S D` or arrow keys | Lower-left virtual stick | | Rise / descend | `Space` or `E` (up), `Shift` or `Q` (down) | On-screen ▲ / ▼ buttons | | Boost speed | Hold `Ctrl` or `F` | — | | Enter a room | Click a cluster shape (or aim and press `Enter`) | Tap a cluster | | Open a leaf gallery | Click a leaf inside a room | Tap a leaf | | Exit leaf / room | `Esc`, breadcrumb bar, or fly out through the glass wall | Back / breadcrumb / fly out | **Useful shortcuts:** `K` opens the settings panel (switch worlds, experiment highlights, and layout controls), `M` cycles layout modes, `L` toggles neighbour lines, `B` switches interior leaves between cubes and pictures, `H` toggles the target-hunt mode, and `P` toggles the FPS / transfer readout. --- ## How it works 1. **Map-aligned rooms from fine centroids.** Rather than clustering raw embeddings independently of the 3D map, rooms are partitioned directly on the map's finest placement centroids (2^20 centroids for MONET 104M) so rooms stay spatially coherent while keeping close visual neighbours together. 2. **Shrink-wrapped two-shell geometry.** Inside each room, images are arranged into balanced leaves on a compact 3D grid. Morphological closing plus shortest-path bridging produces two right-angled shells: a tight outer picture skin (showing sampled thumbnails from the room) and a slightly larger glass room wall that lets you fly among the leaves inside while seeing real neighbouring rooms outside. 3. **Lightweight streaming at 100M scale.** Only exposed outward faces are drawn, distant rooms use a low-res colour/tile ring, sharp surface tiles load only for the immediate neighbourhood, and full leaf thumbnails stream on demand via HTTP `Range` requests. A full world opens in a few megabytes before flight. 4. **Contrastive naming and local updates.** Rooms are named by showing a vision-language model each room's contact sheet alongside the names of its 5 nearest neighbouring rooms (naming all 1,790 MONET rooms cost under $1 with zero duplicate names). New collections can be inserted later via local surgery: near-novel domains dock inside the map beside related rooms, while far-novel domains form distinct coastal islands without moving existing rooms. --- ## Repository map | Path | Description | | --- | --- | | [`visualizer/world3d/`](visualizer/world3d/) | The 3D viewer (Three.js, static ES modules): only what the flyable page needs, plus `deploy.sh` and headless `tools/`. Its building blocks (`stage.js`, `containers.js`, `interior.js`, `enter-transition.js`, `fly-controls.js`, `thumb-atlas.js`) and vendored Three.js 0.185.1 are in [`shared/`](visualizer/world3d/shared/). See [`visualizer/world3d/README.md`](visualizer/world3d/README.md). | | [`visualizer/hexmap/`](visualizer/hexmap/) | The 2D hexagon map (WebGL2, static ES modules, no dependencies) with its own `config.js`, `deploy.sh` and smoke test. See [`visualizer/hexmap/README.md`](visualizer/hexmap/README.md). | | [`pipeline/`](pipeline/) | Everything that builds data. [`cluster/`](pipeline/cluster/): clustering sweeps, map-aligned Voronoi world builds, balanced interiors, local-surgery worlds ([`README-surgery.md`](pipeline/cluster/README-surgery.md)). [`world3d/`](pipeline/world3d/): the 3D viewer's sidecars (`build_*.py`: thumbnail refs, shapes and shells, faces, map hulls, picture tiles, per-picture info). [`naming/`](pipeline/naming/): contrastive room naming (`sample.py` -> `caption.py` -> `name.py`). [`scale/`](pipeline/scale/): occupancy and frame-sensitivity benchmarks, 1M to 104M. [`render/`](pipeline/render/), [`search/`](pipeline/search/): thumbnail atlas packer, local SigLIP 2 text search. [`hexmap/`](pipeline/hexmap/) + [`tests/`](pipeline/tests/): the 2D map's package (`python -m hexmap --config map.toml`, dependencies in `pipeline/pyproject.toml`). `textworld/`, `textnaming/`, `textpack/`, `icons/`: the text worlds. [`archive/`](pipeline/archive/): one-off campaign scripts kept as a record. | | [`configs/`](configs/) | Every machine-specific value lives here: `world3d.toml` (data root, sources, tools of the 3D pipelines, read by `pipeline/settings.py`), `text.toml` (the text pipelines, `pipeline/settings.py`), and the hexmap map configs `bl1m.toml`, `monet104.toml` (machine settings versus map configs: [`pipeline/README.md`](pipeline/README.md)). | | [`docs/`](docs/) | The hexmap format specification and the build-your-own guide. | | [`deploy/`](deploy/) | Public release tooling: R2 inventory/upload/verification (`r2.py`, `hexmap/r2.py`), 128 px thumbnail ref builder (`refs128.py`), Cloudflare cache rule helper, GitHub Pages build/publish scripts and browser checks. See [`deploy/README.md`](deploy/README.md). | | [`experiments/`](experiments/) | Kept for explaining or for the record, not maintained with the viewers: [`explainers/`](experiments/explainers/) (the story, shapes and breach pages, importing the viewer's modules), [`text3d/`](experiments/text3d/) (the 3D viewer adapted to text: OpenAlex titles, Wikipedia passages; LAN data only), [`grid/`](experiments/grid/) (the GRID prototype that lost the comparison), `render-lab/` (rendering study pages), `text-lab/` (text-worlds study pages) and `bundle/` (an Electron desktop trial). | | [`tools/`](tools/) | `playwright.cjs`: how every headless check finds Playwright (`PLAYWRIGHT=`). | | [`studies/`](studies/) | Recorded benchmark JSONs and research notes from the clustering, grid, scale, rendering, text and 2D map studies (e.g. [`studies/cluster/README.md`](studies/cluster/README.md), [`studies/scale/README.md`](studies/scale/README.md)). | | [`hub/`](hub/) | Local lab index page linking prototypes and galleries. | > **Machine paths:** the viewers under `visualizer/` are self-contained; the 3D pipelines read `configs/world3d.toml` (`python3 pipeline/settings.py world3d show`; override with `WORLD3D_CONFIG=`, `WORLD3D_=...` or `--world3d-set key=value`), the text pipelines `configs/text.toml`, and `pipeline/hexmap` its map config. The research pipelines were run on one Linux workstation against its data; to adapt them, copy the config and change the values. --- ## Building and deploying the public site See [`deploy/README.md`](deploy/README.md) for the full R2 + GitHub Pages release workflow: ```bash # Build static site pointed at the R2 release RELEASE=20261127a deploy/build-pages.sh # Verify cross-origin R2 loading in headless Chromium node deploy/check-site.mjs --live # Publish built site to the gh-pages branch deploy/publish-pages.sh --push ``` --- ## License and data credits - **Code:** Released under the [MIT License](LICENSE). - **Vendored dependency:** Three.js (`visualizer/world3d/shared/vendor/three/`) is included under its own [MIT License](visualizer/world3d/shared/vendor/three/LICENSE). - **Datasets:** Image thumbnails and embeddings displayed in the demo worlds belong to their respective dataset sources and licences, including the British Library 19th-Century Book Illustrations (public domain), MONET web-image corpus, Prelinger Archives, Galaxy Zoo 2, RxRx1 / RxRx3, NCT-CRC-HE-100K, and NIH ChestX-ray14.