{"record":{"id":"2b5178ab4ba82bf4","repo":"chroma-core/chroma","slug":"you-must-provide-an-embedding-function-to-compute","errorCode":null,"errorMessage":"You must provide an embedding function to compute embeddings.https://docs.trychroma.com/guides/embeddings","messagePattern":"You must provide an embedding function to compute embeddings\\.https://docs\\.trychroma\\.com/guides/embeddings","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/api/models/CollectionCommon.py","lineNumber":792,"sourceCode":"                    override.float_list.vector_index.config.embedding_function,\n                )\n            elif (\n                schema.defaults.float_list is not None\n                and schema.defaults.float_list.vector_index is not None\n                and schema.defaults.float_list.vector_index.config.embedding_function\n                is not None\n            ):\n                schema_embedding_function = cast(\n                    EmbeddingFunction[Embeddable],\n                    schema.defaults.float_list.vector_index.config.embedding_function,\n                )\n\n        if schema_embedding_function is not None:\n            if is_query and hasattr(schema_embedding_function, \"embed_query\"):\n                return schema_embedding_function.embed_query(input=input)\n            return schema_embedding_function(input=input)\n        if self._embedding_function is None:\n            raise ValueError(\n                \"You must provide an embedding function to compute embeddings.\"\n                \"https://docs.trychroma.com/guides/embeddings\"\n            )\n        if is_query:\n            return self._embedding_function.embed_query(input=input)\n        else:\n            return self._embedding_function(input=input)\n\n    def _sparse_embed(\n        self,\n        input: Any,\n        sparse_embedding_function: SparseEmbeddingFunction[Any],\n        is_query: bool = False,\n    ) -> Any:\n        if is_query:\n            return sparse_embedding_function.embed_query(input=input)\n        return sparse_embedding_function(input=input)\n","sourceCodeStart":774,"sourceCodeEnd":810,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/api/models/CollectionCommon.py#L774-L810","documentation":"`_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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass an embedding function at creation: `client.get_or_create_collection(name, embedding_function=MyEF())`","Or configure it in the collection schema's dense (float_list) vector index config","Or send precomputed `embeddings` so no client-side function is needed","If a default EF is desired, pass it explicitly (e.g. ONNXMiniLM_L6_V2) rather than relying on implicit defaults"],"exampleFix":"# before\ncol = client.get_or_create_collection(name=\"docs\")\ncol.add(documents=[\"hello\"])  # ValueError: no embedding function\n\n# after\nfrom chromadb.utils.embedding_functions import DefaultEmbeddingFunction\ncol = client.get_or_create_collection(name=\"docs\", embedding_function=DefaultEmbeddingFunction())\ncol.add(documents=[\"hello\"])","handlingStrategy":"validation","validationCode":"ef_configured = collection.embedding_function is not None or schema_has_dense_ef(collection)\nif sending_text and not ef_configured:\n    raise ValueError(\"configure an embedding function or send precomputed embeddings\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass embedding_function= (or a schema dense EF) when creating collections that will embed text","After upgrading Chroma, audit collections created without an explicit EF","Centralize collection creation so the EF decision cannot be silently skipped"],"tags":["embeddings","embedding-function","configuration"],"backgroundTag":"missing-embedding-function","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}