Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embeddings column type and vector similarity search #1163

Open
nileshtrivedi opened this issue Dec 12, 2024 · 0 comments
Open

Embeddings column type and vector similarity search #1163

nileshtrivedi opened this issue Dec 12, 2024 · 0 comments
Assignees
Labels
feature help wanted Extra attention is needed

Comments

@nileshtrivedi
Copy link

I would like to be able to perform similarity search over vector embeddings generated by language models to find records in a table.

Describe the solution you'd like
Postgresql has an extension pgvector which allows easy storage and query over embedding vectors.

It supports:
- exact and approximate nearest neighbor search
- single-precision, half-precision, binary, and sparse vectors
- L2 distance, inner product, cosine distance, L1 distance, Hamming distance, and Jaccard distance
- any language with a Postgres client

Sample usage in SQL:

CREATE EXTENSION vector;
-- Create a vector column with 3 dimensions
CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3));

-- Insert Vectors
INSERT INTO items (embedding) VALUES ('[1,2,3]'), ('[4,5,6]');

-- Get the nearest neighbors by L2 distance
SELECT * FROM items ORDER BY embedding <-> '[3,1,2]' LIMIT 5;

pgvector supports inner product (<#>), cosine distance (<=>), and L1 distance (<+>, added in 0.7.0)

These operations are agnostic of the model which was used to generate these embedding vectors.

@caoxing9 caoxing9 self-assigned this Dec 12, 2024
@caoxing9 caoxing9 added feature good first issue Good for newcomers help wanted Extra attention is needed and removed good first issue Good for newcomers labels Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants