Dynamic Top-k Retrieval Chunks #5094
Replies: 2 comments
This comment was marked as off-topic.
This comment was marked as off-topic.
-
|
@Malak-Alaabiad From what I can tell, Flowise doesn't currently provide a dedicated "Dynamic Top-k" node that automatically changes the number of retrieved chunks per query. I couldn't find any documentation describing such a feature. :contentReference[oaicite:0]{index=0} Instead, I'd recommend one (or a combination) of these approaches: 1. Use a Similarity Score Threshold Retriever (Recommended)Instead of always returning a fixed number of chunks (e.g. Top-10), use the Similarity Score Threshold Retriever. This returns only documents above a relevance threshold: For simple questions you may end up with only 2–3 chunks, while more complex questions can still retrieve more. This is often the closest behavior to "dynamic top-k". Flowise includes this retriever out of the box. :contentReference[oaicite:1]{index=1} 2. Add a RerankerIf you currently retrieve a larger candidate set (for example Top-20), add a reranker such as:
A common pattern is: This usually gives better relevance while reducing the amount of context passed to the LLM. Flowise provides built-in reranker retrievers for this purpose. :contentReference[oaicite:2]{index=2} 3. Reduce chunk size and tune Top-KToken usage is also heavily influenced by your indexing strategy. The Flowise documentation recommends experimenting with:
to balance retrieval quality against token cost. Smaller, more focused chunks often allow you to lower Top-K without hurting answer quality. :contentReference[oaicite:3]{index=3} 4. Keep your Custom Retriever leanSince you're already using a Custom Retriever, make sure you're only sending the information the LLM actually needs. For example, instead of: return only something like: or include only the metadata that contributes to answering the question (e.g. source for citations). The Custom Retriever is specifically intended to control the context formatting sent to the LLM. :contentReference[oaicite:4]{index=4} Suggested pipelineThis typically achieves lower token usage than a fixed Top-K approach while maintaining answer quality. One question: is your goal to optimize for cost, latency, or both? That will help determine whether a threshold retriever, reranker, or another retrieval strategy is the best fit. If this solves your problem, feel free to mark it as the accepted answer so others can find it easily. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Suggest me a specific node or flow to reduce the number of tokens going into the LLM model, considering that my data is stored in a Qdrant collection, and I'm using a custom retriever node to pull only the necessary metadata. This custom retriever node is connected to the Conversational Retriever QA Chain, which then passes the data directly to the LLM.
Now, I want to implement a Dynamic Top-k Retrieval Chunks or a similar flow to achieve the same goal—reducing the tokens sent to the model, which would help minimize the associated costs.
Beta Was this translation helpful? Give feedback.
All reactions