Searching the Graph
Zep’s Graph search combines semantic similarity and full-text BM25 search. It supports multiple rerankers: Reciprocal Rank Fusion, Maximal Marginal Relevance, Node Distance, and Episode Mentions.
Simple Hybrid Edge Search
Graph edges represent relationships between nodes and contain retrievable semantic facts. The basic search query is a text-based hybrid search against graph edges. It requires only a text string as input. Zep performs both semantic similarity search using embeddings and BM25 full-text search, and results are merged and reranked using Reciprocal Rank Fusion (RRF).
Reciprocal Rank Fusion (RRF) combines and ranks results from multiple searches based on their individual rankings.
The example below demonstrates a search against a chat session using only search text.
Python
TypeScript
Read more about chat message history search.
Search Scopes
Graph search supports both edge and node scopes. Nodes represent entities discussed in chat history or business data added via the Graph API. Nodes contain summaries of relevant facts from edges adjacent to the node, providing a useful overview of a node’s context.
Group graphs can be searched by passing a group_id
instead of a user_id
.
The example below demonstrates a node search. All re-ranking methods are applicable to node searches as well.
Python
TypeScript
Maximal Marginal Relevance Re-Ranking
Zep supports Maximal Marginal Relevance (MMR) re-ranking for graph search results.
MMR balances relevance and diversity in search results. Standard similarity searches often return highly similar top results, potentially limiting the information added to a prompt. MMR addresses this by re-ranking results to promote diversity, downranking similar results in favor of relevant but distinct alternatives.
Example of MMR search:
Python
TypeScript
Node Distance
Node Distance re-ranks search results based on the number of hops between the search result and a center node. This can be useful for finding facts related to a specific node, such as a user or a topic.
The UUID of a node must be passed in to be used as a center node.
An example using Node Distance search.
Python
TypeScript
Episode Mentions
Episode Mentions re-ranks search results based on the number of times the node or edge has been mentioned in the chat history.
An example using Episode Mentions search.