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

Add similarity threshold to (.findNearest) queries in addition to returning similarity scores. #2079

Open
Moe03 opened this issue Jun 30, 2024 · 6 comments
Assignees
Labels
api: firestore Issues related to the googleapis/nodejs-firestore API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@Moe03
Copy link

Moe03 commented Jun 30, 2024

Is your feature request related to a problem? Please describe.
I'm trying to be able to add a thresold to my similarity search with vectors but it doesn't semm to be mentioned here anywhere?
https://firebase.google.com/docs/firestore/vector-search#node.js_2

Describe the solution you'd like
Adding a field called similarityThreshold to the vector search query would be perfect:

const searchRes = await dbToUse.collection(`voiceglow/${agentData.ID}/kb_chunks`).findNearest("vector", 
   FieldValue.vector(searchVector), {
   limit: 5,
   distanceMeasure: 'COSINE',
   similarityThresohold: 0.2 // add this (currently doesn't work)
}).get();

Also adding to the queryies of such types (.findNearest) the similarity score with the search vector is highly beneficial for debugging purposes, we're currenlty using pgvector on postgres but would love to migrate everything on firestore but these may be annoying to deal with.

Describe alternatives you've considered
There is nothing mentioned in the docs, I hope it's already implemented but not docuemented/typed properly?

@Moe03 Moe03 added priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Jun 30, 2024
@product-auto-label product-auto-label bot added the api: firestore Issues related to the googleapis/nodejs-firestore API. label Jun 30, 2024
@Moe03 Moe03 changed the title Add similarity threshold and to FieldValue.vector queries in addition to the similarity values. Add similarity threshold to (.findNearest) queries in addition to returning similarity scores. Jun 30, 2024
@tom-andersen
Copy link
Contributor

@MarkDuckworth Could you take this into consideration as part of your API design?

@dave-lacy
Copy link

+1 this would be great to have

@MarkDuckworth
Copy link
Contributor

Thanks for the feedback. I've passed it along to the rest of the team working on vector search in Firestore.

I can confirm that similarity threshold and returning the vector distance is not supported as of today. The Firestore vector search feature is currently in Preview and it is not necessarily feature complete.

@joshke
Copy link

joshke commented Aug 29, 2024

+1 definitely needed

@manucorporat
Copy link

This is supported in Javascript and other languages, how can we speed up the process? would a PR be accepted?

@pogorv12
Copy link

Hello!

Check this #2217. It might help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the googleapis/nodejs-firestore API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

7 participants