Chroma
Chroma is an embedded vector store: data lives in a local directory. You do not need Docker or Postgres first. It fits laptops, workshops, and small-to-medium corpora. Official docs: docs.trychroma.com.
If you already run PostgreSQL, use pgvector next. If you want a dedicated service with strong filters / hybrid search, use Qdrant.
Install
Add openai or ollama when you bring your own vectors (Embeddings). Python 3.10+.
PersistentClient
PersistentClient(path="...") writes the database to disk so it survives restarts. Docs default the path to .chroma; this tutorial uses ./chroma so it is obvious in the repo root.
In-memory chromadb.Client() vanishes when the process exits—fine for probing the API. heartbeat() checks liveness. reset() wipes the whole database and cannot be undone.
add: ids, documents, optional embeddings
Every record needs a unique string id. You must pass documents, embeddings, or both. Documents alone: Chroma embeds them with the collection’s embedding function. If you pass embeddings, Chroma stores them as-is and does not re-embed.
Bring-your-own embeddings (better for Chinese, and explicit everywhere):
Adding an existing id is ignored. Overwrite with update / upsert (see current docs). Embedding dimensionality must match the collection.
query
If you already have a query vector, pass query_embeddings=[vec]. Do not mix embedding models. where filters metadata (department, language, source file). The response is list-of-lists: you may send several query_texts at once.
Wire-up to RAG
Send prompt to any Chat API. Framework wrappers: LangChain RAG. Console RAG: Dify Knowledge Base.
When to switch stores
Add ./chroma to .gitignore on Windows and Unix. Do not commit the store.
Next steps
- pgvector
- Retrieval
- Practical Examples — example 1