chroma-core/chroma · error · ValueError

Expected EmbeddingFunction.__call__ to have the following si

Error message

Expected EmbeddingFunction.__call__ to have the following signature: {protocol_signature}, got {function_signature}
Please see https://docs.trychroma.com/guides/embeddings for details of the EmbeddingFunction interface.
Please note the recent change to the EmbeddingFunction interface: https://docs.trychroma.com/deployment/migration#migration-to-0.4.16---november-7,-2023 

What it means

Chroma pins custom embedding functions to a protocol: __call__ must have exactly the parameter names of EmbeddingFunction.__call__ (currently 'def __call__(self, input) -> Embeddings'). validate_embedding_function (chromadb/api/types.py:993) compares parameter-name sets with inspect.signature and raises on any mismatch - a parameter named 'texts' instead of 'input' fails even with correct types. The check runs when a Collection is created with an embedding_function (CollectionCommon.py:138) and when functions are resolved from configuration, so a non-conforming function fails immediately.

Source

Thrown at chromadb/api/types.py:1002

    def max_tokens(self) -> int:
        return 256

    @staticmethod
    def validate_config(config: Dict[str, Any]) -> None:
        return


def validate_embedding_function(
    embedding_function: EmbeddingFunction[Embeddable],
) -> None:
    function_signature = signature(
        embedding_function.__class__.__call__
    ).parameters.keys()
    protocol_signature = signature(EmbeddingFunction.__call__).parameters.keys()

    if not function_signature == protocol_signature:
        raise ValueError(
            f"Expected EmbeddingFunction.__call__ to have the following signature: {protocol_signature}, got {function_signature}\n"
            "Please see https://docs.trychroma.com/guides/embeddings for details of the EmbeddingFunction interface.\n"
            "Please note the recent change to the EmbeddingFunction interface: https://docs.trychroma.com/deployment/migration#migration-to-0.4.16---november-7,-2023 \n"
        )


class DataLoader(Protocol[L]):
    def __call__(self, uris: URIs) -> L:
        ...


def validate_ids(ids: IDs) -> IDs:
    """Validates ids to ensure it is a list of strings"""
    if not isinstance(ids, list):
        raise ValueError(f"Expected IDs to be a list, got {type(ids).__name__} as IDs")
    if len(ids) == 0:
        raise ValueError(f"Expected IDs to be a non-empty list, got {len(ids)} IDs")
    seen = set()

View on GitHub (pinned to aecdd12c8a)

Solutions

  1. Define __call__ with the exact protocol signature: def __call__(self, input: Documents) -> Embeddings - the parameter must be named 'input'
  2. Subclass chromadb.api.types.EmbeddingFunction so signature drift is caught by your type checker
  3. Wrap legacy functions in a small adapter class with the conforming signature instead of editing vendor code
  4. For config-driven embedding functions, implement name()/get_config()/build_from_config() so Chroma recognizes the function

Example fix

# before
class MyEF:
    def __call__(self, texts):
        return [embed(t) for t in texts]

# after
class MyEF(EmbeddingFunction):
    def __call__(self, input):
        return [embed(t) for t in input]
Defensive patterns

Strategy: type-guard

Validate before calling

from inspect import signature

def conforms_to_ef_protocol(fn) -> bool:
    got = list(signature(fn.__class__.__call__).parameters)
    want = list(signature(EmbeddingFunction.__call__).parameters)
    return got == want

assert conforms_to_ef_protocol(my_ef), 'EF signature does not match protocol'

Type guard

from inspect import signature
from chromadb.api.types import EmbeddingFunction

def is_conforming_embedding_function(fn) -> bool:
    try:
        return list(signature(fn.__class__.__call__).parameters) == list(signature(EmbeddingFunction.__call__).parameters)
    except (TypeError, ValueError):
        return False

Try / catch

try:
    col = client.create_collection(name='c', embedding_function=my_ef)
except ValueError as e:
    if 'EmbeddingFunction.__call__' in str(e):
        raise RuntimeError('custom EF must define __call__(self, input)') from e
    raise

Prevention

When it happens

Trigger: A custom embedding function defined as 'def __call__(self, texts)' (wrong parameter name); extra parameters such as 'def __call__(self, input, model)'; legacy pre-0.4.16 embedding functions; callable wrappers (e.g. LangChain or sentence-transformers adapters) whose __call__ signature differs from the protocol.

Common situations: Upgrading chromadb across the 0.4.16 interface change; porting third-party embedding wrappers; renaming parameters for style; custom EFs written against old documentation.

Related errors


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