{"record":{"id":"a78e5d8ff4792b22","repo":"chroma-core/chroma","slug":"expected-each-embedding-in-the-embeddings-to-be-a-a78e5d","errorCode":null,"errorMessage":"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}","messagePattern":"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 (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/api/types.py","lineNumber":1393,"sourceCode":"        raise ValueError(\n            f\"Expected embeddings to be a list, got {type(embeddings).__name__}\"\n        )\n    if len(embeddings) == 0:\n        raise ValueError(\n            f\"Expected embeddings to be a list with at least one item, got {len(embeddings)} embeddings\"\n        )\n    if not all([isinstance(e, np.ndarray) for e in embeddings]):\n        raise ValueError(\n            \"Expected each embedding in the embeddings to be a numpy array, got \"\n            f\"{list(set([type(e).__name__ for e in embeddings]))}\"\n        )\n    for i, embedding in enumerate(embeddings):\n        if embedding.ndim == 0:\n            raise ValueError(\n                f\"Expected a 1-dimensional array, got a 0-dimensional array {embedding}\"\n            )\n        if embedding.size == 0:\n            raise ValueError(\n                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}\"\n            )\n\n        if embedding.dtype not in [\n            np.float16,\n            np.float32,\n            np.float64,\n            np.int32,\n            np.int64,\n        ]:\n            raise ValueError(\n                \"Expected each value in the embedding to be a int or float, got an embedding with \"\n                f\"{embedding.dtype} - {embedding}\"\n            )\n    return embeddings\n\n\ndef validate_sparse_vectors(vectors: SparseVectors) -> SparseVectors:","sourceCodeStart":1375,"sourceCodeEnd":1411,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/api/types.py#L1375-L1411","documentation":"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.","triggerScenarios":"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.","commonSituations":"Custom tokenizers returning zero tokens for blank/whitespace documents; empty rows after pandas filtering; per-row feature extraction that yields [] for some inputs.","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"],"exampleFix":"# before\nembeddings = [encode(doc) for doc in docs]  # encode('') -> np.array([])\ncollection.add(ids=ids, embeddings=embeddings, documents=docs)\n\n# after\npairs = [(i, d, encode(d)) for i, d in zip(ids, docs)]\npairs = [p for p in pairs if p[2].size > 0]\ncollection.add(ids=[p[0] for p in pairs], embeddings=[p[2] for p in pairs], documents=[p[1] for p in pairs])","handlingStrategy":"validation","validationCode":"import numpy as np\n\ndef drop_empty_embeddings(ids, embeddings, documents=None):\n    keep = [(i, e) for i, e in zip(ids, embeddings) if np.asarray(e).size > 0]\n    if len(keep) != len(ids):\n        logger.warning(\"dropped %d empty embeddings\", len(ids) - len(keep))\n    ids2 = [i for i, _ in keep]\n    embs2 = [np.asarray(e) for _, e in keep]\n    docs2 = [d for i, d in zip(ids, documents or []) if any(k == i for k, _ in keep)]\n    return ids2, embs2, docs2","typeGuard":"import numpy as np\n\ndef is_non_empty_vector(e) -> bool:\n    return isinstance(e, np.ndarray) and e.ndim == 1 and e.size > 0","tryCatchPattern":"try:\n    collection.add(ids=ids, embeddings=embeds, documents=docs)\nexcept ValueError as e:\n    if \"no values at pos\" in str(e):\n        pos = int(str(e).rsplit(\"pos \", 1)[-1])\n        raise ValueError(f\"input row {pos} ({ids[pos]!r}) produced an empty embedding\") from e\n    raise","preventionTips":["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"],"tags":["chromadb","embeddings","empty-array","numpy"],"backgroundTag":"invalid-embedding-format","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}