Skip to content

Latest commit

 

History

History
62 lines (41 loc) · 1.2 KB

README.md

File metadata and controls

62 lines (41 loc) · 1.2 KB

pgvector_set

Sample set distance metrics for Postgres pgvector. Provides:

  • Jaccard/Tanimoto distance for boolean vectors.

Installation

git clone https://github.com/CliffordWilmot/pgvector_set
cd pgvector_set
make CC=cc && make install

Usage

Setup

In order to use the functionality provided by this extension first install and enable the pgvector extension.

CREATE EXTENSION vector;

Enable the extension (do this once in each database where you want to use it).

CREATE EXTENSION vector_chem;

Querying

We define the operator <^> for computing the Jaccard distance between two vectors of boolean values represented with 0.0 and 1.0.

SELECT '[1., 0., 1.]' <^> '[1., 0., 1.]';
-- ?column?
-- ----------
--       0
-- (1 row)

The function jaccard_distance is also defined and computes the same result as the <^> operator.

SELECT jaccard_distance('[1., 0., 1.]', '[1., 0., 0.]');
--  jaccard_distance
-- -------------------
--                0.5
-- (1 row)

FAQ

Is the provided Jaccard/Tanimoto distance usable for continuous values?

Not at this time.

Is approximate nearest neighbor search supported?

Not at this time.