Skip to content

Provisioning a Chroma Service#

Summary#

As the demand for advanced enterprise AI solutions continues to grow, vector databases emerge as key enablers for RAG applications. Some common vector databases include Pinecone, Milvus, Chroma, and Weaviate.

In this blog article, we will provision a Chroma vector database on a Macbook Pro using the Ametnes Platform.

Ametnes help you deploy various applications in your private network environment including your local workstation - Laptop or PC as well on-prem and any cloud provider.

Requirements#

Before you can create your ChromaDB service, you'll need to setup an Ametnes application location.

  1. To setup your local laptop as an Ametnes application location, follow these instructions.
  2. To setup your private VM (e.g. EC2 instance) as an Ametnes application location, follow these instructions.

Create the service#

Once you have your Ametnes application location setup,

  1. Signin to your Ametnes account and search for ChromaDB service and click Create Create a ChromaDB Service

  2. In the New ChromaDB Service form, enter all the details including the Name, Location and the API key. Add ChromaDB Service Details

  3. Once the service is provisioned and ready, the endpoint to your service is in the Admin section Administer the ChromaDB Service

Test the service#

You can now connect to your ChromaDB service.

  1. First install the requirements
    pip install chromadb==0.4.18
    pip install chromadb-client==0.4.19.dev0
    
  2. Use the service
chromadb.py
import chromadb
from chromadb.utils import embedding_functions

host = "https://chromadb-6525262439.prod-accounts.ametnes.net"
token = "8F602156-2784-43E7-BA7C-AB63C725F7AA"
client = chromadb.HttpClient(host=host,
                             headers={
                                 'Authorization': f"Bearer {token}"
                             })

default_ef = embedding_functions.ONNXMiniLM_L6_V2()
collection = client.get_or_create_collection(name="documents", embedding_function=default_ef,
                                             metadata={"hnsw:space": "cosine"})

collection.add(
    documents=["This is document 1", "This is document 2"],
    metadatas=[{"source": "notion"}, {"source": "google-docs"}],  # filter on these!
    ids=["doc1", "doc2"],
)

results = collection.query(
    query_texts=["This is a query document"],
    n_results=2,
)

print(results)

Result

{'ids': [['doc1', 'doc2']], 'distances': [[0.9745468583082412, 1.0752288612058232]], 'embeddings': None, 'metadatas': [[{'source': 'notion'}, {'source': 'google-docs'}]], 'documents': [['This is document 1', 'This is document 2']], 'uris': None, 'data': None}

Conclusion#

In this article we've seen how easy it is to provision a Chroma vector database on your local laptop using the Ametnes platform. Ametnes helps you provision various data applications - On your Laptop, PC, on-prem or any cloud provider.