Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Dimension mismatches

Fix embedding dimension errors — dim vs profile.dimension at create, query length vs dim at search, and space_id incompatibility after changing models.

Telys is strict about vector width: a collection stores fixed-width vectors, and every vector you add or query must match. A mismatch raises a clear ValueError or AssertionError at the point of failure rather than silently corrupting results. It shows up in three places — at create, at search, and after you change embedding models.

A collection's width comes from its embedder's EmbeddingProfile.dimension. Create the collection with dim=emb.profile.dimension and you'll never have to guess a number.

Errors and fixes

dim doesn't match the embedder profile at create_collection

create_collection(name, dim, ...) fixes the collection width. Pass an embedder whose profile.dimension differs from dim, and create_collection itself raises — ValueError: embedder dim X != collection dim Y — before any insert runs. A wrong-width vector batch fails later, at ingest: add/upsert raises ValueError: vectors must be (n, dim); got shape .... CallableEmbedder is especially strict: it asserts every batch is 2-D and shape[1] == profile.dimension.

Cause: a hard-coded dim that doesn't equal the embedder's real dimension. Algenta* embedder dims are read from the native kernel (64 and 384 are hints, not guaranteed constants), so hard-coding them is fragile.

Fix: always derive dim from the profile.

from telys import Telys
from telys.embedding import AlgentaMultigramEmbedder

emb = AlgentaMultigramEmbedder()
mem = Telys("./memory")
col = mem.create_collection(
    "notes",
    dim=emb.profile.dimension,     # not a hard-coded 384
    partition_by="scope",
    embedder=emb,
)

For CallableEmbedder, the wrapped function must return exactly profile.dimension columns, or its assertion fires on the first add.

ValueError — query vector length doesn't equal the collection dim

search(vector, ...) validates len(vector) == dim before it runs, so a query of the wrong width fails immediately.

Cause: the query vector was built with a different model (or a truncated/padded array) than the collection.

Fix: embed the query with the same embedder as the collection, or check the width before calling search.

# Preferred: let the collection embed the query with its own embedder
col.search_text("how do refunds work", top_k=5)

# If you pass a raw vector, it must match the collection width exactly:
import numpy as np
q = np.asarray(query_vector, dtype="float32")
assert q.shape[-1] == emb.profile.dimension     # same width the collection was built with
res = col.search(q, top_k=5)

search_text avoids length errors entirely — the collection's own embedder produces the query vector.

Changed the embedding model — new space_id, incompatible collection

A collection is bound to a vector space, identified by the embedder's EmbeddingProfile.space_id() — a SHA-256 over provider, model id, version, dimension, normalization, distance, and pooling. Change any of those and the space_id changes, so vectors from the new model are not comparable to the old ones. profile.compatible_with(other) is simply space_id equality.

Cause: you swapped embedders (or bumped a model version) and queried or added into a collection built in a different space.

Fix: a space change means a new collection. Create one with the new embedder and re-ingest; don't mix spaces in one collection.

from telys.embedding import AlgentaBigramEmbedder, AlgentaMultigramEmbedder

old = AlgentaBigramEmbedder()
new = AlgentaMultigramEmbedder()
print(old.profile.space_id() == new.profile.space_id())   # False -> incompatible
print(new.profile.compatible_with(old.profile))           # False

# Re-ingest into a new collection built in the new space:
mem_new = mem.create_collection("notes_v2", dim=new.profile.dimension,
                                partition_by="scope", embedder=new)

On open_collection, Telys auto-attaches an embedder from the provider registry by matching model_id / space_id. If the registered embedder is in a different space, register the correct provider so it can attach the right one.

Next steps

With widths lined up, the remaining "not finding it" cases are about scope, filters, and recall.

Next: No results / poor recall

Last updated

Was this helpful?