The community member is asking if there is a way to select the number of retrieved nodes in an index based on their score, so that in one question, all 5 highly relevant nodes are included, while in another question, only the most relevant node is included. The community member provides some example code that sets the top-n parameter to 2 for a Cohere reranking model.
In the comments, another community member suggests using a score threshold post-processor or writing a custom post-processor to set the top-k higher, as a potential solution to the original question.
is there a way to select the number of retrieved nodes in an index different depending on the score? so that in a question if 5 nodes are very relevant include all them but in other question only one is relevant.
# Crear motor de chat con la colección seleccionada chat_engine = index.as_chat_engine( service_context=service_context, similarity_top_k=10, node_postprocessors=[cohere_rerank], chat_mode="context", memory=memory, )