From 857a8f61cf0ec9064f5ce3abb5a7cac2b1e41a41 Mon Sep 17 00:00:00 2001 From: Preston Rasmussen <109292228+prasmussen15@users.noreply.github.com> Date: Wed, 6 Nov 2024 14:59:17 -0500 Subject: [PATCH] add search recipes (#210) --- graphiti_core/search/search_config_recipes.py | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/graphiti_core/search/search_config_recipes.py b/graphiti_core/search/search_config_recipes.py index 712793db..06b6f8cb 100644 --- a/graphiti_core/search/search_config_recipes.py +++ b/graphiti_core/search/search_config_recipes.py @@ -118,6 +118,19 @@ EDGE_HYBRID_SEARCH_EPISODE_MENTIONS = SearchConfig( ) ) +# performs a hybrid search over edges with cross encoder reranking +EDGE_HYBRID_SEARCH_CROSS_ENCODER = SearchConfig( + edge_config=EdgeSearchConfig( + search_methods=[ + EdgeSearchMethod.bm25, + EdgeSearchMethod.cosine_similarity, + EdgeSearchMethod.bfs, + ], + reranker=EdgeReranker.cross_encoder, + ), + limit=10, +) + # performs a hybrid search over nodes with rrf reranking NODE_HYBRID_SEARCH_RRF = SearchConfig( node_config=NodeSearchConfig( @@ -150,6 +163,19 @@ NODE_HYBRID_SEARCH_EPISODE_MENTIONS = SearchConfig( ) ) +# performs a hybrid search over nodes with episode mentions reranking +NODE_HYBRID_SEARCH_CROSS_ENCODER = SearchConfig( + node_config=NodeSearchConfig( + search_methods=[ + NodeSearchMethod.bm25, + NodeSearchMethod.cosine_similarity, + NodeSearchMethod.bfs, + ], + reranker=NodeReranker.cross_encoder, + ), + limit=10, +) + # performs a hybrid search over communities with rrf reranking COMMUNITY_HYBRID_SEARCH_RRF = SearchConfig( community_config=CommunitySearchConfig( @@ -165,3 +191,12 @@ COMMUNITY_HYBRID_SEARCH_MMR = SearchConfig( reranker=CommunityReranker.mmr, ) ) + +# performs a hybrid search over communities with mmr reranking +COMMUNITY_HYBRID_SEARCH_CROSS_ENCODER = SearchConfig( + community_config=CommunitySearchConfig( + search_methods=[CommunitySearchMethod.bm25, CommunitySearchMethod.cosine_similarity], + reranker=CommunityReranker.cross_encoder, + ), + limit=3, +)