Skip to content

Instantly share code, notes, and snippets.

@yasushisakai
Created February 13, 2024 22:02
Show Gist options
  • Save yasushisakai/3d78beb4e8cd4efeeed355e57e036f76 to your computer and use it in GitHub Desktop.
Save yasushisakai/3d78beb4e8cd4efeeed355e57e036f76 to your computer and use it in GitHub Desktop.
vector database small example

vector database example using chroma

import chromadb
client = chromadb.Client()
collection = client.create_collection(name="fruits")
collection.add(
embeddings=[[1.25, 0.3, 0.4], [0.30, 0.5, 0.05], [1.00, 0.35, 0.5]],
documents=["apples", "bananas", "strawberries"],
metadatas=[{"store":"wholefoods"}, {"store":"traders joes"}, {"store": "wholefoods"}],
ids=["a", "b", "s"]
)
blueberries = [0.8, 0.3, 0.3]
result = collection.query(
query_embeddings=[blueberries],
n_results=1
)
print(result['documents'][0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment