匠人学院 JR Academy
Skip to article
Learning guide
ChromaDB Guide

Build local and lightweight retrieval systems with ChromaDB, embeddings, and RAG workflows.

2 chapters·4 guides·Access varies by chapter
Embeddings
On this page

ChromaDB Embedding Functions

Embedding choice affects retrieval, but inspect chunking and collection design before assuming the model is the problem.

#Default/local baseline

The source describes the all-MiniLM-L6-v2 default as a small local baseline and notes limitations for Chinese tasks. Confirm the default in your installed version and evaluate on your own language/domain examples.

#External provider example

python
import os from chromadb.utils import embedding_functions openai_ef = embedding_functions.OpenAIEmbeddingFunction( api_key=os.environ["OPENAI_API_KEY"], model_name="text-embedding-3-small", ) collection = client.get_or_create_collection( name="my_collection", embedding_function=openai_ef )

This invokes a separately configured provider when used; it is not an offline example.

#Language-specific models

The source uses BAAI/bge-small-zh-v1.5 as an example for Chinese retrieval. Distinguish local Sentence Transformers execution from a hosted Hugging Face API embedding function; model location and execution mode are separate choices.

#Custom function interface

python
from chromadb.api.types import Documents, Embeddings class MyEmbeddingFunction: def __call__(self, input: Documents) -> Embeddings: raise NotImplementedError("Return one valid vector per input document")

This is an interface skeleton, not a working embedding implementation. Use the version's required embedding-function protocol and lifecycle methods.

#Do not mix embedding spaces

A collection with stored vectors has a fixed dimension. A 384-dimensional space cannot simply accept 1536-dimensional vectors. Even matching dimensions do not make different model spaces compatible.

Create a separate collection, re-embed the corpus and compare retrieval on a stable evaluation set before switching a production reader. Record the model, dimensions and preprocessing so improvements remain attributable.

Published by
JR Academy
Learning resources

Individual authors and reviewers are credited where recorded.

System Design

Core system design concepts and practical case studies

Learn the trade-offs and patterns that matter in technical interviews.

Open System Design →

Related Roadmaps

Done reading? Next steps