Skip to content

limit amount(20) documents return after using filter in retriever #26806

Answered by dosubot bot
BarryC7 asked this question in Q&A
Discussion options

You must be logged in to vote

Hey there, @BarryC7! I'm here to help you with any bugs, questions, or contributions you have in mind. Let's get to the bottom of this together!

I found a similar issue that might be relevant to your problem. The default value of the fetch_k parameter in the as_retriever method is 20, which limits the maximum number of documents fetched regardless of the k value specified. To retrieve more documents, you should adjust the fetch_k parameter accordingly [1].

Here's how you can modify your code to set the fetch_k parameter:

sources = {'b.txt', 'c.txt'}
all_sources = {'a.txt', 'b.txt', 'c.txt'}

retriever = vectordb.as_retriever(search_kwargs={'k': 25, 'fetch_k': 50, 'filter': {'source': list(

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@BarryC7
Comment options

@dosubot
Comment options

Answer selected by BarryC7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant