Applying Multiple 'OR' Filters with FAISS Retriever #20202
Replies: 2 comments
-
Hey @phoebeeeeeeeeee, great to see you diving into the depths of LangChain again! How's everything going on your end? To implement multiple 'any-match' filters for document retrieval using the FAISS retriever in LangChain, you can use the Here's an example of how you can use the results_with_scores = db.similarity_search_with_score("foo", filter={'$or': [{'page': {'$eq': 1}}, {'page': {'$eq': 2}}]}) In this example, the If you want to apply filters based on a list of values, you can use the results_with_scores = db.similarity_search_with_score("foo", filter={'page': {'$in': [1, 2, 3]}}) In this example, the Please note that the I hope this helps! If you have any other questions, feel free to ask. Sources
Sources
|
Beta Was this translation helpful? Give feedback.
-
filter in FAISS is post-filter |
Beta Was this translation helpful? Give feedback.
-
Checked other resources
Commit to Help
Example Code
Description
Hello everyone,
I'm looking for some guidance on using the FAISS retriever to handle multiple filters for document retrieval.
The official documentation indicates that we can apply a single filter parameter to narrow down our search, as demonstrated by:
results_with_scores = db.similarity_search_with_score("foo", filter=dict(page=1))
However, I'm unsure how to proceed when I need to include multiple filter values and a match with any one of those values would suffice.
Additionally, I've experimented with other vector stores and encountered issues where certain methods found on Internet were not effective. It would be great if you could share any examples that illustrate how to implement this type of 'any-match' filtering.
Thank you so much for your help!
System Info
Python 3.9.7
langchain latest version
Beta Was this translation helpful? Give feedback.
All reactions