-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat(PGVector): implement validation for embedding dimensions when creating a vector index for ANN search in pgvector #4732
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
base: main
Are you sure you want to change the base?
Conversation
| """ | ||
| ) | ||
| # pgvector's embedding dimensions requirement to create an index for Approximate Nearest Neighbor (ANN) search is up to 2,000 dimensions for column with type vector | ||
| if self.dimension <= self.MAX_EMBEDDING_DIMENSION_FOR_HNSW_AND_IVFFLAT_INDEX: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably we should log something for the else condition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I am planning to do it along with adding support for IVFFlat after #4714 lands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can log specific information regarding what index user created/attempted to create i.e. HNSW or IVFFlat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logging for indexes will be implemented in PR for this issue #4745
5265de2 to
eff1070
Compare
|
This pull request has merge conflicts that must be resolved before it can be merged. @r3v5 please rebase it. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork |
|
I am solving merge conflict. Almost there :) |
eff1070 to
64c3408
Compare
7c0aad8 to
478f404
Compare
|
It would be great to land current PR as I need it for #4745. |
115a464 to
b9fa2e1
Compare
…eating a pgvector index for ANN search
b9fa2e1 to
f83978d
Compare
|
I will rebase PR tomorrow and solve merge conflict |
|
This pull request has merge conflicts that must be resolved before it can be merged. @r3v5 please rebase it. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork |
What does this PR do?
This PR is responsible for implementing a validation for embedding dimensions when creating a pgvector index for Approximate Nearest Neighbor (ANN) search allowing users to successfully create a vector store in pgvector with higher dimensions without receiving 500 Internal Server Error and the runtime error. Though index won't be created due to limitations, users still will be able to use vector store in pgvector via Llama Stack.
Closes #4731
Test Plan
1. Create vector stores with different embedding dimensions:
curl -X GET "http://localhost:8321/v1/vector_stores"{"object":"list","data":[{"id":"vs_868c6ef3-a713-4b1b-a7ab-f1f267f08f5c","object":"vector_store","created_at":1769435063,"name":"indexed_vector_store","usage_bytes":0,"file_counts":{"completed":0,"cancelled":0,"failed":0,"in_progress":0,"total":0},"status":"completed","expires_after":null,"expires_at":null,"last_active_at":1769435063,"metadata":{"provider_id":"pgvector","provider_vector_store_id":"vs_868c6ef3-a713-4b1b-a7ab-f1f267f08f5c","embedding_model":"sentence-transformers/nomic-ai/nomic-embed-text-v1.5","embedding_dimension":"768"}},{"id":"vs_b9bcd0dc-4a72-4b5f-954e-3f02b1a8569e","object":"vector_store","created_at":1769434929,"name":"indexed_vector_store","usage_bytes":0,"file_counts":{"completed":0,"cancelled":0,"failed":0,"in_progress":0,"total":0},"status":"completed","expires_after":null,"expires_at":null,"last_active_at":1769434929,"metadata":{"provider_id":"pgvector","provider_vector_store_id":"vs_b9bcd0dc-4a72-4b5f-954e-3f02b1a8569e","embedding_model":"openai/text-embedding-3-large","embedding_dimension":"3072"}},{"id":"vs_0babba17-4840-4552-b379-77752fc86149","object":"vector_store","created_at":1769434691,"name":"invoices_store","usage_bytes":0,"file_counts":{"completed":0,"cancelled":0,"failed":0,"in_progress":0,"total":0},"status":"completed","expires_after":null,"expires_at":null,"last_active_at":1769434691,"metadata":{"provider_id":"pgvector","provider_vector_store_id":"vs_0babba17-4840-4552-b379-77752fc86149","embedding_model":"openai/text-embedding-3-large","embedding_dimension":"3072"}}],"first_id":"vs_868c6ef3-a713-4b1b-a7ab-f1f267f08f5c","last_id":"vs_0babba17-4840-4552-b379-77752fc86149","has_more":false}%2. Check that HNSW index was created only on vector store with embedding_dimension = 768: