Find answers from the community

Updated 2 years ago

the LLMRerank node post processor isn't working for me, should i be adding that to the res

@kapa.ai the LLMRerank node post processor isn't working for me, should i be adding that to the response synthesizer, the retriever or the query engine?
k
2 comments
Please stand by @shere as I search the knowledge base. We are experiencing especially high traffic right now and might take longer than usual. :wave:
----------------------
You should add the LLMRerank node postprocessor to the query engine. Here's an example of how to do that:

Plain Text
query_engine = index.as_query_engine(
    similarity_top_k=10,
    node_postprocessors=[reranker],
    response_mode="tree_summarize"
)
response = query_engine.query(
    "What did the author do during his time at Y Combinator?", 
)


In this example, reranker is an instance of the LLMRerank class. You can create it like this:

Plain Text
from llama_index.indices.postprocessor import LLMRerank
from llama_index import ServiceContext, LLMPredictor
from langchain.chat_models import ChatOpenAI

# LLM Predictor (gpt-3.5-turbo) + service context
llm_predictor = LLMPredictor(llm=ChatOpenAI(temperature=0, model_name="gpt-3.5-turbo"))
service_context = ServiceContext.from_defaults(llm_predictor=llm_predictor, chunk_size_limit=512)

# Create the reranker
reranker = LLMRerank(choice_batch_size=5, top_n=3, service_context=service_context)


Source: LLMReranker-Gatsby (https://gpt-index.readthedocs.io/en/latest/examples/node_postprocessor/LLMReranker-Gatsby.html)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Add a reply
Sign up and join the conversation on Discord