Building an Embedding Runtime
Part VIII โ Embeddings Become Infrastructure
Not a RAG chatbot
The obvious capstone would be “build a RAG system.” It would also be the wrong one โ a RAG system exercises maybe a third of this book and hides the rest inside a framework.
The capstone is an Embedding Observatory: a runtime whose job is to know things about representations. It ingests text, documents, and queries under one or more embedding models, and it exposes not just vectors but the geometry, neighborhoods, distributions, evaluations, calibrations, versions, and bridges that the book spent 23 chapters building tools for.
What would a system look like if it treated the representation layer as something to be measured and governed rather than assumed?
The architecture
flowchart TD
IN["INGEST โ chunk, embed under N models, tag every vector with its space_hash"] --> SP["SPACE layer"]
SP --> V["vectors"]
SP --> G["geometry / shape profile"]
SP --> NB["neighbourhoods / hub list"]
SP --> D["distributions / calibration"]
SP --> RT["retrieval policy"]
SP --> EV["evaluation cards"]
SP --> VR["space versions / registry"]
SP --> BR["bridges + preservation profiles"]
V --> QA["QUERY API โ what space produced this vector? are A and B compatible? how stable is this neighbourhood? what does a translation preserve? should this corpus be re-embedded?"]
G --> QA
NB --> QA
D --> QA
RT --> QA
EV --> QA
VR --> QA
BR --> QA
Each box is a companion component from an earlier chapter:
| Component | From | Answers |
|---|---|---|
space_record / space_registry |
Ch 1, 17 | what transformation produced this vector |
geometry_probe / shape_profile |
Ch 2, 8 | what geometry this model imposes |
dimensionality_report |
Ch 7 | how many dimensions it actually uses |
neighborhood_report |
Ch 6 | where kNN is trustworthy; the hub list |
similarity_spec / calibration_record |
Ch 4, 14 | what a score means; the operating point |
retrieval_policy |
Ch 12 | what the retrieval chain returns |
distractor_probe / negative_set_descriptor |
Ch 10, 11 | how it fails on hard cases |
evaluation_card |
Ch 13 | how good it is for this task |
signal_bundle |
Ch 15 | per-result diagnostic vector |
space_comparison |
Ch 16 | how much two models agree |
bridge_registry / preservation_profile |
Ch 20, 21 | whether spaces can be crossed, and for what |
compression_record |
Ch 22 | whether a cartridge can stand in |
transformation_record |
Ch 23 | the simplest operator class that represents an edit, and what it distorts |
The questions the runtime answers
What space produced this vector?
โ space_registry lookup by space_hash
Is space A compatible with space B?
โ space_comparison + bridge_registry: "structurally 0.6 overlap;
a linear bridge exists, usable_for [retrieval, clustering], not [thresholds]"
How stable are this vector's neighbors?
โ neighborhood_report + signal_bundle: "hub-adjacent, margin 0.02,
42% of perturbations change top-1 โ treat as low confidence"
What is this space's intrinsic dimensionality?
โ dimensionality_report: "nominal 1536, effective rank 190, intrinsic dim ~18;
safe truncation: 256 for retrieval, 96 for clustering (per-task, this corpus)"
How does this model differ from the previous version?
โ space_comparison(v1, v2): "neighborhood overlap 0.55 on your corpus โ
NOT compatible; re-embed or bridge"
Can the old space be translated to the new one?
โ bridge_registry: "v1โv2 bridge, retrieval_agreement 0.79,
hard_negative_agreement 0.41 (โ v1 source-native score), threshold transfer NO"
What properties does the translation preserve?
โ preservation_profile: the full table, with native reference and random floor
Should these vectors be re-embedded?
โ migration status + space_comparison + cost estimate:
"bridge covers retrieval at -4 pts; full re-embed = $Xk, Yh;
recommend progressive re-embed with bridge on the tail"
The design principles, restated as system invariants
Every recurring principle from the book becomes an enforced rule. And one principle now subsumes half of them:
Every transformation of an embedding โ truncation, compression, cross-space translation, or semantic editing โ creates an obligation to measure what was preserved.
Truncation (Chapter 7), whitening (Chapter 8), a cross-space bridge (Chapters 18โ21), document compression (Chapter 22), a semantic operator (Chapter 23): each takes vectors and returns different vectors, each produces a new derived space (Chapter 17), and none may be treated as equivalent to its input until a preservation profile says so โ scoped to the task, the corpus, and the space.
a vector is not meaning โ no vector without a space_record
similarity is not equivalence โ retrieval returns candidates, tagged with signal_bundle
proximity is not truth โ no "verified" flag from geometry alone
retrieval is not verification โ retrieval and verification are separate API calls
dimension is not capacity โ geometry can suggest redundancy; only a task-preservation
experiment can authorize compression. Truncation only under
a task-, corpus-, and space-scoped preservation record โ
never one global "safe" dimension
compression is not faithfulness โ global embedding drift gates topical drift only;
a stand-in claim needs claim- and query-conditioned
preservation, and a verifier for relations
equal dimensions โ compatible spaces โ cross-space ops DENIED without a bridge
a bridge is not compatibility โ cross-space ops check the bridge's usable_for scope
a visualization is another transform โ every plot annotates full-space survival
identity is exact; compatibility โ a matching space_hash permits an op; a mismatch
is empirical; usability is policy requires a MEASURED bridge, never an assumption,
and usable_for(scope, operating_point) gates the use
a derived space is a new space โ PCA / whitening / bridge output / Matryoshka prefix
each get their own space_hash + preservation record
geometry diagnoses geometry first โ the runtime exhausts geometric signals before
calling a second model
space incompatibility is not a โ a store of embeddings from ANY encoder is, for
privacy boundary access control, a store of the documents' topics and
sensitive attributes (unpaired translation + inversion)
every transformation creates a โ truncation / whitening / bridge / compression /
preservation obligation semantic operator โ no transformed representation is
treated as equivalent to its input until a preservation
profile says so, scoped to task, corpus, and space
Demonstration: the Observatory over the whole RELATE corpus
COMPOSED from the emitted artifacts of Waves 1โ4 and the Transformation Wave โ every number below traces to a file under
experiments/embeddings-from-first-principles/wave{1,2,3,4,5}/artifacts/. Corpus:relate-0.2.0for the query steps,relate-0.1.0for the rest.
Load RELATE under three models (A = MiniLM-L6, B = mpnet-base, C = bge-large). One session:
> register model A, B, C over corpus RELATE
โ 3 space_hashes; 3 shape_profiles (mean random-pair cosine 0.06 / 0.08 / 0.40 โ wave2/shape-comparison)
โ 3 dimensionality_reports (effective rank 259 / 387 / 434; TwoNN-ID 3.6 / 4.2 / 5.8 โ wave2/dimensionality-report)
โ space_comparison(A,B),(B,C),(A,C): 10-NN overlap 0.71 / 0.88 / 0.71, linear CKA 0.81 / 0.99 / 0.85
"coarse structure shared; per-relation preservation is NOT โ a fitted AโB bridge inverts
paraphrase-vs-negation (wave3/relation-preservation: +0.033 native โ โ0.107 bridged)"
> evaluate for task = "answer the query, correct claim" (on the v0.2 hard queries)
โ evaluation_cards: C wins (nDCG@10 0.85), B (0.85), A (0.84) [v0.1 saturated at 0.94; v0.2 separates them]
> calibrate B for a duplicate filter
โ calibration_record: AUC 0.75, equal-error 24% at t=0.84, escalate-band 86% of pairs
(wave1/calibration); the threshold shifts 0.10 across domains (wave1/threshold-drift)
> build bridge AโB (Procrustes, anchors from split_entity:train)
โ preservation_profile: retrieval ratio 0.91, neighborhood 0.74, relation-order corr 0.86,
hard-negative margin ratio 0.47, calibration transfer 0.76 โ FAIL;
reconstruction 1.00 on anchor entities, 0.56 on unseen entities (wave3/ladder-8property-matrix)
โ usable_for: [retrieval on anchor-like corpora]; NOT usable_for: [threshold_transfer, unseen entities]
> query "Where does Ireland run its ministries from?" via policy C (hybrid + rerank + verify)
โ 10 candidates, each with signal_bundle
โ the NEGATION passage ("Dublin is not the capital of Ireland") scores cos ~0.83, margin ~0.06
(wave1/relation-cosine-by-type: negation โ paraphrase for every model)
โ policy routes on the geometric signals alone: score-only would accept; the full geometric
bundle (margin + density + rank + hubness) separates correct from near-wrong at 0.90 vs 0.76
balanced accuracy (wave1/signal-ablation) โ route to VERIFY
โ verification (a separate NLI call) flags the polarity conflict โ candidate demoted
โ a generic NLI reranker applied blindly would have RAISED the negation's rank
(wave1/distractor-winrate: NLI reranker win-rate for negation 3.5% โ 34%) โ the verifier
must be the right one, not just any second model
OBSERVATION: the runtime did not “fix” the embedding. It carried the embedding’s known limits โ negation blindness, the hub, the low margin โ as data, and let policy act on them. The near-but-wrong result was caught by the system, not the geometry.
What this chapter establishes and what it does not
Establishes: an architecture that composes every companion component into one runtime; the concrete questions it answers; the book’s principles as enforced system invariants; that the value is in carrying limits as metadata, not in a better embedding.
Does not establish: a production-ready system (this is a reference design), or that every application needs all of it (a cheap-error use case needs the space record and a calibrated threshold and little else). It establishes what “treating the representation layer as infrastructure” concretely means.
Lab 24: build a minimal Observatory
PROPOSED, not executed.
Setup. One corpus, two models, labeled queries with a hard-negative subset.
Task. Implement the smallest runtime that can answer, for a given vector or query:
- Which space produced it? (
space_hashtagging) - What is this space’s effective rank, and its safe truncation dimension per task (retrieval vs clustering)?
- Is this query in a hub region, and what is its top-1 margin?
- Do models A and B agree on this query’s top-10? (
space_comparison) - If a bridge AโB exists, what is it
usable_for, and does that cover the operation being requested? - For a retrieval result, emit the
signal_bundleand a{accept | rerank | verify}verdict.
Success criterion. A runtime that, given a query, returns results and the metadata a downstream system needs to decide how much to trust them โ with at least one enforced invariant (e.g. cross-space comparison refused without a bridge).
Companion component: the whole book
embedding_observatory:
ingest: chunk + embed(models) + tag(space_hash)
space:
registry: {space_hash: space_identity}
per_space: {shape_profile, dimensionality_report, neighborhood_report,
calibration_records, evaluation_cards, index, retrieval_policy}
cross_space:
comparisons: {(hash_a, hash_b): space_comparison}
bridges: {(hash_a, hash_b, dir): bridge + preservation_profile}
compression: {doc_id: compression_record}
transformations: {relation: transformation_record}
query_api: the eight questions above
invariants: the enforced rules above
What this chapter โ and the book โ established
- Retrieval, RAG, agent memory, clustering, dedup, and recommendation all run on the representation layer and inherit its geometry’s limits whether or not anyone measured them.
- Every limit in this book is measurable: the objective’s bias, the arbitrary basis, the effective dimension, the hubs, the near-but-wrong tail, the uncalibrated score, the incompatible second space, the lossy bridge, the forgetful compression.
- An Embedding Observatory composes the per-chapter artifacts into a runtime that carries those measurements as metadata and enforces the book’s principles as invariants โ including the separation of identity (exact,
space_hash), compatibility (empirical, measured), and usability (a scoped policy call). - The destination is not a better embedding. It is a system that knows what its embeddings can and cannot support โ and makes consequential trust an explicit, measured decision rather than an assumption.
The book began with a vector is not meaning. The instruments in it lead somewhere more precise:
Geometry is evidence about a representation, not permission to use it.
And the second half supplies the operational form of that principle:
Whenever you transform a representation โ compress it, project it, translate it to another space, edit its meaning โ measure what survived before treating the transformed representation as equivalent.
A vector is a list of numbers. What you are allowed to conclude from it, and what you are allowed to do to it, are separate questions โ and now you have the instruments to answer both.