chroma-core/chroma · error · ValueError
Expected each embedding in the embeddings to be a 1-dimensio
Error message
Expected each embedding in the embeddings to be a 1-dimensional numpy array with at least 1 int/float value. Got a 1-dimensional numpy array with no values at pos {i} What it means
Each embedding must contain at least one value. validate_embeddings raises when embedding.size == 0 — a 1-D numpy array with no elements (np.array([])). The message includes the position i of the offending embedding.
Source
Thrown at chromadb/api/types.py:1393
raise ValueError(
f"Expected embeddings to be a list, got {type(embeddings).__name__}"
)
if len(embeddings) == 0:
raise ValueError(
f"Expected embeddings to be a list with at least one item, got {len(embeddings)} embeddings"
)
if not all([isinstance(e, np.ndarray) for e in embeddings]):
raise ValueError(
"Expected each embedding in the embeddings to be a numpy array, got "
f"{list(set([type(e).__name__ for e in embeddings]))}"
)
for i, embedding in enumerate(embeddings):
if embedding.ndim == 0:
raise ValueError(
f"Expected a 1-dimensional array, got a 0-dimensional array {embedding}"
)
if embedding.size == 0:
raise ValueError(
f"Expected each embedding in the embeddings to be a 1-dimensional numpy array with at least 1 int/float value. Got a 1-dimensional numpy array with no values at pos {i}"
)
if embedding.dtype not in [
np.float16,
np.float32,
np.float64,
np.int32,
np.int64,
]:
raise ValueError(
"Expected each value in the embedding to be a int or float, got an embedding with "
f"{embedding.dtype} - {embedding}"
)
return embeddings
def validate_sparse_vectors(vectors: SparseVectors) -> SparseVectors:View on GitHub (pinned to aecdd12c8a)
Solutions
- Find the offending input using the position i in the message and fix or drop that row before embedding
- Guard: embeddings = [e for e in embeddings if getattr(e, 'size', 0) > 0] (and drop matching ids/documents)
- Fix the custom encoder to always emit at least a zero-vector placeholder if your model supports it
Example fix
# before
embeddings = [encode(doc) for doc in docs] # encode('') -> np.array([])
collection.add(ids=ids, embeddings=embeddings, documents=docs)
# after
pairs = [(i, d, encode(d)) for i, d in zip(ids, docs)]
pairs = [p for p in pairs if p[2].size > 0]
collection.add(ids=[p[0] for p in pairs], embeddings=[p[2] for p in pairs], documents=[p[1] for p in pairs]) Defensive patterns
Strategy: validation
Validate before calling
import numpy as np
def drop_empty_embeddings(ids, embeddings, documents=None):
keep = [(i, e) for i, e in zip(ids, embeddings) if np.asarray(e).size > 0]
if len(keep) != len(ids):
logger.warning("dropped %d empty embeddings", len(ids) - len(keep))
ids2 = [i for i, _ in keep]
embs2 = [np.asarray(e) for _, e in keep]
docs2 = [d for i, d in zip(ids, documents or []) if any(k == i for k, _ in keep)]
return ids2, embs2, docs2 Type guard
import numpy as np
def is_non_empty_vector(e) -> bool:
return isinstance(e, np.ndarray) and e.ndim == 1 and e.size > 0 Try / catch
try:
collection.add(ids=ids, embeddings=embeds, documents=docs)
except ValueError as e:
if "no values at pos" in str(e):
pos = int(str(e).rsplit("pos ", 1)[-1])
raise ValueError(f"input row {pos} ({ids[pos]!r}) produced an empty embedding") from e
raise Prevention
- Filter out blank/whitespace documents before embedding
- Unit-test custom encoders with empty-string input
- Use the reported pos to map the bad embedding back to its source row
When it happens
Trigger: embeddings=[np.array([]), ...] — one item in the batch produced an empty vector, e.g. tokenizing an empty string with a custom encoder, slicing an array with a wrong (empty) range, or filtering that removed all values per row.
Common situations: Custom tokenizers returning zero tokens for blank/whitespace documents; empty rows after pandas filtering; per-row feature extraction that yields [] for some inputs.
Related errors
- Expected embeddings to be an array with at least one item
- Expected each embedding to be a non-empty array of numbers,
- Expected each embedding in the embeddings to be a numpy arra
- Expected a 1-dimensional array, got a 0-dimensional array {e
- Expected each value in the embedding to be a int or float, g
AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16).
Data as JSON: /api/errors/a78e5d8ff4792b22.
Report an issue: GitHub.