Announcing: Zep Fact Ratings

Not all user Facts extracted by Zep are relevant to your application. Fact Ratings help Zep understand the relevance of a Fact to your use case.

Rating Facts for Poignancy
Rating Facts for Poignancy

Zep's long-term memory is powered by user Facts. Zep extracts these facts from the dialogue between the user and Assistant application. Not all facts are created equal.

For a mental health application, what I ate for breakfast today might be far less important than me mentioning my sick relative. Fact Ratings are a way to help Zep understand the relevance of a Fact to your use case.

To implement Ratings, pass in your rating instructions and rubric when creating a new chat session.

Fact Rating for Poignancy Example

Implementing Fact Ratings

In this example, we've instructed Zep to rate Facts by poignancy. We've also provided several examples to help Zep calibrate low, medium, and high poignancy ratings.

fact_rating_instruction = """Rate the facts by poignancy. Highly poignant 
facts have a significant emotional impact or relevance to the user. 
Low poignant facts are minimally relevant or of little emotional 
significance."""
fact_rating_examples = FactRatingExamples(
    high="The user received news of a family member's serious illness.",
    medium="The user completed a challenging marathon.",
    low="The user bought a new brand of toothpaste.",
)
await zep.memory.add_session(
    user_id=user_id,
    session_id=session_id,
    fact_rating_instruction=FactRatingInstruction(
        instruction=fact_rating_instruction,
        examples=fact_rating_examples,
    ),
)

We can also build use case-specific rating frameworks. Here, we're rating facts by relevance to a shoe sales process.

await zep.memory.add_session(
    user_id=user_id,
    session_id=session_id,
    fact_rating_instruction=FactRatingInstruction(
        instruction="""Rate the facts by how relevant they 
                       are to purchasing shoes.""",
        examples=FactRatingExamples(
            high="The user has agreed to purchase a Reebok running shoe.",
            medium="The user prefers running to cycling.",
            low="The user purchased a dress.",
        ),
    ),
)

And when retrieving memory, specify a minimum rating. Zep will return relevant Facts rated higher than the minimum.

result = await client.memory.get(session_id, min_rating=0.7)

How Fact Retrieval Works

When using Zep's 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 your user's Chat History. Facts are ranked by the current state of the conversation, filtered by Rating if requested, and returned.

Next Steps

Review the Zep Facts Guide to learn more.