Description
search_events_by_embedding fetches every event with an embedding from Neo4j, transfers all embedding vectors to Python, and then computes cosine similarity using NumPy. This is O(N) in the number of events per user, which wastes memory and bandwidth.
Code Reference
src/graph/neo4j_client.py - search_events_by_embedding()
Proposed Fix
Push the cosine computation into the Neo4j Cypher query using gds.similarity.cosine() (or native vector index search) and use ORDER BY score DESC LIMIT $top_k. This reduces data transfer to only the top_k rows.
Description
search_events_by_embeddingfetches every event with an embedding from Neo4j, transfers all embedding vectors to Python, and then computes cosine similarity using NumPy. This is O(N) in the number of events per user, which wastes memory and bandwidth.Code Reference
src/graph/neo4j_client.py-search_events_by_embedding()Proposed Fix
Push the cosine computation into the Neo4j Cypher query using
gds.similarity.cosine()(or native vector index search) and use ORDER BY score DESC LIMIT $top_k. This reduces data transfer to only thetop_krows.