Skip to main content

Overview

Chroma is an open-source embedding database that can run locally or as a server. It’s designed for simplicity and ease of use.

Installation

Basic Usage

Constructor Options

string
default:"llamaindex"
Name of the Chroma collection
ChromaClient
Custom Chroma client instance
string
default:"http://localhost:8000"
Chroma server URL
number
default:100
Batch size for operations

Setup Options

In-Memory (Default)

Persistent Local Storage

Remote Server

Running Chroma Server

Docker

Python

Querying

Basic Query

Metadata Filtering

Collections

Manage multiple collections:

Managing Data

Add Documents

Delete Documents

Clear Collection

Loading Existing Collection

Distance Metrics

Chroma supports different distance metrics:

Embedding Functions

Use custom embedding functions:

Complete Example

Best Practices

  1. Use persistent storage: Enable data persistence for production
  2. Choose appropriate metric: Cosine for most text use cases
  3. Organize with collections: Separate data by use case or environment
  4. Run server for production: Use Chroma server for scalability
  5. Monitor memory: In-memory mode limited by available RAM

Troubleshooting

Connection Error

Collection Already Exists

See Also