Chroma

FirstBatch integrates Chroma through the Chroma Class.

Example run:

import chromadb
from firstbatch import Chroma

path = os.environ["CHROMA_CLIENT_PATH"]
collection = "default"
client = chromadb.PersistentClient(path=path)
embedding_size = int(os.environ["EMBEDDING_SIZE"])
config = Config(batch_size=20, verbose=True)
personalized = FirstBatch(api_key=os.environ["FIRSTBATCH_API_KEY"], config=config)
personalized.add_vdb("chroma_db", Chroma(client=client, collection_name=collection, embedding_size=embedding_size))

Distance metric can explicitly be provided. If not, default value is COSINE_SIM

class DistanceMetric(Enum):
    COSINE_SIM = "cosine_sim"
    EUCLIDEAN_DIST = "euclidean_dist"
    DOT_PRODUCT = "dot_product"
from firstbatch import DistanceMetric

Chroma(client=client, collection_name=collection, 
distance_metric=DistanceMetric.EUCLIDEAN_DIST)

Last updated