How to make k in top-k dynamic

We have documents which we’re ingesting into pinecone and querying with questions.

Some times we need top-3 answers, some times we need top-10 answers. This is because there is information that is scattered between multiple parts of the document.

The document could be “Sarah’s food log”. A certain question could be “what is the fruit that Sarah ate” - we need to return all results of the fruit Sarah ate, not just the top 3.

Do you guys have any way to have a dynamic sizing of k in the top-k queries?

Would appreciate any help in this!
Thanks a lot.

The script querying Pinecone should define the top_k parameter.

Pinecone is returning vectors with the score associated to it (0.80 is probably more irrelevant than one with 0.96).

You could:

→ do the first query with top_k with 3.
→ if all the results returned have a score satisfing (let’s say over 0.95), you could extend the query with top_k 6 and eliminates anything under your predefined minimal allowed score (ex: 0.94)