Embeddings & spaces
How an embedder maps text to vectors in a space identified by EmbeddingProfile.space_id(), and how a collection is bound to exactly one space.
An embedder turns text into a fixed-length vector of float32 numbers. Telys compares vectors, never raw text — and two vectors are comparable only if they came from the same embedder configured the same way. Telys makes that explicit with a space: a stable identity for "vectors produced by this exact embedder". A collection is bound to one space at creation, and every later read is checked against it.
An embedder produces vectors in a space
Every embedder exposes a profile and returns a (N, D) float32 array — one row per input text:
from telys.embedding import AlgentaMultigramEmbedder
emb = AlgentaMultigramEmbedder() # on-device lexical embedder
vecs = emb.embed_documents(["def add(a, b): return a + b"])
print(vecs.shape) # (1, D) — D is the embedder's dimension
print(emb.profile.dimension) # D, sourced from the native kernelD is the embedder's dimension — a property of the embedder, not a number you choose. The Algenta* embedders read it from the native kernel (bigram and multigram are 64 and 384 as hints, not guarantees). The collection, the on-disk slab, and every query vector must agree on it.
EmbeddingProfile: the identity of a space
EmbeddingProfile is a frozen dataclass describing how vectors were made — the fields that decide whether two sets of vectors are comparable:
from telys.embedding import EmbeddingProfile
profile = EmbeddingProfile(
provider="openai",
model_id="text-embedding-3-small",
model_version="1",
dimension=1536,
normalization="l2", # default
distance="ip", # default — inner product on L2-normalized vectors == cosine
pooling="none", # default
)
print(profile.space_id()) # e.g. "sha256:9f2a1c4b7e0d3a56"space_id() hashes the profile's identity fields — provider, model_id, model_version, dimension, normalization, distance, pooling (plus tokenizer_hash and projection_version when set) — into a short sha256:-prefixed digest. Two profiles are in the same space iff their space_id() values are equal:
Non-identity fields such as created are metadata and do not change the space. Every field that affects the geometry of the vectors does:
provider
"algenta"
yes
model_id
"multigram"
yes
model_version
"1"
yes
dimension
384
yes
normalization
"l2"
yes
distance
"ip"
yes
pooling
"multigram-hash"
yes
tokenizer_hash / projection_version
""
yes (when set)
created
timestamp
no (metadata only)
Change any identity field — a new model, a different dimension, a switch of distance — and you have a new space. Vectors from the old space are not comparable to the new one.
A collection is bound to one space
When you create a collection you pass a dim and an embedder. The dim must equal embedder.profile.dimension — Telys stores vectors in a fixed-width slab and rejects a mismatch:
save() writes the embedder's profile into collection.json. That stored profile — and its space_id() — is the collection's permanent contract: every later vector and query against notes lives in that one space.
Reopening validates space compatibility
Reopening reads the stored profile and checks the embedder you attach belongs to the same space. Pass no embedder and Telys resolves one from the provider registry by matching model_id / space_id:
If the embedder's space_id() does not match the stored profile, Telys refuses to attach it: the on-disk vectors were written in the original space, so a different embedder would produce meaningless scores. This check stops a silently-changed-model bug from degrading recall.
Why this matters
Silent space mismatches are the most common way a vector store goes wrong: someone bumps a model version or changes dimensions, and every later score is subtly meaningless. Telys makes the space a hashed identity so the mismatch is caught at open time, not weeks later as mysteriously bad results. Moving to a new model is a new space — create a new collection and re-embed rather than mixing spaces in one collection.
Next steps
Next: read Lexical vs dense embeddings to choose what actually produces your vectors.
Last updated
Was this helpful?