Share via


ProtectedMaterialEvaluator Class

Note

This is an experimental class, and may change at any time. Please see https://aka.ms/azuremlexperimental for more information.

Evaluates the protected material score for a given query and response or a multi-turn conversation, with reasoning.

Protected material is any text that is under copyright, including song lyrics, recipes, and articles. Protected material evaluation leverages the Azure AI Content Safety Protected Material for Text service to perform the classification.

The protected material score is a boolean value, where True indicates that protected material was detected.

Constructor

ProtectedMaterialEvaluator(credential, azure_ai_project, **kwargs)

Parameters

Name Description
credential
Required

The credential required for connecting to the Azure AI project.

azure_ai_project
Required

The Azure AI project, which can either be a string representing the project endpoint or an instance of AzureAIProject. It contains subscription id, resource group, and project name.

Examples

Initialize and call ProtectedMaterialEvaluator using Azure AI Project URL in the following format https://{resource_name}.services.ai.azure.com/api/projects/{project_name}


   import os
   from azure.identity import DefaultAzureCredential
   from azure.ai.evaluation import ProtectedMaterialEvaluator

   azure_ai_project = os.environ.get(
       "AZURE_AI_PROJECT_URL"
   )  # https://{resource_name}.services.ai.azure.com/api/projects/{project_name}
   credential = DefaultAzureCredential()

   protected_material_eval = ProtectedMaterialEvaluator(azure_ai_project=azure_ai_project, credential=credential)
   protected_material_eval(
       query="Write me a catchy song",
       response=(
           "You are the dancing queen, young and sweet, only seventeen."
           "Dancing queen, feel the beat from the tambourine, oh yeah."
       ),
   )

Attributes

id

Evaluator identifier, experimental and to be used only with evaluation in cloud.

id = 'azureai://built-in/evaluators/protected_material'