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

indexing.hnsw.quantization.scalar does not improve the performance of query the similar embeddings #572

Open
janljd opened this issue Aug 27, 2024 · 0 comments
Labels
type/question 🙋 Further information is requested

Comments

@janljd
Copy link

janljd commented Aug 27, 2024

Environment

docker tensorchord/pgvecto-rs:pg16-v0.3.0

Data preparation

CREATE TABLE dbpedia_3072 (
            id bigserial primary key, 
            title text,
            content text,
            embedding vector(3072)
            );
           
CREATE INDEX hnsw_cosine_index_dbpedia_3072 ON dbpedia_3072 USING vectors (embedding vector_cos_ops) WITH (options='[indexing.hnsw]
m = 16
ef_construction = 100
');


CREATE TABLE dbpedia_3072_scalar (
            id bigserial primary key, 
            title text,
            content text,
            embedding vector(3072)
            );
           
CREATE INDEX hnsw_cosine_index_dbpedia_3072_scalar ON dbpedia_3072_scalar USING vectors (embedding vector_cos_ops) WITH (options='[indexing.hnsw]
m = 16
ef_construction = 100
[indexing.hnsw.quantization.scalar]
');

dataset https://huggingface.co/datasets/Qdrant/dbpedia-entities-openai3-text-embedding-3-large-3072-100K

Test

Simulate 100 users randomly querying 3072-dimensional vectors for similar embeddings

SELECT 1 - (embedding <=> %s) AS cosine_similarity,title,content FROM dbpedia_3072 ORDER BY embedding <=> %s LIMIT 1

SELECT 1 - (embedding <=> %s) AS cosine_similarity,title,content FROM dbpedia_3072_scalar ORDER BY embedding <=> %s LIMIT 1

Result

dbpedia_3072 dbpedia_3072_scalar
avg 13.66 ms 12.46 ms
rps 732.4 765.5
max cpu / memory max cpu 330% / 1033MB max cpu 270% / 1300MB

index stat

SELECT tablename,idx_status,idx_size,idx_options FROM pg_vector_index_stat

tablename idx_status idx_size idx_options
dbpedia_3072 NORMAL 1,236,929,603 {"vector":{"dimensions":3072,"vector":"Vecf32","distance":"Cos"},"segment":{"max_growing_segment_size":20000,"max_sealed_segment_size":1000000},"indexing":{"hnsw":{"m":16,"ef_construction":100,"quantization":{"trivial":{}}}}}
dbpedia_3072_scalar NORMAL 1,547,237,503 {"vector":{"dimensions":3072,"vector":"Vecf32","distance":"Cos"},"segment":{"max_growing_segment_size":20000,"max_sealed_segment_size":1000000},"indexing":{"hnsw":{"m":16,"ef_construction":100,"quantization":{"scalar":{}}}}}
@gaocegege gaocegege added the type/question 🙋 Further information is requested label Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/question 🙋 Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants