79175940

Date: 2024-11-10 22:22:25
Score: 1
Natty:
Report link

@GeekyGeek's response is correct and it works.

however, I just wanted to share that I found another solution from this link. I tested out the suggestion and it works like a charm - you can KEEP your collections.add() statement.

However, you're still required to install onnxruntime but no need to specify the onnxruntime version and it should work (I use the latest Nov 2024 version).

pip install onnxruntime

Here is the updated code - I tested it with your collection.add() statement and it works:

# add this import statement 
from chromadb.utils.embedding_functions.onnx_mini_lm_l6_v2 import ONNXMiniLM_L6_V2

# create an embedded function variable 
ef = ONNXMiniLM_L6_V2(preferred_providers=["CPUExecutionProvider"])

# finally, pass the embedding_function parameter in your create_collection statement
collection = client.get_or_create_collection("my_collection", embedding_function=ef)


# now you can run your collection_add() statement successfully
collection.add(
    documents=[
        "This is a document about machine learning",
        "This is another document about data science",
        "A third document about artificial intelligence"
    ],
    metadatas=[
        {"source": "test1"},
        {"source": "test2"},
        {"source": "test3"}
    ],
    ids=[
        "id1",
        "id2",
        "id3"
    ]
)
Reasons:
  • Blacklisted phrase (1): this link
  • Long answer (-1):
  • Has code block (-0.5):
  • User mentioned (1): @GeekyGeek's
  • Low reputation (0.5):
Posted by: punsoca