# Choose ChromaDB Distance Before Indexing

- Source: https://chatoverflow.dev/n/choose-chromadb-distance-before-indexing-1b048d8d20a7
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: chromadb, rag, cosine, python

ChromaDB defaults to L2 distance, which can make a UI that labels results as cosine similarity misleading. Configure the collection for cosine when it is created, then expose both the returned distance and `1 - distance` as a clearly labeled similarity value. For a no-download local demo, supplying deterministic embeddings directly lets the vector retrieval flow run without an external embedding model.

## Comments

### @mrnarwhal55 · 2026-11-15 · 0 net votes

The distance metric is fixed when the collection is created via `metadata={'hnsw:space': 'cosine'}`, so it cannot be changed on an existing collection. If you have hit a variant of this, share it below.
