Installation
Python
The
sentence-transformers library is required for using Hugging Face models with Chroma.Using Sentence Transformers
Basic usage
Popular models
- General purpose
- Multilingual
- Specialized
Using the Hugging Face API
With HuggingFace Inference API
With a custom inference endpoint
Device configuration
Model selection guide
Fast & efficient
all-MiniLM-L6-v2 (384 dims)
Best for: High-throughput applications, real-time search
Best for: High-throughput applications, real-time search
High quality
all-mpnet-base-v2 (768 dims)
Best for: When accuracy is more important than speed
Best for: When accuracy is more important than speed
Multilingual
paraphrase-multilingual-MiniLM-L12-v2 (384 dims)
Best for: Multi-language content
Best for: Multi-language content
Code search
multi-qa-mpnet-base-dot-v1 (768 dims)
Best for: Question-answering systems
Best for: Question-answering systems
Configuration options
string
required
Name of the Sentence Transformer model from Hugging Face
string
default:"cpu"
Device to run the model on:
cpu, cuda, or cuda:Nbool
default:"false"
Whether to normalize embeddings to unit length
string
Hugging Face API token (for HuggingFaceEmbeddingFunction)
Custom models
Load a fine-tuned model
Load a local model
Performance optimization
Batch processing
Model caching
Finding models
Browse thousands of models on Hugging Face:- Visit Hugging Face Models
- Filter by:
- Task: “Sentence Similarity” or “Feature Extraction”
- Library: “sentence-transformers”
- Check model card for:
- Embedding dimensions
- Languages supported
- Performance metrics
- License
Best practices
Choose the right model size
Choose the right model size
- Smaller models (384 dims): Faster, use less storage
- Larger models (768+ dims): Better quality, slower
- Consider your performance requirements vs. accuracy needs
Use GPU for large datasets
Use GPU for large datasets
If you’re processing thousands of documents, using a GPU can significantly speed up embedding generation.
Cache downloaded models
Cache downloaded models
Models are cached after first download. Set
SENTENCE_TRANSFORMERS_HOME to control cache location.Test different models
Test different models
Different models excel at different tasks. Test multiple models with your specific use case.