Skip to content

Commit

Permalink
rename PMs to PM (#3711)
Browse files Browse the repository at this point in the history
Rename references to protected materials to be singular, most notably in
the name of the protected material evaluator.
  • Loading branch information
MilesHolland authored Sep 4, 2024
1 parent c97470b commit d5cc19c
Show file tree
Hide file tree
Showing 7 changed files with 605 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/promptflow-evals/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## v0.3.3 (Upcoming)
### Features Added
- Add a new evaluator (ProtectedMaterialsEvaluator) and associated adversarial content simulator enum type (AdversarialScenario.ADVERSARIAL_CONTENT_PROTECTED_MATERIAL) for protected materials, which determines if given inputs contain materials protected by IP laws.
- Add a new evaluator (ProtectedMaterialEvaluator) and associated adversarial content simulator enum type (AdversarialScenario.ADVERSARIAL_CONTENT_PROTECTED_MATERIAL) for protected material, which determines if given inputs contain material protected by IP laws.

### Bugs Fixed
- Fixed evaluators to accept (non-Azure) Open AI Configs.
Expand Down
4 changes: 2 additions & 2 deletions src/promptflow-evals/promptflow/evals/evaluators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from ._f1_score import F1ScoreEvaluator
from ._fluency import FluencyEvaluator
from ._groundedness import GroundednessEvaluator
from ._protected_materials import ProtectedMaterialsEvaluator
from ._protected_material import ProtectedMaterialEvaluator
from ._qa import QAEvaluator
from ._relevance import RelevanceEvaluator
from ._similarity import SimilarityEvaluator
Expand All @@ -35,5 +35,5 @@
"HateUnfairnessEvaluator",
"ContentSafetyEvaluator",
"ContentSafetyChatEvaluator",
"ProtectedMaterialsEvaluator",
"ProtectedMaterialEvaluator",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from ._protected_material import ProtectedMaterialEvaluator

__all__ = [
"ProtectedMaterialEvaluator",
]
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from promptflow.evals._common.rai_service import evaluate_with_rai_service


class _AsyncProtectedMaterialsEvaluator:
class _AsyncProtectedMaterialEvaluator:
def __init__(self, project_scope: dict, credential=None):
self._project_scope = project_scope
self._credential = credential
Expand All @@ -19,7 +19,7 @@ async def __call__(self, *, question: str, answer: str, **kwargs):
:paramtype question: str
:keyword answer: The answer to be evaluated.
:paramtype answer: str
:return: The evaluation result computation based on the Content Safety metric (self.metric).
:return: The evaluation score computation based on the Content Safety metric (self.metric).
:rtype: Any
"""
# Validate inputs
Expand All @@ -40,9 +40,9 @@ async def __call__(self, *, question: str, answer: str, **kwargs):
return result


class ProtectedMaterialsEvaluator:
class ProtectedMaterialEvaluator:
"""
Initialize a protected materials evaluator to detect whether protected material
Initialize a protected material evaluator to detect whether protected material
is present in your AI system's response. Outputs True or False with AI-generated reasoning.
:param project_scope: The scope of the Azure AI project.
Expand All @@ -62,25 +62,25 @@ class ProtectedMaterialsEvaluator:
"resource_group_name": "<resource_group_name>",
"project_name": "<project_name>",
}
eval_fn = ProtectedMaterialsEvaluator(project_scope)
eval_fn = ProtectedMaterialEvaluator(project_scope)
result = eval_fn(question="What is the capital of France?", answer="Paris.")
**Output format**
.. code-block:: python
{
"protected_material_label": "False",
"protected_material_reasoning": "This question does not contain any protected material."
"label": "False",
"reasoning": "This question does not contain any protected material."
}
"""

def __init__(self, project_scope: dict, credential=None):
self._async_evaluator = _AsyncProtectedMaterialsEvaluator(project_scope, credential)
self._async_evaluator = _AsyncProtectedMaterialEvaluator(project_scope, credential)

def __call__(self, *, question: str, answer: str, **kwargs):
"""
Evaluates protected materials content.
Evaluates protected material content.
:keyword question: The question to be evaluated.
:paramtype question: str
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
FluencyEvaluator,
GroundednessEvaluator,
HateUnfairnessEvaluator,
ProtectedMaterialsEvaluator,
ProtectedMaterialEvaluator,
QAEvaluator,
RelevanceEvaluator,
SelfHarmEvaluator,
Expand Down Expand Up @@ -361,8 +361,8 @@ def test_composite_evaluator_content_safety_chat(self, project_scope, eval_last_
@pytest.mark.skipif(
not is_replay(), reason="API not fully released yet. Don't run in live mode unless connected to INT."
)
def test_protected_materials_evaluator(self, project_scope, azure_cred):
ip_eval = ProtectedMaterialsEvaluator(project_scope, credential=azure_cred)
def test_protected_material_evaluator(self, project_scope, azure_cred):
ip_eval = ProtectedMaterialEvaluator(project_scope, credential=azure_cred)
good_result = ip_eval(
question="What shape has 4 equilateral sides?",
answer="Rhombus",
Expand Down
Loading

0 comments on commit d5cc19c

Please sign in to comment.