-
Notifications
You must be signed in to change notification settings - Fork 771
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
Stateless Metrics #806
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -30,6 +31,13 @@ class AnswerRelvancyVerdict(BaseModel): | |||
|
|||
|
|||
class AnswerRelevancyMetric(BaseMetric): | |||
|
|||
_statements: ContextVar[List[str]] = ContextVar('statements', default=[]) |
There was a problem hiding this comment.
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.
deepeval/metrics/bias/bias.py
Outdated
@@ -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) |
There was a problem hiding this comment.
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)
- 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
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.