1. Project Overview & Quickstart (chroma-core/integrations)
integrations
Open-source repository chroma-core/integrations
Repository Details
- Repository: chroma-core/integrations
- Primary Language: Code
Note: High-volume repository documentation is actively indexed and synchronized by YakaAI.
2. Official Technical Reference & Guides (chroma-core/docs)
File: README.md
Deprecated
The docs are now in a monorepo with the rest of the codebase.
Read the new readme here:
https://github.com/chroma-core/chroma/tree/main/docs/docs.trychroma.com
Chroma docs
These docs are built using Docusaurus 2
Installation
$ yarnLocal Development
$ yarn startThis command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
Build
$ yarn buildThis command generates static content into the build directory and can be served using any static contents hosting service.
Generating Python Docs
- Have chroma as a sibling to the the docs dir, eg
/docs
/chromaUpdate
pydoc-markdown.ymlif you need to expose more files other than Collection and ClientRun
yarn gen-python
Deployment
Vercel handles deploying main to https://docs.trychroma.com
Generating Javascript Docs
- Have chroma as a sibling to the the docs dir, eg
/docs
/chromaUpdate
scripts/jsDocs.sh,sidebar.jsonif you need to expose more files other than Collection and ClientRun
yarn gen-js
File: docs/api/index.md
slug: /api title: 🔧 API
🔧 API
Client APIs
Chroma currently maintains 1st party clients for Python and Javascript. For other clients in other languages, use their repos for documentation.
Client - is the object that wraps a connection to a backing Chroma DB
Collection - is the object that wraps a collection
| Client | Collection | |
|---|---|---|
| Python | Client | Collection |
| Javascript | Client | Collection |
Backend API
Chroma's backend Swagger REST API docs are viewable by running Chroma and navigating to http://localhost:8000/docs.
pip install chromadb
chroma run
open http://localhost:8000/docsFile: docs/embeddings/cohere.md
Cohere
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
Select a language
Chroma also provides a convenient wrapper around Cohere's embedding API. This embedding function runs remotely on Cohere’s servers, and requires an API key. You can get an API key by signing up for an account at Cohere.
This embedding function relies on the cohere python package, which you can install with pip install cohere.
import chromadb.utils.embedding_functions as embedding_functions
cohere_ef = embedding_functions.CohereEmbeddingFunction(api_key="YOUR_API_KEY", model_name="large")
cohere_ef(texts=["document1","document2"])const {CohereEmbeddingFunction} = require('chromadb');
const embedder = new CohereEmbeddingFunction("apiKey")
// use directly
const embeddings = embedder.generate(["document1","document2"])
// pass documents to query for .add and .query
const collection = await client.createCollection({name: "name", embeddingFunction: embedder})
const collectionGet = await client.getCollection({name:"name", embeddingFunction: embedder})You can pass in an optional model_name argument, which lets you choose which Cohere embeddings model to use. By default, Chroma uses large model. You can see the available models under Get embeddings section here.
Multilingual model example
cohere_ef = embedding_functions.CohereEmbeddingFunction(
api_key="YOUR_API_KEY",
model_name="multilingual-22-12")
multilingual_texts = [ 'Hello from Cohere!', 'مرحبًا من كوهير!',
'Hallo von Cohere!', 'Bonjour de Cohere!',
'¡Hola desde Cohere!', 'Olá do Cohere!',
'Ciao da Cohere!', '您好,来自 Cohere!',
'कोहिअर से नमस्ते!' ]
cohere_ef(texts=multilingual_texts)const {CohereEmbeddingFunction} = require('chromadb');
const embedder = new CohereEmbeddingFunction("apiKey")
multilingual_texts = [ 'Hello from Cohere!', 'مرحبًا من كوهير!',
'Hallo von Cohere!', 'Bonjour de Cohere!',
'¡Hola desde Cohere!', 'Olá do Cohere!',
'Ciao da Cohere!', '您好,来自 Cohere!',
'कोहिअर से नमस्ते!' ]
const embeddings = embedder.generate(multilingual_texts)For more information on multilingual model you can read here.
File: docs/embeddings/google-gemini.md
Google Generative AI
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
Select a language
Chroma provides a convenient wrapper around Google's Generative AI embedding API. This embedding function runs remotely on Google's servers, and requires an API key.
You can get an API key by signing up for an account at Google MakerSuite.
This embedding function relies on the google-generativeai python package, which you can install with pip install google-generativeai.
# import
import chromadb.utils.embedding_functions as embedding_functions
# use directly
google_ef = embedding_functions.GoogleGenerativeAiEmbeddingFunction(api_key="YOUR_API_KEY")
google_ef(["document1","document2"])
# pass documents to query for .add and .query
collection = client.create_collection(name="name", embedding_function=google_ef)
collection = client.get_collection(name="name", embedding_function=google_ef)You can view a more complete example chatting over documents with Gemini embedding and langauge models.
For more info - please visit the official Google python docs.
This embedding function relies on the @google/generative-ai npm package, which you can install with yarn add @google/generative-ai.
import { ChromaClient, GoogleGenerativeAiEmbeddingFunction } from 'chromadb'
const embedder = new GoogleGenerativeAiEmbeddingFunction({googleApiKey: "<YOUR API KEY>"})
// use directly
const embeddings = await embedder.generate(["document1","document2"])
// pass documents to query for .add and .query
const collection = await client.createCollection({name: "name", embeddingFunction: embedder})
const collectionGet = await client.getCollection({name:"name", embeddingFunction: embedder})You can view a more complete example using Node.
For more info - please visit the official Google JS docs.
File: docs/embeddings/google-palm.md
Google PaLM
Google PaLM APIs are currently in private preview, but if you are part of this preview, you can use them with Chroma via the GooglePalmEmbeddingFunction.
To use the PaLM embedding API, you must have google.generativeai Python package installed and have the API key. To use:
import chromadb.utils.embedding_functions as embedding_functions
palm_embedding = embedding_functions.GooglePalmEmbeddingFunction(
api_key=api_key, model_name=model_name)File: docs/embeddings/hugging-face.md
Hugging Face
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
Select a language
Chroma also provides a convenient wrapper around HuggingFace's embedding API. This embedding function runs remotely on HuggingFace's servers, and requires an API key. You can get an API key by signing up for an account at HuggingFace.
This embedding function relies on the requests python package, which you can install with pip install requests.
import chromadb.utils.embedding_functions as embedding_functions
huggingface_ef = embedding_functions.HuggingFaceEmbeddingFunction(
api_key="YOUR_API_KEY",
model_name="sentence-transformers/all-MiniLM-L6-v2"
)You can pass in an optional model_name argument, which lets you choose which HuggingFace model to use. By default, Chroma uses sentence-transformers/all-MiniLM-L6-v2. You can see a list of all available models here.
File: docs/embeddings/hugging-face-embedding-server.md
Hugging Face Text Embedding Server
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
Select a language
Chroma provides a convenient wrapper for HuggingFace Text Embedding Server, a standalone server that provides text embeddings via a REST API. You can read more about it here.
Setting Up The Server
To run the embedding server locally you can run the following command from the root of the Chroma repository. The docker compose command will run Chroma and the embedding server together.
docker compose -f examples/server_side_embeddings/huggingface/docker-compose.yml up -dor
docker run -p 8001:80 -d -rm --name huggingface-embedding-server ghcr.io/huggingface/text-embeddings-inference:cpu-0.3.0 --model-id BAAI/bge-small-en-v1.5 --revision -main:::note
The above docker command will run the server with the BAAI/bge-small-en-v1.5 model. You can find more information about running the server in docker here.
:::
Usage
This embedding function relies on the requests python package, which you can install with pip install requests.
from chromadb.utils.embedding_functions import HuggingFaceEmbeddingServer
huggingface_ef = HuggingFaceEmbeddingServer(url="http://localhost:8001/embed")The embedding model is configured on the server side. Check the docker-compose file in examples/server_side_embeddings/huggingface/docker-compose.yml for an example of how to configure the server.
import {HuggingFaceEmbeddingServerFunction} from 'chromadb';
const embedder = new HuggingFaceEmbeddingServerFunction({url:"http://localhost:8001/embed"})
// use directly
const embeddings = embedder.generate(["document1","document2"])
// pass documents to query for .add and .query
const collection = await client.createCollection({name: "name", embeddingFunction: embedder})
const collection = await client.getCollection({name: "name", embeddingFunction: embedder})File: docs/embeddings/instructor.md
Instructor
The instructor-embeddings library is another option, especially when running on a machine with a cuda-capable GPU. They are a good local alternative to OpenAI (see the Massive Text Embedding Benchmark rankings). The embedding function requires the InstructorEmbedding package. To install it, run pip install InstructorEmbedding.
There are three models available. The default is hkunlp/instructor-base, and for better performance you can use hkunlp/instructor-large or hkunlp/instructor-xl. You can also specify whether to use cpu (default) or cuda. For example:
#uses base model and cpu
import chromadb.utils.embedding_functions as embedding_functions
ef = embedding_functions.InstructorEmbeddingFunction()or
import chromadb.utils.embedding_functions as embedding_functions
ef = embedding_functions.InstructorEmbeddingFunction(
model_name="hkunlp/instructor-xl", device="cuda")Keep in mind that the large and xl models are 1.5GB and 5GB respectively, and are best suited to running on a GPU.
File: docs/embeddings/jinaai.md
Jina AI
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
Select a language
Chroma provides a convenient wrapper around JinaAI's embedding API. This embedding function runs remotely on JinaAI's servers, and requires an API key. You can get an API key by signing up for an account at JinaAI.
This embedding function relies on the requests python package, which you can install with pip install requests.
import chromadb.utils.embedding_functions as embedding_functions
jinaai_ef = embedding_functions.JinaEmbeddingFunction(
api_key="YOUR_API_KEY",
model_name="jina-embeddings-v2-base-en"
)
jinaai_ef(input=["This is my first text to embed", "This is my second document"])You can pass in an optional model_name argument, which lets you choose which Jina model to use. By default, Chroma uses jina-embedding-v2-base-en.
const {JinaEmbeddingFunction} = require('chromadb');
const embedder = new JinaEmbeddingFunction({
jinaai_api_key: 'jina_****',
model_name: 'jina-embeddings-v2-base-en',
});
// use directly
const embeddings = embedder.generate(['document1', 'document2']);
// pass documents to query for .add and .query
const collection = await client.createCollection({name: "name", embeddingFunction: embedder})
const collectionGet = await client.getCollection({name:"name", embeddingFunction: embedder})File: docs/embeddings/ollama.md
Ollama Embeddings
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
Select a language
Chroma provides a convenient wrapper around Ollama'
s embeddings API. You can use
the OllamaEmbeddingFunction embedding function to generate embeddings for your documents with
a model of your choice.
import chromadb.utils.embedding_functions as embedding_functions
ollama_ef = embedding_functions.OllamaEmbeddingFunction(
url="http://localhost:11434/api/embeddings",
model_name="llama2",
)
embeddings = ollama_ef(["This is my first text to embed",
"This is my second document"])// const {OllamaEmbeddingFunction} = require('chromadb'); //CJS import
import {OllamaEmbeddingFunction} from "chromadb"; //ESM import
const embedder = new OllamaEmbeddingFunction({
url: "http://127.0.0.1:11434/api/embeddings",
model: "llama2"
})
// use directly
const embeddings = embedder.generate(["document1", "document2"])
// pass documents to query for .add and .query
const collection = await client.createCollection({
name: "name",
embeddingFunction: embedder
})
const collection = await client.getCollection({
name: "name",
embeddingFunction: embedder
})You can pass in an optional model_name argument, which lets you choose which OpenAI embeddings model to use. By
default, Chroma uses text-embedding-ada-002. You can see a list of all available
models here.