Skip to content

Stateless Metrics #806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jun 13, 2024
Merged

Conversation

kritinv
Copy link
Collaborator

@kritinv kritinv commented Jun 4, 2024

Stateless Support for Metrics

Stateless support was implemented for all metrics except RAGAS and knowledge retention. This involves adding context variables and changing the measure and a_measure accordingly. The measure method is more complex, because there is also support for async_mode, which involved implementing an additional function to overcome the loss of information due to using context variables in coroutines. In addition, the indicator was adapted to support a_measure.

Copy link

vercel bot commented Jun 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
evals-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 13, 2024 6:40am

@kritinv kritinv changed the title context var addition Stateless Metrics Jun 9, 2024
@@ -30,6 +31,13 @@ class AnswerRelvancyVerdict(BaseModel):


class AnswerRelevancyMetric(BaseMetric):

_statements: ContextVar[List[str]] = ContextVar('statements', default=[])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible for context variables to default to None? Since right now we default to none: https://github.com/confident-ai/deepeval/blob/main/deepeval/metrics/base_metric.py#L7

Also add error as well.

@@ -203,11 +268,56 @@ def is_successful(self) -> bool:
self.success = False
else:
try:
self.success = self.score <= self.threshold
self._success.set(self.score >= self.threshold)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Careful copy n pasting (should be self.score <= self.threshold instead)

Created getters for all context variables and deleted test examples from bias.py
- Fixed ContextVar bug and moved it to init method in each metric class so that the variables are not shared among metric object instantiations.
- Removed shared context variables and defined them in BaseMetric class
@penguine-ip penguine-ip merged commit 700a1b8 into confident-ai:main Jun 13, 2024
1 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants