Facts
Facts are extracted from the Chat History as a conversation unfolds.
Facts are observations about a user and their interaction with your Assistant. They are derived from the Chat History as new Messages are added to a Session.
Zep uses low-latency agents to continuously update a Fact Table as the conversation progresses. Facts are deconflicted and deduplicated, and the relationship between conflicting information is preserved.
A stylized example below:
How Fact Retrieval Works
Relevant Facts can be retrieved via a Memory call or using the Search API.
When using the Memory API
to retrieve relevant Facts, low-latency agents use a combination of semantic search and LLM tools to review the most recent messages in the Chat History. Facts are ranked by the current state of the conversation and returned.
Rating Facts for Relevancy
Available to Subscription customers only.
Not all Facts are relevant to your application and users. For example, a realtionship coach app may need to recall important facts about a user’s family, but what the user ate for breakfast Friday last week is unimportant.
Fact Ratings are a way to help Zep understand the relevance of a Fact to your particular use case. After implementing Fact Ratings, you can specify a minimum rating when retrieving Facts from Zep, ensuring that prompt only contains high-signal context.
Implementing Fact Ratings
A Fact Rating framework consist of an Instruction and three example Facts, one for each of a “High”, “Medium”, and “Low” rating. This is passed into a Session
on creation.
Rating Facts for Poignancy
Use Case-Specific Fact Rating
Facts are rated on a scale between 0 and 1. You can review ratings for a Session by visiting the web app or retrieving all Facts for a Session.
Limiting Memory Recall to High-Rating Facts
Zep automatically returns relevant Facts when retrieving Memory. You can limit the returned Facts by Rating when setting the min_rating
parameter in the get
method.
It’s also possible to filter search results by Fact Rating by setting the min_fact_rating
parameter when searching Sessions.
Creating Facts
You may have information about your user that would be helpful context when prompting an LLM. You can generate textual facts from this data and persist these to a Session. The data will be returned if relevant to the current conversation, alongside other facts gleaned from the Chat History.
Unlike RAG, where documents in a vector index are static, Facts you add to a Session will be curated as the conversation with the user progresses. They may be updated, merged into new Facts, or deleted as new information is learned from the user.
Python
TypeScript
Deleting Facts
You or your users may want to remove a fact from Zep’s memory. You can do this by deleting a fact by Fact UUID
.
Customizing Fact Generation
Available to Enterprise Plan customers only.
You can customize the contents and format of facts by providing Custom Instructions when persisting a Memory to a Session.
Retrieving Facts
Facts are added to Memory responses when you retrieve a Session’s Memory. They’re also accessible the Search API and lower-level Session API.