Retriever Example for Zep Cloud
Recall, understand, and extract data from chat histories. Power personalized AI experiences.
Zep is a long-term memory service for AI Assistant apps. With Zep, you can provide AI assistants with the ability to recall past conversations, no matter how distant, while also reducing hallucinations, latency, and cost.
See Zep Cloud Installation Guide and more Zep Cloud LangChain Examples
Retriever Example
This notebook demonstrates how to search historical chat message histories using the Zep Long-term Memory Store. We’ll demonstrate:- Adding conversation history to the Zep memory store.
- Vector search over the conversation history:
- With a similarity search over chat messages
- Using maximal marginal relevance re-ranking of a chat message search
- Filtering a search using metadata filters
- A similarity search over summaries of the chat messages
- Using maximal marginal relevance re-ranking of a summary search
Initialize the Zep Chat Message History Class and add a chat message history to the memory store
NOTE: Unlike other Retrievers, the content returned by the Zep Retriever is session/user specific. Asession_id is required when instantiating the Retriever.
Use the Zep Retriever to vector search over the Zep memory
Zep provides native vector search over historical conversation memory. Embedding happens automatically. NOTE: Embedding of messages occurs asynchronously, so the first query may not return results. Subsequent queries will return results as the embeddings are generated.Reranking using MMR (Maximal Marginal Relevance)
Zep has native, SIMD-accelerated support for reranking results using MMR. This is useful for removing redundancy in results.Using metadata filters to refine search results
Zep supports filtering results by metadata. This is useful for filtering results by entity type, or other metadata. More information here: help.getzep.com/document-collections#searching-a-collection-with-hybrid-vector-searchSearching over Summaries with MMR Reranking
Zep automatically generates summaries of chat messages. These summaries can be searched over using the Zep Retriever. Since a summary is a distillation of a conversation, they’re more likely to match your search query and offer rich, succinct context to the LLM. Successive summaries may include similar content, with Zep’s similarity search returning the highest matching results but with little diversity. MMR re-ranks the results to ensure that the summaries you populate into your prompt are both relevant and each offers additional information to the LLM.Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.