[GH-ISSUE #1387] [FEAT]: Add Optional Small-to-Big Retrieval #886

Closed
opened 2026-02-22 18:22:01 -05:00 by yindo · 1 comment
Owner

Originally created by @cope on GitHub (May 13, 2024).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/1387

What would you like to see?

Apparently, smaller chunk sizes improve retrieval quality, but larger chunk sizes improve generation quality: Advanced RAG 01: Small-to-Big Retrieval.

If the current embediing process stores the relative chunk ids per document, then when chunk i is retrieved, we can prepend chunks [i-2, i-1] and append chunks [i+1, i+2] and pass on that big combined text to the generation step. This would have both benefits: smaller chunks for retrieval and larger chunks for generation. Naturally, we need to make sure that any i+/-n chunk exists before adding null.

My idea is to simplify the implementation by just adding optional prepend/append integers that would default to 0, but could be changed by the user in the settings.

The alternative is to do full Parent Document Retriever, but this is a much bigger task IMHO.

Originally created by @cope on GitHub (May 13, 2024). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/1387 ### What would you like to see? Apparently, smaller chunk sizes improve retrieval quality, but larger chunk sizes improve generation quality: [Advanced RAG 01: Small-to-Big Retrieval](https://towardsdatascience.com/advanced-rag-01-small-to-big-retrieval-172181b396d4). If the current embediing process stores the relative chunk ids per document, then when chunk `i` is retrieved, we can _prepend_ chunks `[i-2, i-1]` and _append_ chunks `[i+1, i+2]` and pass on that big combined text to the generation step. This would have both benefits: smaller chunks for retrieval and larger chunks for generation. _Naturally, we need to make sure that any `i+/-n` chunk exists before adding `null`._ My idea is to simplify the implementation by just adding optional prepend/append integers that would default to 0, but could be changed by the user in the settings. The alternative is to do full [Parent Document Retriever](https://python.langchain.com/v0.1/docs/modules/data_connection/retrievers/parent_document_retriever/), but this is a much bigger task IMHO.
yindo added the enhancementfeature request labels 2026-02-22 18:22:01 -05:00
yindo closed this issue 2026-02-22 18:22:01 -05:00
Author
Owner

@RahSwe commented on GitHub (May 13, 2024):

Parent Document Retriever would be a nice option for documents (like the pinning option). Due to mixes of documents in which some are too big to be retrieved as parent.

@RahSwe commented on GitHub (May 13, 2024): Parent Document Retriever would be a nice option for documents (like the pinning option). Due to mixes of documents in which some are too big to be retrieved as parent.
yindo changed title from [FEAT]: Add Optional Small-to-Big Retrieval to [GH-ISSUE #1387] [FEAT]: Add Optional Small-to-Big Retrieval 2026-06-05 14:37:45 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#886