diff --git a/rag/graphrag/search.py b/rag/graphrag/search.py index 0cbb884f25..c342ae03cf 100644 --- a/rag/graphrag/search.py +++ b/rag/graphrag/search.py @@ -192,7 +192,9 @@ class KGSearch(Dealer): nhop_pathes[(f, t)]["sim"] += ent["sim"] / (2 + i) else: nhop_pathes[(f, t)]["sim"] = ent["sim"] / (2 + i) - nhop_pathes[(f, t)]["pagerank"] = wts[i] + nhop_pathes[(f, t)]["pagerank"] = max( + nhop_pathes[(f, t)].get("pagerank", 0), wts[i] + ) logging.info("Retrieved entities: {}".format(list(ents_from_query.keys()))) logging.info("Retrieved relations: {}".format(list(rels_from_txt.keys())))