Find answers from the community

Updated last month

Modifying the Reranking System in LLMRerank

At a glance
Hi guys, quick question about modifying the reranking system. I implemented a couple changes into _postprocess_nodes inside of LLMRerank where it gives priority to nodes with a more recent date and a specific subtype. However, since llm_rerank.py is directly part of a Python package, I'm having trouble with utilizing the modified file instead of the original version of LLM rerank. Is there either a way to make these same node reranking adjustments in my workflow file or override the original package with my new code? Here is my updated section of the code:
Plain Text
for node, relevance in zip(choice_nodes, relevances):
                # date score
                date_str = node.metadata.get('date')
                date_score = datetime.strptime(date_str, "%Y-%m-%d").timestamp()
                # Subtype score
                subtype = node.metadata.get('subtype', '')
                subtype_score = 1.0 if subtype == "pro report" else 0.0
                node_score = relevance + date_score + subtype_score
                initial_results.append(NodeWithScore(node=node, score=node_score))
M
1 comment
Oh sick. I didn’t realize you can make your own post processor. Will take a look into this. Thank you!!!
Add a reply
Sign up and join the conversation on Discord