Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: When using add() to insert embeddings and ids, I found that the maximum number is only 100. Why? #3437

Open
13hgj14 opened this issue Jan 8, 2025 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@13hgj14
Copy link

13hgj14 commented Jan 8, 2025

What happened?

start_time = time.time()
client = chromadb.PersistentClient(path="./chroma")
# client = chromadb.Client()
end_time = time.time()
print(end_time - start_time)

start_time = time.time()
collection = client.get_or_create_collection(name="test_collection", 
                                            metadata={"hnsw:space": "cosine",
                                                      "hnsw:search_ef": 100})
start_time = time.time()
results = collection.get()
end_time = time.time()
print(end_time - start_time)
print(results)

embedding = np.random.randn(1000, 768).astype(np.float32).tolist()
num = 0
keys = [str(i) for i in range(num, num + embedding.__len__())]
metadatas = [{"keys":v} for v in keys]
print(keys[:10])
print(embedding.__len__())
print(metadatas.__len__())

dict_ = {
    "id1": {"source": "doc1"},
    "id2": {"source": "doc2"},
    "id3": {"source": "doc3"}
}

try:
    collection.add(
        ids=keys,           
        embeddings=embedding,
        # metadatas=list(dict_.values()),  
        metadatas=metadatas,  
    )
   print(“success”)
except Exception as e:
   print("defeat")

start_time = time.time()
results = collection.get()
end_time = time.time()
print(end_time - start_time)
print(results)

Versions

Chroma 0.6.1, Windows

Relevant log output

@13hgj14 13hgj14 added the bug Something isn't working label Jan 8, 2025
@tazarov
Copy link
Contributor

tazarov commented Jan 8, 2025

@13hgj14, what is the exact error you get? There are cases where your sqlite3 system library in such a way that limits the number of inserts that Chroma can do.

Can you also try:

docker run -d --rm  -p 8000:8000 --name chromadb -v ./chroma:/chroma/chroma -e IS_PERSISTENT=TRUE chromadb/chroma:0.6.1

Then use the same code above but with HttpClient instead.

@tazarov tazarov self-assigned this Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants