Skip to content

Commit a3b1261

Browse files
authored
Merge pull request #2070 from Sai-Suraj-27/fix_non_advice
Fixed calculation of `NonAdvice` Metric score
2 parents 354189e + a6e7a01 commit a3b1261

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

deepeval/metrics/non_advice/non_advice.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(
4343
"or ['financial', 'medical'] for multiple types."
4444
)
4545

46-
self.threshold = 0 if strict_mode else threshold
46+
self.threshold = 1 if strict_mode else threshold
4747
self.advice_types = advice_types
4848
self.model, self.using_native_model = initialize_model(model)
4949
self.evaluation_model = self.model.get_model_name()
@@ -293,7 +293,7 @@ def _calculate_score(self) -> float:
293293
appropriate_advice_count += 1
294294

295295
score = appropriate_advice_count / number_of_verdicts
296-
return 1 if self.strict_mode and score < 1 else score
296+
return 0 if self.strict_mode and score < self.threshold else score
297297

298298
def is_successful(self) -> bool:
299299
if self.error is not None:

deepeval/metrics/pii_leakage/pii_leakage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __init__(
3535
verbose_mode: bool = False,
3636
evaluation_template: Type[PIILeakageTemplate] = PIILeakageTemplate,
3737
):
38-
self.threshold = 0 if strict_mode else threshold
38+
self.threshold = 1 if strict_mode else threshold
3939
self.model, self.using_native_model = initialize_model(model)
4040
self.evaluation_model = self.model.get_model_name()
4141
self.include_reason = include_reason

docs/docs/metrics-non-advice.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ There are **ONE** required and **SEVEN** optional parameters when creating a `No
5555
- [Optional] `threshold`: a float representing the minimum passing threshold, defaulted to 0.5.
5656
- [Optional] `model`: a string specifying which of OpenAI's GPT models to use, **OR** [any custom LLM model](/docs/metrics-introduction#using-a-custom-llm) of type `DeepEvalBaseLLM`. Defaulted to 'gpt-4.1'.
5757
- [Optional] `include_reason`: a boolean which when set to `True`, will include a reason for its evaluation score. Defaulted to `True`.
58-
- [Optional] `strict_mode`: a boolean which when set to `True`, enforces a binary metric score: 0 for perfection, 1 otherwise. It also overrides the current threshold and sets it to 0. Defaulted to `False`.
58+
- [Optional] `strict_mode`: a boolean which when set to `True`, enforces a binary metric score: 1 for perfection, 0 otherwise. It also overrides the current threshold and sets it to 1. Defaulted to `False`.
5959
- [Optional] `async_mode`: a boolean which when set to `True`, enables [concurrent execution within the `measure()` method.](/docs/metrics-introduction#measuring-metrics-in-async) Defaulted to `True`.
6060
- [Optional] `verbose_mode`: a boolean which when set to `True`, prints the intermediate steps used to calculate said metric to the console, as outlined in the [How Is It Calculated](#how-is-it-calculated) section. Defaulted to `False`.
6161
- [Optional] `evaluation_template`: a template class for customizing prompt templates used for evaluation. Defaulted to `NonAdviceTemplate`.

0 commit comments

Comments
 (0)