Skip to main content
Chroma uses embedding functions to convert your documents and queries into vector representations. You can use built-in embedding functions or create your own.

Default Embedding Function

If you don’t specify an embedding function, Chroma uses the default ONNX MiniLM-L6-v2 model:
The default embedding function creates 384-dimensional vectors using the all-MiniLM-L6-v2 model.

Built-in Embedding Functions

OpenAI Embeddings

Use OpenAI’s embedding models:
Available OpenAI models:
  • text-embedding-ada-002 - Most capable, 1536 dimensions
  • text-embedding-3-small - Smaller, faster
  • text-embedding-3-large - Highest quality

Cohere Embeddings

Use Cohere’s embedding models:

Hugging Face Embeddings

Use any Sentence Transformers model:
Popular models:
  • all-MiniLM-L6-v2 - Fast, 384 dimensions
  • all-mpnet-base-v2 - High quality, 768 dimensions
  • paraphrase-multilingual-MiniLM-L12-v2 - Multilingual support

Instructor Embeddings

Task-specific embeddings with instructions:

Google Gemini Embeddings

Amazon Bedrock Embeddings

Custom Embedding Functions

Create your own embedding function by implementing the EmbeddingFunction protocol:

Custom Function Requirements

Your embedding function must:
  1. Implement __call__ - Takes Documents and returns List[List[float]]
  2. Implement name() - Returns a unique identifier
  3. Implement build_from_config() - Recreates function from config
  4. Implement get_config() - Returns serializable configuration
  5. Return consistent dimensions - All embeddings must have same length

Advanced Custom Function

Embedding Function Configuration

Distance Metrics

Different embedding functions work best with different distance metrics:
Distance metrics:
  • cosine - Cosine similarity (default, recommended for most models)
  • l2 - Euclidean distance
  • ip - Inner product

Query vs. Document Embeddings

Some embedding functions support different embeddings for queries vs documents:

Working with Multiple Modalities

Multimodal Embeddings

For images and text:

Performance Considerations

Batch Processing

Embedding functions process documents in batches:

Caching

Implement caching in custom functions:

Troubleshooting

Dimension Mismatch

API Rate Limits

Memory Issues

For large batches, process in chunks: