File size: 550 Bytes
9f3d22b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import chromadb
from sentence_transformers import SentenceTransformer

# Initialize Chroma client
client = chromadb.Client()

# Initialize SentenceTransformer model
model = SentenceTransformer('all-MiniLM-L6-v2')

# Create or load Chroma collection
collection = client.create_collection(name="documents")

# Add documents and their embeddings to Chroma
documents = ['document 1 text', 'document 2 text', 'document 3 text']
embeddings = model.encode(documents)

# Insert documents into Chroma
collection.add(documents=documents, embeddings=embeddings)