Under batch circumstances where async methods are used (e.g. RetrieverQueryEngine.aquery()), it would be nice if _apply_node_postprocessors() or equivalent could call upon an async equivalent to postprocess_nodes to maintain the async calls throughout. This can be an issue when using a node postprocessor like LLMRerank or RankGPTRerank.
Additionally, RankGPTRerank and LLMRerank seem a bit redundant though someone added a apostprocess_nodes in https://github.com/run-llama/llama_index/pull/12620. Overall, it seems like there's an opportunity to define a cleaner interface and consolidate some of this code.
Reason
There are existing workarounds (implementation through low level API) though this issue gets at some opportunity to improve both in terms of performance and code maintainability.
Value of Feature
There is an improvement both in terms of performance and code maintainability.
Current Workaround
As a workaround, I created a new class extending RetrieverQueryEngine:
This allows me to use apostprocess_nodes which RankGPTRerank currently implements. Presumably some other postprocessors may want to support this as well.
Proposed Solution
We can add an apostprocess_nodes in BaseNodePostprocessor intended to be overwritten but which wraps the synchronous equivalent as a fallback. Query engines would also need to be updated to account for this in a way similar to the workaround above.
Feature Description
Under batch circumstances where async methods are used (e.g.
RetrieverQueryEngine.aquery()
), it would be nice if_apply_node_postprocessors()
or equivalent could call upon an async equivalent topostprocess_nodes
to maintain the async calls throughout. This can be an issue when using a node postprocessor likeLLMRerank
orRankGPTRerank
.Additionally,
RankGPTRerank
andLLMRerank
seem a bit redundant though someone added aapostprocess_nodes
in https://github.com/run-llama/llama_index/pull/12620. Overall, it seems like there's an opportunity to define a cleaner interface and consolidate some of this code.Reason
There are existing workarounds (implementation through low level API) though this issue gets at some opportunity to improve both in terms of performance and code maintainability.
Value of Feature
There is an improvement both in terms of performance and code maintainability.
Current Workaround
As a workaround, I created a new class extending
RetrieverQueryEngine
:This allows me to use
apostprocess_nodes
whichRankGPTRerank
currently implements. Presumably some other postprocessors may want to support this as well.Proposed Solution
We can add an
apostprocess_nodes
inBaseNodePostprocessor
intended to be overwritten but which wraps the synchronous equivalent as a fallback. Query engines would also need to be updated to account for this in a way similar to the workaround above.