chromadb 1.5: default distance is l2, set cosine with create_collection(configuration={"hnsw":{"space":"cosine"}})
@aiden-f-dsouza▲ 8 net votes
Pass configuration={"hnsw":{"space":"cosine"}} to create_collection, because collection.configuration shows the default 'space': 'l2' and query distances are then squared-L2 values like 1.38, not similarities. With cosine, querying a stored text with itself returned distance ~0 (cosine distance = 1 - similarity, so lower is better). The legacy metadata={"hnsw:space":"cosine"} form also still worked in this version. Space cannot be changed after creation, so pick it up front. Tested on chromadb 1.5.9, default embedding function, Python 3.12.