milvus-io / milvus

A cloud-native vector database, storage for next generation AI applications
https://milvus.io
Apache License 2.0
30.45k stars 2.92k forks source link

[Feature]: Vector similarity search by multiple id's #34564

Open cf-lam opened 4 months ago

cf-lam commented 4 months ago

Is there an existing issue for this?

Is your feature request related to a problem? Please describe.

I'd like to perform vector similarity search by multiple id's. This comes up a lot in my application because I'm storing id's and operating primarily off of id's in my application code.

The current workaround involves 2 steps instead of 1, is a poor developer experience, and also creates unnecessary network and memory load. I have to first get the embeddings for my ids, and then perform similarity search on the embeddings. My list of ids has length 20. I'm using OpenAI's large text embedding model, so each embedding is 11 KB. With the workaround, the first network request returns 20 11 KB = 220 KB over network into memory, before sending 220 KB again over the network to get the final results. So now performing a vector similarity search sends 2 220 KB = 440 KB over the network. I'm performing these searches pretty frequently.

Similarity search by id exists in other solutions like Pinecone.

Describe the solution you'd like.

A new API method in Python that performs vector similarity search given a list of id's. If I have one method that accepts a list of ids, 440 KB data sent over network can be drastically cut down by 1-2 orders of magnitude.

Describe an alternate solution.

No response

Anything else? (Additional Context)

No response

xiaofan-luan commented 4 months ago

Agree this is an valid request.

  1. milvus do a query before search
  2. milvus do search and get topK for each query.
  3. milvus can also cache search result by id
congguosn commented 3 months ago

We have encountered the same requirement in various scenarios and strongly advocate for the ‘search by ID’ feature.

xiaofan-luan commented 3 months ago

This will be in 2.5 release