# Announcing: Zep Fact Ratings

By Daniel Chalef · Jul 24, 2024 · https://www.getzep.com/blog/announcing-zep-fact-ratings/ · Tags: Product updates

Zep's Memory for LLM Apps is powered by user Facts. Devs can significantly improve Fact relevance with Ratings.

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.

[Implementing Fact Ratings with Zep](https://player.vimeo.com/video/989192145?app_id=122963)

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](https://www.getzep.com/blog/announcing-zep-fact-ratings/screenshot-2024-07-24-at-7-23-51-am.png)

## 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.

```python
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.

```python
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.

```python
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](https://help.getzep.com/chat-history-memory/facts#rating-facts-for-relevancy) to learn more.
