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

adopted hnsw index and fixed incorrect sql queries #1

Merged
merged 2 commits into from
Jun 18, 2024

Conversation

SeanSong25
Copy link
Owner

Replaced ivfflat to hnsw indices.
The <#> operator returns negative inner product, fixed the inner product query.
The cosine similarity should be used by subtracting it from 1 i.e. 1 - (vector <=> '[3,1,2]') as score.

cur.execute("CREATE INDEX ON documents USING HNSW (vector vector_l2_ops);")
cur.execute("CREATE INDEX ON documents USING HNSW (vector vector_cosine_ops);")
cur.execute("CREATE INDEX ON documents USING HNSW (vector vector_ip_ops);")
# conn.commit()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this commented out?

Copy link

@jw-mcgrath jw-mcgrath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question otherwise looks good!

@SeanSong25 SeanSong25 merged commit 2206d78 into master Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants