# latent-basemap This repository holds the code for building a stable 3D map of a large collection of embedding vectors, scoring it, cutting it into hierarchical rooms, and adding data to it without moving what is already there. The method, called "the recipe" below, places a hierarchy of centroids on the map (a "chain") and then places every row among its nearest centroids. It was developed in November 2026 on image embeddings (MONET, 103.6M images, DINOv2 ViT-g/14) and text embeddings (MiniLM, Jina, OpenAlex). The canonical, self-contained implementation is [`basemap/recipe`](basemap/recipe), with a command line (`python -m basemap.recipe `). Historical campaigns, earlier manuscripts, and the open-sourced research notebook live separately under [`research/`](research/README.md) and [`basemap/legacy/`](basemap/legacy). This is a research repository. It is not a packaged release, the data is not included, and no licence has been chosen yet (see the end of this page). **Research history & open questions.** The full experimental history is preserved under [`research/`](research/README.md): open research directions in [`research/OPEN_QUESTIONS.md`](research/OPEN_QUESTIONS.md), the sanitized lab notebook and campaign reports in [`research/lab-notes/`](research/lab-notes/README.md), campaign code in [`research/campaigns/`](research/campaigns/), the October README in [`research/docs-2026-10/README-2026-10.md`](research/docs-2026-10/README-2026-10.md), the August 2D 100M manuscript in [`research/paper-2026-08/paper.md`](research/paper-2026-08/paper.md) (with its [`REVIEWER_GUIDE.md`](research/paper-2026-08/REVIEWER_GUIDE.md)), and the stored-embedding lens documents under [`research/docs-2026-10/`](research/docs-2026-10/) (start with [`EMBEDDING_LENS_RESULTS.md`](research/docs-2026-10/EMBEDDING_LENS_RESULTS.md) and [`LENS_BUNDLE.md`](research/docs-2026-10/LENS_BUNDLE.md)). The recipe reuses one piece from that earlier line: the small network that positions the coarsest centroids is a parametric-UMAP network of that kind (loaded by [`basemap/recipe/models.py`](basemap/recipe/models.py)). ## The recipe in one paragraph Vectors are unit length. Centroids are fitted at several grains with spherical e-means, for example 2^15, 2^18 and 2^20 centroids; the list of grains is the chain, written fine to coarse as `c20-18-15`. A trained network gives the coarsest centroids their 3D positions. Each finer centroid is then placed among the positions of its 15 most similar coarser centroids, and each row among its 15 most similar finest centroids, by one local rule. The map is scored by how many of a row's map neighbours are among its true nearest 0.1% of rows. New data is added by "local surgery": centroids are appended for the unfamiliar part of an arriving batch and placed near the existing centroids they most resemble; existing centroids and rows keep their positions. ## Requirements - Python 3.10+ (developed and tested on Python 3.12) with numpy, torch, scipy, scikit-learn and threadpoolctl. Either install in editable mode (`pip install -e ".[recipe]"`) or run from the repository root with `PYTHONPATH=.`. - Linux for multi-process row placement (which uses `fork`); pass `--threads 1` to run row placement in-process on any OS or to avoid forking after CUDA initialization. - For the `levels` step: faiss with `faiss.contrib.e_means`, which `faiss-cpu` 1.16 from PyPI ships (1.13 does not); it is in the `recipe` extra, so `pip install -e ".[recipe]"` covers every step (checked 2026-11-29 in a clean venv: levels, the 2D and 3D tests). `build --levels-python /path/to/python` still runs that one step with another interpreter. - A CUDA GPU for anything beyond a few million rows. Every step also runs on the CPU (`--device cpu`), which is how the test runs. - Vectors as `.npy` files of unit rows, float16 or float32. Several `--vectors` parts are read as one array in the order given; a part may join files with commas (`head.npy,tail.npy`) and map rows through an index (`store.npy@rows.npy`: row i of the part is row `rows[i]` of the store). - For `top --umap`: umap-learn 0.5.12 (in the `recipe` extra). To verify an environment in ~5 seconds on CPU without any external data, run the end-to-end smoke test: ```bash PYTHONPATH=. python -m pytest -q tests/test_recipe_smoke.py ``` The package holds no machine paths: every input comes from a command-line argument or the map directory. The workstation paths the campaigns used are in [`research/campaigns/2026-11_recipe/recipe_canonical_20261127/gsv_paths.py`](research/campaigns/2026-11_recipe/recipe_canonical_20261127/gsv_paths.py). ## Building a map, step by step The numbers in the "measured" column are from one run: the 103.6M-row MONET map built on 2026-11-19/20 on one RTX 5090 (32 GB), with 12 CPU processes for placement (run N1; sources at the end). That run was made by `research/campaigns/2026-11_recipe/ruler_20261109/n1.py`, which calls the same placement functions this package holds. The command line shown here has been run end to end only at test size; see "Status and limits". | Step | What it does | Parameters | Measured at 103.6M rows | | --- | --- | --- | --- | | 0. PCA (MONET only) | Projects 1,536-d DINOv2 vectors to 768-d with a PCA fitted once on a 6M-row random sample and never refitted; renormalizes to unit length | 1536 to 768 | 269 s for 25.7M rows on CPU | | 1. Levels | Spherical e-means per level, 3 passes, streamed in 65,536-row blocks | 2^15, 2^18, 2^20 centroids | 652 s, 819 s, 3,080 s GPU wall; peak GPU memory 1.2, 4.4, 16.4 GB | | 2. Top | A trained network maps the 2^15 centroids to 3D | network "N6": residual bottleneck MLP, 768 in, width 2048, depth 3, bottleneck 1536, 3 out, 12.6M parameters | applying it: 1.7 s on CPU (measured for this README). Training it: 11,072 s on the GPU, 6M rows, 650,874 updates, peak 19.8 GB | | 3. Chain | 2^18 placed against 2^15, then 2^20 against 2^18 | 15 nearest coarser centroids, radius fraction 0.45 | 79 s on CPU | | 4. Rows | Exact 15 nearest 2^20 centroids for every row, then placement | 15 centroids, radius fraction 0.45 | search 2.3 GPU-hours (87 s per million rows); placement 1,883 s with 12 processes | | 5. Score | Truth sets and map neighbours for 4,096 query rows | k = 15, 100, 400, 2,000, 10,000 | truth 3 minutes; 0.66 GPU-hours for three maps including a 1% share this package does not compute | The whole run, with three failed attempts counted, used 6.92 GPU-hours and about 75 CPU core-hours. ```bash MAP=./monet-map # any directory; a map is a directory of .npy / .npz / .json files X=./pca768.f16.npy # unit rows, float16 or float32 # 0. MONET only: frozen PCA 1536 -> 768 python -m basemap.recipe pca --model pca768-model.npz --input dino1536.f16.npy --output $X # 1. centroid levels (needs faiss.contrib.e_means) python -m basemap.recipe levels --map $MAP --vectors $X --sizes 32768,262144,1048576 # 2. positions of the coarsest level from a trained top network python -m basemap.recipe top --map $MAP --model model-u650874.pt # 3. the chain: every finer level against the level above python -m basemap.recipe chain --map $MAP # 4. every row against its 15 nearest finest centroids python -m basemap.recipe rows --map $MAP --vectors $X # steps 1 to 4 in one command python -m basemap.recipe build --map $MAP --vectors $X --sizes 32768,262144,1048576 --model model-u650874.pt ``` Outputs in `$MAP`: `levels//centroids.npy` (unit float32) with `fit.json`; `top.npy`; `world.npz` (float64 positions of every level, `W` is the finest); `top15.i32.npy` and `cos1.f32.npy` (each row's 15 nearest finest centroids and its cosine to the nearest); `layer.f32.npy` (float32 `(rows, 3)` positions in the order of the vectors); `recipe.json`. ## A 2D map Every step takes the map's dimension from `recipe.json` (`map_dim`, set by `levels`, `init`, `top` or `build` with `--dim`); `chain`, `rows`, `score`, `rooms` and `update` follow the width of `top.npy` and work in the plane directly (no padding). The built-in 2D top layout is UMAP of the coarsest centroids (cosine, spectral init, 15 neighbours, min_dist 0.1, seed 0; recorded in `recipe.json` `top_umap`). A layout made elsewhere can be given with `top --positions file.npy` (`(k, 2)`). ```bash MAP=./map2d; X=./vectors.f16.npy python -m basemap.recipe center --map $MAP --vectors $X # optional: narrow-cone encoders (see below) python -m basemap.recipe levels --map $MAP --vectors $X --sizes 32768,262144,1048576 --dim 2 python -m basemap.recipe top --map $MAP --umap python -m basemap.recipe chain --map $MAP python -m basemap.recipe rows --map $MAP --vectors $X python -m basemap.recipe score --map $MAP --vectors $X # queries-pos.npy, truth-top.i32.npy, scores.json python -m basemap.recipe rooms --map $MAP # rooms.npz (needed before update) # add a collection: a new map directory, the source is not modified python -m basemap.recipe update --map $MAP --vectors new.f16.npy --out ./map2d-plus ``` Outputs are the 3D ones with `(n, 2)` positions: `top.npy`, `world.npz`, `layer.f32.npy`. `update` writes the appended `levels//centroids.npy`, `world.npz`, `layer.f32.npy` (existing rows first, byte for byte), `top15.i32.npy`, `cos1.f32.npy`, `rooms.npz`, `update.json` (placement mode, counts, stability) and, when a far-novel collection arrives, `outskirt_islands.{json,npz}`. In the plane a far-novel collection becomes an island on a ring of 256 directions at the 95th-percentile room distance plus 5 room radii (the 3D map uses a Fibonacci shell), laid out by its own 2D PCA; a related one docks beside it over the outward half-plane; familiar material docks inside the map by rule `1c`, as in 3D. **Starting from an existing build's levels.** `init` makes a new map directory that links (or with `--copy` copies) another directory's `levels//centroids.npy`, and optionally its row search and parent lists, so `top`, `chain` and `rows` run without refitting or searching: ```bash python -m basemap.recipe init --map ./map2d --from /path/to/build --levels 15,18,20 --dim 2 \ --top15 /path/to/build/top15-20.i32.npy --cos1 /path/to/build/cos1-20.f16.npy \ --parents /path/to/build/graphs.npz --parent-keys par18_15,par20_18 python -m basemap.recipe top --map ./map2d --umap python -m basemap.recipe chain --map ./map2d # uses parents.npz when present python -m basemap.recipe rows --map ./map2d --vectors # no search when top15.i32.npy exists ``` **Centring.** `center` stores the mean of the base vectors (`center.npy`, `center.json` with the cone score: the norm of the mean of unit rows, before and after). Every later step that reads vectors through that map subtracts it and renormalises, including the arrivals of `update`. Off by default; `levels` and `rows` print a warning when the cone score of the vectors is above 0.3 and the map is not centred. ### The placement rule One rule places a finer centroid among coarser ones and a row among finest centroids ([`basemap/recipe/place.py`](basemap/recipe/place.py), working name `micro_source10`). For a point with vector `v` and its K = 15 most similar anchors, nearest first: 1. The center is the map position of the nearest anchor. 2. The radius is 0.45 times the distance on the map from that anchor to its nearest other anchor. 3. The offset comes from a ridge regression. The anchors' vector offsets from the nearest anchor are regressed onto their map offsets, with rank weights `1 / (rank + 1)` for `rank = 0..14` (normalized to sum to 1) and a ridge of `0.10 x trace / 14` of the weighted system. The point's own vector offset is passed through that fit to get `direction`, then squashed to length below 1 via `direction / sqrt(scale2 + ||direction||^2)`, where `scale2` is the weighted mean squared map distance of the anchors from the nearest anchor. 4. Position = center + radius x offset. So a point never leaves the cell of its nearest anchor, and its direction inside the cell follows where its other 14 anchors sit. Twelve alternative rules over the same 15 anchors were tested and none beat it by the preset margin (run T6). ### The top network Training the top network is not part of `basemap/recipe`. The network used for MONET was trained by `research/campaigns/2026-11_recipe/ruler_20261109/t2.py` (`fit`) with the parametric-UMAP trainer under `basemap/legacy/pumap` on a 6M-row sample. `top --model` applies a saved checkpoint via [`basemap/recipe/models.py`](basemap/recipe/models.py); `top --positions file.npy` accepts any `(k, 3)` array for the coarsest level. `top --pca3` is a stand-in for tests and has not been scored. Without a chain the network alone scores far below it at close range (table below). A chain whose top is a UMAP layout of the centroids instead of a network was also tested on three text spaces: it held to 400 neighbours and failed one space at 2,000 (run L2). That variant is not in this package. ## How a map is scored Defined in [`basemap/recipe/score.py`](basemap/recipe/score.py). For a map of n rows and a query that is one of those rows (its own row is excluded everywhere): - **Truth set.** The query's `max(15, n // 1000)` most similar rows by inner product of the unit vectors the map was built from: its true top 0.1%, most similar first, computed exactly in float32. - **Wider score at k.** The share of the query's k nearest map rows (Euclidean distance in 3D, exact) that are in its truth set, for k = 15, 100, 400, 2,000 and 10,000. - **B15.** The share of the query's 15 nearest map rows that are among its 15 most similar rows. Reported numbers are means over queries, times 100. The wider score is a precision: at k = 15 it asks whether the closest things on the map are among the query's true top 0.1%, not whether they are its top 15, which is what B15 asks. ```bash python -m basemap.recipe score --map $MAP --vectors $X --queries 4096 ``` Writes `queries-pos.npy`, `truth-top.i32.npy`, `scores.npz` (per query) and `scores.json`. Measured scores: | Map | Rows | Queries | 15 | 100 | 400 | 2,000 | 10,000 | B15 | | --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | | MONET `c20-18-15`, queries at their own rows | 103,649,675 | 4,096 | 99.58 | 98.23 | 93.51 | 84.98 | 68.58 | 10.23 | | Same map, same queries re-placed through a product-quantized shortlist of 50 centroids | 103,649,675 | 4,096 | 99.51 | 98.13 | 93.51 | 84.88 | 68.51 | 9.47 | | Top network alone, no chain | 103,649,675 | 4,096 | 77.89 | 77.85 | 77.72 | 76.95 | 73.71 | 1.09 | | MONET `c18-15` (the map the updates were tested on) | 19,334,153 | 1,536 | 98.70 | 94.99 | 87.80 | 70.85 | 52.85 | 12.87 | The chain is much better than the network alone up to 2,000 neighbours and worse at 10,000. A single network trained over the finest centroids did not replace the chain: it won only at 10,000 and beyond (run Q25). ## Rooms A room is a set of finest centroids and the rows assigned to them, used as the unit of display, naming, downloading, and obstacle-sphere avoidance during updates. [`basemap/recipe/rooms.py`](basemap/recipe/rooms.py) unifies the hierarchical room cut used for the published 3D world (`world-monet-v1-e3dbal`) with local surgery's obstacle-sphere spacing and per-arrival balancing: 1. **Level-1 containers (`balance_map_containers`, E3 `D-map-bal`).** Live finest centroids are grouped into up to 16,384 micro-cells when larger than that, cut by mass-weighted 3D k-means (`n_init=4`) into target containers (`150` at scale, or `~k_rooms / 14` on smaller maps), and balanced on the 3D 15-NN Gaussian contact graph: dwarfs under `0.3 x mean` merge into the surviving container they share the most 3D edge weight with; giants over `2.5 x median` split into `ceil(size / (1.5 x median))` parts (`138` containers on 19.3M MONET). 2. **Level-2 rooms inside each container (`cut_rooms_hierarchical`).** Within each container, its finest centroids are cut by mass-weighted 3D k-means (`n_init=2`) into `round(target_rooms x mass_c / total)` rooms, giving compact pre-merge rooms (`node_room`). 3. **Display dwarf merge & obstacle-sphere decoupling.** Rooms below `0.3 x mean` (`2,839` rows on 19.3M MONET) merge smallest-first into the non-dwarf room of the *same* container sharing the most 3D 15-NN edges, yielding balanced display rooms (`node_room_display`: `1,805` rooms on 19.3M MONET, `2,848 / 9,224 / 43,591` min / median / max). Obstacle spheres (`room_stats`, radius = `1.5 x` weighted RMS distance; spaced with scale `1.5`, gap `1.3`) are built on the compact pre-merge rooms (`node_room`) so merged dwarfs across pockets cannot inflate bounding spheres during updates (the Round 5 decoupling finding). 4. **Legacy flat cut (`--flat`).** Passing `--flat` runs the earlier 1-level mass-weighted 3D k-means cut (`cut_rooms_kmeans`, `1,933` rooms on 19.3M MONET) used by rounds 1–4 of local surgery before the E3 cut was unified into this package. ```bash python -m basemap.recipe rooms --map $MAP # unified hierarchical cut (e3dbal), ~10,000 rows/room python -m basemap.recipe rooms --map $MAP --flat # legacy 1-level k-means cut python -m basemap.recipe rooms --map $MAP --labels rooms.npy # or bring a room id per finest centroid ``` ## Adding data: local surgery `update` adds one batch of rows. It requires `rooms.npz` (run `rooms` once on `$MAP` first), writes a new map directory, and leaves the source untouched. ```bash python -m basemap.recipe update --map $MAP --vectors new.f16.npy --out $MAP-2 python -m basemap.recipe score --map $MAP-2 --vectors $X new.f16.npy --groups 19334153 ``` The parameters are frozen in `basemap/recipe/config.py` (`FROZEN_UPDATE_SETTINGS`, a copy of `frozen-settings-r6-outskirts.json`, SHA-256 `ea249384...f351`). A settings file that differs from them is refused unless `--allow-variant` is given. The steps ([`basemap/recipe/update.py`](basemap/recipe/update.py)): 1. **Novelty, "fit-all".** One candidate centroid per 64 arriving rows is fitted on the whole batch (plain spherical k-means, 5 passes). A candidate is kept when at least 30 of its rows are at least as close to it as to their nearest existing finest centroid and those rows gain at least 0.033 in cosine on average. Kept candidates become new finest centroids. A batch of familiar material keeps none. 2. **Coarse anchors and far-novel outskirt seeding (Round 6).** About one anchor per 32 new finest centroids is fitted on the rows of kept candidates. Each batch is classified purely from embedding geometry (`far_ratio = median(d15_t0 / d_int)`, the ratio of each anchor's mean chord distance to its 15 nearest base coarse centroids to its 1-NN sibling distance within the batch): - **Near-novel (`far_ratio < 2.5`):** each anchor starts at the mean map position of its 15 most similar existing coarsest centroids, weighted by cosine clipped to `[0, 1]` to the 4th power (rule `1c`), and is pushed to 1.2 radii from the center of any existing room sphere it lands inside. - **Far-novel matching a prior outskirt island (`far_ratio >= 2.5` and best prior island has `median(d1_prev / d1_t0) < 0.95`):** anchors are laid out by local 3D PCA, Procrustes-aligned to their rule-`1c` projection onto the matched island, and docked cleanly beside that island on the coastal rim (for example, RxRx3 automatically pairs beside RxRx1). - **Far-novel new domain (`far_ratio >= 2.5`, no prior island closer than the base map):** anchors are laid out by local 3D PCA and seeded as a distinct coastal island on an open Fibonacci sector at `R_shell_p95 + 5.0` with at least `4.5` units of clearance from all base rooms and maximal angular separation from prior outskirt islands. Sequential `update` calls persist placed islands in `outskirt_islands.{json,npz}`. 3. **Chain.** New finest centroids are placed against the new anchors with the build's rule (15 nearest, radius 0.45). 4. **Top up.** If the new finest centroids attract more than 100 rows each on average, the overfull ones are split into 2 to 8 children placed under them. 5. **Rows.** Each arriving row is placed against 15 centroids from one side only: the new centroids if they hold at least 8 of its 15 nearest (or 7 with a new centroid nearest), the existing ones otherwise. 6. **Rooms.** New centroids are cut into rooms of about 10,000 rows by 3D k-means; all room spheres are respaced with the original rooms held by a spring to their original places. For display, the new rooms of one arrival are then balanced among themselves: rooms over 23,060 rows are split, rooms under 2,839 rows are merged into the nearest new room (decoupled from the compact obstacle spheres). Existing centroids, their positions and existing rows are never written. What does shift slightly is the spaced layout of room spheres (median 0.0001 room radii, 95th percentile 1.29 radii under compact obstacle spheres / 0.92 radii under balanced RMS spheres in Round 6; `room_dist_spearman = 0.9999`). ### Measured strengths Two test beds. "Outside collections": seven image collections from outside MONET (British Library book images, two cell microscopy sets RxRx1 and RxRx3, histopathology, galaxy images, chest X-rays, archive film stills) added to the 19.3M-row MONET map (`c18-15`). "Withheld MONET": a 15.6M-row MONET map built without 12 domains, to which 3.77M rows (the 12 domains plus more of familiar ones) are added. "Rebuild" is a full rebuild of the map with the new data included. - In every run of rounds 1 to 6, 100.0% of existing rows had zero displacement. In the viewer's world, all 1,815 untouched tile files were byte-identical after seven arrivals. - Withheld MONET: a 500,000-row batch of familiar images created 0 new centroids and 0 rooms on 3 of 3 seeds. - Five outside collections added alone (the two microscopy sets, histopathology, galaxies, X-rays): 99.49% to 99.99% of their rows went to new centroids, and the wider score at 15 was within 2 points of a rebuild on all five (differences +1.48, +0.42, +2.72, -0.31, +11.07). - Withheld MONET, the whole 3.77M-row batch: 1.05% of familiar rows and 93.35% of withheld-domain rows went to new centroids. - Seven outside collections in sequence, both orders, three seeds (Round 4/5): the worst loss on an earlier arrival was 0.08 at 15 and 0.16 at 100; the largest difference between the two orders at 15 was 0.76 on arrival and 0.32 at the end. - End-to-end Round 6 run (forward sequence, seed 0, wider score at 15 / 100 / 400 / 2,000 / 10,000 after all seven arrivals, with deltas against Round 5): - **Existing MONET (19.3M):** 98.78 / 95.16 / 88.11 / 71.34 / 53.52 (0.00 to -0.01 vs R5, 100% unmoved). - **Near-novel (docked inside):** British Library 98.93 / 94.28 / 85.45 / 73.27 / 42.77 (+0.28 to +1.18 at 100..10,000), film stills (Prelinger) 97.97 / 90.24 / 76.31 / 51.90 / 23.41 (unchanged). - **Far-novel (outskirt islands):** RxRx1 98.40 / 93.61 / 85.96 / 76.24 / 57.61 (+12.65 at 10,000), histopathology (NCT-CRC) 98.93 / 97.45 / 91.57 / 76.72 / 59.38 (+11.66 at 10,000), RxRx3 (auto-paired beside RxRx1) 95.54 / 89.16 / 73.98 / 63.18 / 46.88 (+8.29 at 10,000), galaxies (GZ2) 96.27 / 91.24 / 78.74 / 66.15 / 46.00 (+9.49 at 10,000), chest X-rays (NIH CXR) 96.96 / 95.40 / 89.67 / 77.47 / 59.74 (+3.49 at 10,000, +4.57 at 2,000). - Cost: adding 250,000 British Library rows took 21.3 s on the GPU workstation, of which 9.5 s was CPU row placement (measured for this README by replaying the saved run, scoring excluded). Running all seven arrivals sequentially on CPU in Round 6 took 266.8 s end-to-end (including exact scoring). Fit-all on 3.77M rows took 43 s on GPU. ### Measured shortfalls - **Middle range against a rebuild.** At 100 and 400 neighbours new material often scores below a rebuild. In round 1: British Library -2.29 / -4.23, RxRx1 -3.95 / -5.32 at 15 / 100, a second encoder (SigLIP 2) -3.02 / -8.07. With round 4's gated settings the galaxy set was still 3.67 below a rebuild at 100. - **Fit-all costs range on two sets.** On the two microscopy sets it scores 1.55 to 2.81 lower at 100 and 400 than the earlier gated test, because the denser repair step no longer triggers. - **Arrival in pieces.** On withheld MONET, the batch arriving over 8 rounds ends at 97.6 / 94.1 / 84.3 on its new rows against 98.6 / 93.8 / 85.3 in one batch. An optional end-of-sequence refit exists only in the experiment scripts. - **One-sided row placement is the weakest setting.** It passed its preset rule with exactly the two gains required, and it loses 0.90 / 1.42 / 0.59 when combined with the end-of-sequence refit. Its real gains are on near-novel material (British Library +0.74 / +2.50 at 100 / 400). - **Round 6 validation scope.** Round 6 outskirt seeding replaced Round 3's failed `1r` rim rule (which remains off) and beat Round 5 on every far-novel domain while separating the hubness pile-up, and it is adopted in the interactive surgery world builder. However, it has been run on one seed in the forward 7-dataset order on CPU (`sequence_forward_r6.json`) plus a 2D plane test (`research/campaigns/2026-11_recipe/map2d_20261128/`), not yet across the full two-order, three-seed matrix that Round 4 ran. Pass `--allow-variant` with `far_novel_outskirts: false` to reproduce Round 5's interior-only placement. - **Large familiar batches are slow under fit-all.** Scaled from measurements, a 34M-row familiar batch would cost about 28 GPU-minutes against seconds for the gated test. Batches of at most 5M rows are the measured range. - **Not run:** an update of the 103.6M-row map (a paper forecast only); more than 24 rounds; the final settings on a second image encoder; the final settings on text. - **Text and encoder changes.** In the Embedding Push campaign (2026-11-26), on 1M-row text maps whose encoder had just been swapped, arrivals from new territory reached 0.60 of a native map's score at 15 and 0.76 at 100 on the worst seed, and existing rows lost about a point. Arrivals from the same distribution were fine. - **Reproducibility.** On CUDA the candidate k-means is not bit-reproducible with a fixed seed (float32 accumulation order). In round 5, 14 of 1,961 candidate centroids differed between two identical calls. Replaying one arrival twice for this README, 4.7% of arriving rows moved more than 0.001 room radii between the two runs and 0.04% more than one radius. - **Not in the package:** splitting existing centroid cells that a familiar batch overloads (setting `overload_factor`). It ran in the mixed-batch experiments (`research/campaigns/2026-11_recipe/local_surgery_20261123/r4_d2_fit_all.py`) but was not part of the engine used for whole collections, so `update` does not do it. ## What the Embedding Push campaign did not change The most recent campaign (2026-11-26/27) tested keeping a map's layout while swapping the encoder, and a fused two-encoder image map. Its report stopped at a review gate with two of its decision rules missed. Nothing from it is in `basemap/recipe`. Its maps were built with a shorter build than the one above (no trained top network), so its numbers do not describe this recipe's build. ## What is not in this repository - **Data.** No vectors, centroids, maps or checkpoints are included. The paths in `basemap/recipe/config.py` are those of the workstation the campaigns ran on. - **Room interiors, tiles, VLM naming, and the 3D flyable viewer.** These live in a separate repository that will be published as `enjalot/latent-space` (`interior.py`, tile/KTX2 builders, naming pipeline, and WebGL viewer). The base-world hierarchical container/room cut itself is now unified in [`basemap/recipe/rooms.py`](basemap/recipe/rooms.py). - **Training the top network** (`research/campaigns/2026-11_recipe/ruler_20261109/t2.py`, on top of `basemap/legacy/pumap`). - **The product-quantized client lookup** used to place new queries without the full centroid table (`research/campaigns/2026-11_recipe/ruler_20261109/n1.py`, `client` and `lookup`). ## Tests and checks ```bash PYTHONPATH=. python -m pytest -q ``` Runs [`tests/test_recipe_2d.py`](tests/test_recipe_2d.py) (levels by the e-means step, 2D and 3D builds with init, update docking a familiar batch and islanding a far-novel one, init reuse and indexed vectors reproducing positions byte for byte, centring, the 2D outskirt routing; about 15 s on CPU) and [`tests/test_recipe_smoke.py`](tests/test_recipe_smoke.py) (default pytest target in `pyproject.toml`): builds a map of 30,000 synthetic 32-d rows with a `64 > 512 > 2048` chain, scores it, compares the score with a brute-force computation, cuts unified hierarchical rooms (and checks `--flat`), adds 6,000 rows of which half come from new clusters, verifies that existing rows and centroids are bit-identical afterwards, checks familiar vs novel routing, and exercises edge-case guards and `basemap.recipe` package isolation. CPU only; about 4–6 seconds on the workstation. It uses a PCA stand-in for the top network. [`research/campaigns/2026-11_recipe/recipe_canonical_20261127/equivalence.py`](research/campaigns/2026-11_recipe/recipe_canonical_20261127/equivalence.py) recomputes saved arrays of the finished runs with the package (workstation paths; CPU). Results on 2026-11-27: | Compared | Result | | --- | --- | | Top network positions of the 19.3M map's 32,768 coarsest centroids | bit-identical | | All 262,144 positions of the 2^18 level of the 19.3M map | bit-identical | | Row positions, rows 0 to 65,535 and 10,000,000 to 10,065,535 of the 19.3M map | bit-identical | | 16,384 centroids each of the 2^18 and 2^20 levels of the 103.6M map | bit-identical | | Wider score, B15 and 0.1% share of 32 of the 4,096 queries on the 103.6M map, CPU against the saved GPU values | largest per-query difference 0.0001 (one neighbour in 10,000); means equal to 3 decimals | | Base room cut of the 19.3M map (1,933 rooms), room spheres, spacing | bit-identical | | Round 5's balanced rooms and their spheres, from round 4's saved end state | room labels identical, spheres bit-identical; spaced centers of new rooms within 0.00006 map units (max 5.3e-5, CPU against saved GPU) | `arrival_check.py` in the same directory replays one saved arrival (British Library 250K) on the GPU: the same 2,792 new centroids, 87 anchors and 21 rooms as the saved run, every row on the same side (new or existing centroid), and every row within 0.0003 room radii of its saved position; repeating the replay a second time differed from the first run by the run-to-run amount given under "Reproducibility". [`tests/regression/regress3d.py`](tests/regression/regress3d.py) runs the same small 3D pipeline (top, chain, rows, score, rooms, update, score) with two copies of the package and compares every array: against `main` at `db4f3f8` all 74 arrays are byte-identical; `recipe.json` gains only the key `map_dim`. ## Repository map | Path | Contents | | --- | --- | | [`basemap/recipe/`](basemap/recipe/) | **The canonical recipe:** `centroids`, `models`, `build`, `place`, `topk`, `score`, `rooms`, `update`, `config`, and CLI (`__main__.py`). Self-contained; zero imports from `legacy/` or `research/`. | | [`tests/`](tests/) | `test_recipe_smoke.py` (default `pytest` target); historical test suites in `tests/legacy/`. | | [`basemap/legacy/`](basemap/legacy/) | Earlier packages kept for provenance: `pumap/` (parametric-UMAP trainer), `coarse/`, `lens/` (Oct stored-embedding lens/projectors/reference codec), `rounds/` (Jul–Aug R0001–R0268 execution machinery), `ruler/`. | | [`research/OPEN_QUESTIONS.md`](research/OPEN_QUESTIONS.md) | Open research & engineering directions (`nested-4m` + local surgery, 1B+ LAION scale, Round 6 multi-seed validation, network-free top, 2D clumping, encoder swaps). | | [`research/lab-notes/`](research/lab-notes/README.md) | **Open-sourced research history:** sanitized markdown reports, plans, reviews, `basemap-log.md`, and `basemap-100m/` round records exported from `latent-labs`. | | [`research/campaigns/`](research/campaigns/) | Campaign code grouped by era: `2026-11_recipe/` (ruler, local surgery, trainers, placement), `2026-11_encoder_swaps/` (plato, embedding push, midlayer bridge), `2026-10_architecture/`, `2026-07_09_parametric/`. | | [`research/paper-2026-08/`](research/paper-2026-08/paper.md), [`research/docs-2026-10/`](research/docs-2026-10/README-2026-10.md), [`research/viewer-2026-08/`](research/viewer-2026-08/) | Earlier 2D 100M MiniLM manuscript, October stored-embedding lens docs, and static 2D map-pack viewer. | | [`archive/`](archive/early-prototypes/README.md) | Archived Feb 2025–Jul 2026 prototypes (`early-prototypes/`), `autoresearch/`, and legacy requirements files. | ## Status and limits - The method is validated on one 103.6M-row image map (build and score) and one 19.3M-row image map (updates). Text maps were built with chains in the same campaign, but the update step has been measured on text only in the unfavourable case reported above. - Every score quoted here is on rows that are on the map (with each query's own row excluded). The second row of the score table re-places those same 4,096 queries through the product-quantized lookup path as if unseen rather than reading their stored positions; a separate held-out query set was not scored at 103.6M. - The command line has run end to end only on the 30,000-row test. Its functions reproduce saved arrays of the large maps (table above), but the large builds were driven by the campaign scripts, which also handle storage order and the GPU lease. The command line's `rows` step uses a simpler exact search than the one that took 2.3 GPU-hours at 103.6M rows; its cost at that size is not measured. - The centroid fit in the package is the one the update campaign used. The two large builds used the same loop from their own scripts (`n1.py`, `m1.py`) without a renormalization step; those two scripts were not rewired, and no saved centroid level was refitted to compare. - The update step was written and tested with 768-d vectors. The package no longer hard-codes that width, and the 32-d test passes, but no other width has been scored on real data. - A map's quality at 2,000 neighbours and beyond depends on the top network, which is trained separately and takes about three GPU-hours. - The unified hierarchical room cut (`cut_rooms_hierarchical`, `e3dbal`) is now in `basemap/recipe/rooms.py`, while room interiors, KTX2 tiles, VLM naming, and the 3D flyable viewer remain in `enjalot/latent-space`. ## Sources Every campaign report cited above is now included under [`research/lab-notes/`](research/lab-notes/README.md). Paths starting with `/data2` refer to large binary run artifacts on the workstation (not committed). | Topic | Source | | --- | --- | | 103.6M build: times, scores, GPU and CPU totals | [`n1-monet-104m-learning.md`](research/lab-notes/campaigns/basemap-ruler-20261109/n1-monet-104m-learning.md); run files under `/data2/latent-basemap-research/ruler-20261109/n/monet-104m/` | | Top network N6 | `fit.json` beside the checkpoint (`/data2/latent-basemap-research/ruler-20261109/h/h2/monet/fits/monet-n6000000-w2048-d3-s42/`) | | Placement rule held against 12 alternatives (T6) | [`t6-local-placement-learning.md`](research/lab-notes/campaigns/basemap-ruler-20261109/t6-local-placement-learning.md) | | Single network over the finest centroids (Q25); UMAP-topped chain (L2) | [`q25-learning.md`](research/lab-notes/campaigns/basemap-ruler-20261109/q25-learning.md), [`part-l-l2-learning.md`](research/lab-notes/campaigns/basemap-ruler-20261109/part-l-l2-learning.md) | | 19.3M map score | `/data2/latent-basemap-research/local-surgery-20261123/t0_monet19m/t0_summary.json` | | Updates, round 1 (rebuild comparison, speed, middle-range misses, PCA on outside data) | [`local-surgery-20261123/report.md`](research/lab-notes/campaigns/local-surgery-20261123/report.md) | | Updates, final settings (fit-all, one-sided placement, sequences, end-to-end run) | [`local-surgery-20261123/r4-report.md`](research/lab-notes/campaigns/local-surgery-20261123/r4-report.md); 2026-11-26 entry in [`basemap-log.md`](research/lab-notes/basemap-log.md) | | Room balance, obstacle decoupling, k-means non-determinism | [`r5-interiors-learning.md`](research/lab-notes/campaigns/local-surgery-20261123/r5-interiors-learning.md) | | Hierarchical container & room cut (`e3dbal`) | [`e3-c18-cuts.md`](research/lab-notes/campaigns/hunt-tiles-20261122/e3-c18-cuts.md) and [`e3-worlds.md`](research/lab-notes/campaigns/hunt-tiles-20261122/e3-worlds.md) | | Embedding Push | [`ep-report.md`](research/lab-notes/campaigns/embedding-push-20261126/ep-report.md) | | Equivalence table, 21.3 s replay, top network 1.7 s | [`recipe_canonical_20261127/`](research/campaigns/2026-11_recipe/recipe_canonical_20261127/), run 2026-11-27 | ## Licence and citation The root repository, model and map licences have not been selected. The BSD licence under `basemap/legacy/pumap/` applies to that nested upstream-derived package, not to the whole repository. Citation metadata will be added with a release tag.