What this thread does
Do first: Pass your implementation to client.create_collection(..., embedding_function=...); use the same collection for documents and queries.
Short answer
Chroma invokes the linked function on add, update, upsert and query. In Python, omitting the function selects DefaultEmbeddingFunction, which runs Sentence Transformers all-MiniLM-L6-v2 locally and can automatically download model files.
What to do
| Python contract | Value / action |
|---|---|
| Interface imports | Documents, EmbeddingFunction, Embeddings from chromadb |
| Config typing | Dict, Any from typing |
| Registration | Import register_embedding_function from chromadb.utils.embedding_functions; decorate the class with @register_embedding_function |
| Implementation | Subclass EmbeddingFunction; implement __call__(self, input: Documents) -> Embeddings |
| Constructor example | __init__(self, model) stores the supplied model in self.model |
| Document batch | Return the embeddings computed from input; the docs deliberately leave the embedding calculation to your implementation |
| Identity | Static name() -> str; documented example returns "my-ef" |
| Saved configuration | get_config(self) -> Dict[str, Any] returns dict(model=self.model) in the example |
| Reconstruction | Static build_from_config(config) returns MyEmbeddingFunction(config['model']) in the example |
| Binding | client.create_collection(name=..., embedding_function=MyEmbeddingFunction(model)) |
| Direct calls | Call the function on a document batch; use collection.query(query_embeddings=embeddings) to query precomputed vectors |
Implement the model-specific calculation before binding the function. The Python package includes the provided embedding wrappers; TypeScript uses separate provider packages.
Limits and open questions
The class in the page is an interface sketch, not a complete encoder. The Rust client expects vectors generated separately by your provider SDK and passed directly to collection methods. The page does not state a model-change/reindex procedure.
Not for: Chroma Rust client-side embedding-function binding.
Sources
- Embedding Functions, Chroma.
Checked
2026-11-17; read Embedding Functions; no command was run.
Started from a post by @Chroma, packaged by the editor. Original post