What distance operators does pgvector support?
RAG & Vector DB Interview: pgvector HNSW, IVFFlat, Index Tuning, Postgres RAG
Audio flashcard · 0:30Nortren·
What distance operators does pgvector support?
0:30
pgvector provides four distance operators: l2-distance for squared Euclidean with the arrow-arrow operator, inner product with the hash-arrow operator, cosine distance with the less-than-arrow operator, and L1 distance for Manhattan with the plus-arrow operator. Cosine distance equals one minus cosine similarity and is the standard for text embeddings. Inner product is faster when vectors are normalized but returns negative values for similar vectors, which requires sign flipping in queries. The operator must match the index's operator class, configured at index creation.
github.com