chroma-core/chroma · error · ValueError

You must provide an embedding function to compute embeddings

Error message

You must provide an embedding function to compute embeddings.https://docs.trychroma.com/guides/embeddings

What it means

`_embed` needs an embedding function to convert text into vectors. It first checks the collection schema's configured dense embedding function (float_list vector_index config), then the collection's `embedding_function` argument; when both are absent and text inputs are given, it raises. The linked docs (https://docs.trychroma.com/guides/embeddings) describe the supported options.

Source

Thrown at chromadb/api/models/CollectionCommon.py:792

                    override.float_list.vector_index.config.embedding_function,
                )
            elif (
                schema.defaults.float_list is not None
                and schema.defaults.float_list.vector_index is not None
                and schema.defaults.float_list.vector_index.config.embedding_function
                is not None
            ):
                schema_embedding_function = cast(
                    EmbeddingFunction[Embeddable],
                    schema.defaults.float_list.vector_index.config.embedding_function,
                )

        if schema_embedding_function is not None:
            if is_query and hasattr(schema_embedding_function, "embed_query"):
                return schema_embedding_function.embed_query(input=input)
            return schema_embedding_function(input=input)
        if self._embedding_function is None:
            raise ValueError(
                "You must provide an embedding function to compute embeddings."
                "https://docs.trychroma.com/guides/embeddings"
            )
        if is_query:
            return self._embedding_function.embed_query(input=input)
        else:
            return self._embedding_function(input=input)

    def _sparse_embed(
        self,
        input: Any,
        sparse_embedding_function: SparseEmbeddingFunction[Any],
        is_query: bool = False,
    ) -> Any:
        if is_query:
            return sparse_embedding_function.embed_query(input=input)
        return sparse_embedding_function(input=input)

View on GitHub (pinned to aecdd12c8a)

Solutions

  1. Pass an embedding function at creation: `client.get_or_create_collection(name, embedding_function=MyEF())`
  2. Or configure it in the collection schema's dense (float_list) vector index config
  3. Or send precomputed `embeddings` so no client-side function is needed
  4. If a default EF is desired, pass it explicitly (e.g. ONNXMiniLM_L6_V2) rather than relying on implicit defaults

Example fix

# before
col = client.get_or_create_collection(name="docs")
col.add(documents=["hello"])  # ValueError: no embedding function

# after
from chromadb.utils.embedding_functions import DefaultEmbeddingFunction
col = client.get_or_create_collection(name="docs", embedding_function=DefaultEmbeddingFunction())
col.add(documents=["hello"])
Defensive patterns

Strategy: validation

Validate before calling

ef_configured = collection.embedding_function is not None or schema_has_dense_ef(collection)
if sending_text and not ef_configured:
    raise ValueError("configure an embedding function or send precomputed embeddings")

Prevention

When it happens

Trigger: Collection created with neither `embedding_function=` nor a schema dense vector config carrying an embedding function, then add/upsert/query with textual input that requires embedding.

Common situations: Upgrading to a version where the default embedding function is no longer implicitly downloaded/attached; creating collections via a client path that does not accept or forward an embedding function.

Related errors


AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16). Data as JSON: /api/errors/2b5178ab4ba82bf4. Report an issue: GitHub.