mmr update (#369)

* mmr update

* bump version

* format
This commit is contained in:
Preston Rasmussen 2025-04-17 10:14:50 -04:00 committed by GitHub
parent 0661db0759
commit e73aaf8171
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 4 additions and 10 deletions

View file

@ -210,7 +210,6 @@ async def edge_search(
query_vector,
search_result_uuids_and_vectors,
config.mmr_lambda,
min_score=reranker_min_score,
)
elif config.reranker == EdgeReranker.cross_encoder:
search_result_uuids = [[edge.uuid for edge in result] for result in search_results]
@ -310,7 +309,6 @@ async def node_search(
query_vector,
search_result_uuids_and_vectors,
config.mmr_lambda,
min_score=reranker_min_score,
)
elif config.reranker == NodeReranker.cross_encoder:
# use rrf as a preliminary reranker
@ -437,7 +435,6 @@ async def community_search(
query_vector,
search_result_uuids_and_vectors,
config.mmr_lambda,
min_score=reranker_min_score,
)
elif config.reranker == CommunityReranker.cross_encoder:
summary_to_uuid_map = {

View file

@ -230,8 +230,8 @@ async def edge_similarity_search(
query: LiteralString = (
"""
MATCH (n:Entity)-[r:RELATES_TO]->(m:Entity)
"""
MATCH (n:Entity)-[r:RELATES_TO]->(m:Entity)
"""
+ group_filter_query
+ filter_query
+ """\nWITH DISTINCT r, vector.similarity.cosine(r.fact_embedding, $search_vector) AS score
@ -852,7 +852,6 @@ def maximal_marginal_relevance(
query_vector: list[float],
candidates: list[tuple[str, list[float]]],
mmr_lambda: float = DEFAULT_MMR_LAMBDA,
min_score: float = 0,
):
candidates_with_mmr: list[tuple[str, float]] = []
for candidate in candidates:
@ -862,6 +861,4 @@ def maximal_marginal_relevance(
candidates_with_mmr.sort(reverse=True, key=lambda c: c[1])
return list(
set([candidate[0] for candidate in candidates_with_mmr if candidate[1] >= min_score])
)
return list(set([candidate[0] for candidate in candidates_with_mmr]))

View file

@ -1,7 +1,7 @@
[project]
name = "graphiti-core"
description = "A temporal graph building library"
version = "0.10.2"
version = "0.10.3"
authors = [
{ "name" = "Paul Paliychuk", "email" = "paul@getzep.com" },
{ "name" = "Preston Rasmussen", "email" = "preston@getzep.com" },