#7824·chroma

Improve `InvalidDimensionException` message to teach the underlying concept (dimension mismatch is not just a number)

Author: Ansel-PoiesisCreated Sep 30, 2026Updated Sep 30, 2026

Problem

InvalidDimensionException: Embedding dimension 384 does not match collection dimensionality 768

This message surfaces repeatedly (user bug reports: #4368, #1905, #771, plus many Stack Overflow questions), but it only reports the numbers. Users "fix" it by changing the number without learning the constraint that actually matters:

Each embedding model produces its own vector space. Vectors from different models are not comparable — even when dimensions happen to match. Switching embedding models requires re-embedding the entire collection (or creating a new collection with a consistent model).

Without this, the same users go on to mix vectors from different models (silent quality loss), or query a collection right after swapping models (empty/unstable results).

Proposal

Append two sentences to the exception message (raised in chromadb/segment/impl/vector/local_hnsw.py):

This collection was created with a different embedding model.
Each embedding model defines its own vector space: vectors from
different models are not comparable even if dimensions match.
Fix: re-embed all documents with one consistent model (or create
a new collection).

Why it matters

Error messages are where user attention peaks. The current message resolves the symptom; the proposed addition resolves the misconception, and points at the correct fix (re-embed everything / new collection) rather than inviting a numeric patch.

Happy to submit a PR if maintainers are open to it — the change is localized to the exception message construction.