genkit icon indicating copy to clipboard operation
genkit copied to clipboard

[FR] Support using a similarity threshold in Firestore retriever

Open ssbushi opened this issue 1 year ago • 4 comments

Is your feature request related to a problem? Please describe. Firestore retriever does not support using a similarity threshold (instead of k) when retrieving documents.

Describe the solution you'd like An optional threshold config that lets developers specify a threshold for the retrieved documents.

Describe alternatives you've considered Existing workaround:

  • Manually implement a cutoff mechanism as a post-retrieval step.

Consider extending this support to other retrievers.

Additional context See Discord

ssbushi avatar Jul 18 '24 19:07 ssbushi

I don't think Firestore generally supports threshold-based querying (see docs) which makes it difficult to add to the Firestore retriever.

mbleigh avatar Jul 24 '24 17:07 mbleigh

/cc @MarkDuckworth for viz

peterfriese avatar Jul 24 '24 17:07 peterfriese

@mbleigh Yes, this is not natively supported in Firestore. Which means that this should be handled in the retriever definition after Firestore returns the appropriate documents.

ssbushi avatar Jul 25 '24 15:07 ssbushi

This is a feature we are considering implementing natively.

MarkDuckworth avatar Jul 25 '24 15:07 MarkDuckworth

This is now natively supported in Firestore https://firebase.google.com/docs/firestore/vector-search#distance-threshold

ssbushi avatar Jan 06 '25 15:01 ssbushi

Fixed in https://github.com/firebase/genkit/pull/2246

ssbushi avatar Apr 28 '25 20:04 ssbushi