現在表示中:Foundry (クラシック) ポータルのバージョン - 新しい Foundry ポータルのバージョンに切り替える
Note
Microsoft Foundry SDK for evaluation および Foundry ポータルはパブリック プレビュー段階ですが、API はモデルとデータセットの評価に一般提供されています (エージェントの評価はパブリック プレビューのままです)。 この記事でマークされている Azure AI Evaluation SDK とエバリュエーター (プレビュー) は、現在、あらゆる場所でパブリック プレビュー段階にあります。
組み込みのエバリュエーターは、アプリケーションの世代の品質を簡単に監視する方法を提供します。 評価をカスタマイズするには、独自のコード ベースまたはプロンプト ベースのエバリュエーターを作成します。
Code-based evaluators
特定の評価指標に対して大規模な言語モデルは必要ありません。 コードベースの評価ツールは、関数や呼び出し可能なクラスに基づいてメトリクスを定義する柔軟性を提供します。 例えば、answer_length.pyの回答の長さをディレクトリanswer_len/で計算する簡単なPythonクラスを作成すれば、自分でコードベースの評価器を作成できます。以下の例のように。
コードベースの評価器例:回答の長さ
class AnswerLengthEvaluator:
def __init__(self):
pass
# A class is made callable by implementing the special method __call__
def __call__(self, *, answer: str, **kwargs):
return {"answer_length": len(answer)}
呼び出し可能なクラスをインポートしてデータの行に対して評価器を実行します:
from answer_len.answer_length import AnswerLengthEvaluator
answer_length_evaluator = AnswerLengthEvaluator()
answer_length = answer_length_evaluator(answer="What is the speed of light?")
コードベースの評価者出力:回答の長さ
{"answer_length":27}
Prompt-based evaluators
自分だけのプロンプトベースの大規模言語モデル評価器やAI支援アノテーターを作成するには、 Prompty ファイルを基にカスタム評価者を作成してください。
Promptyは、プロンプトテンプレート開発用の .prompty 拡張子のファイルです。 Promptyアセットは、フロントマターが修正されたマークダウンファイルです。 前文はYAML形式です。 モデル構成やプロンプティの期待される入力を定義するメタデータフィールドが含まれています。
回答の親しみやすさを測るために、 FriendlinessEvaluatorという名前のカスタム評価者を作成します。
プロンプトベースの評価者の例:親しみ評価者
まず、親しみ度指標とその評価ルーブリックを定義する friendliness.prompty ファイルを作成します。
---
name: Friendliness Evaluator
description: Friendliness Evaluator to measure warmth and approachability of answers.
model:
api: chat
configuration:
type: azure_openai
azure_endpoint: ${env:AZURE_OPENAI_ENDPOINT}
azure_deployment: gpt-4o-mini
parameters:
model:
temperature: 0.1
inputs:
response:
type: string
outputs:
score:
type: int
explanation:
type: string
---
system:
Friendliness assesses the warmth and approachability of the answer. Rate the friendliness of the response between one to five stars using the following scale:
One star: the answer is unfriendly or hostile
Two stars: the answer is mostly unfriendly
Three stars: the answer is neutral
Four stars: the answer is mostly friendly
Five stars: the answer is very friendly
Please assign a rating between 1 and 5 based on the tone and demeanor of the response.
**Example 1**
generated_query: I just don't feel like helping you! Your questions are getting very annoying.
output:
{"score": 1, "reason": "The response is not warm and is resisting to be providing helpful information."}
**Example 2**
generated_query: I'm sorry this watch is not working for you. Very happy to assist you with a replacement.
output:
{"score": 5, "reason": "The response is warm and empathetic, offering a resolution with care."}
**Here the actual conversation to be scored:**
generated_query: {{response}}
output:
次に、Promptyファイルを読み込み、JSON形式で出力を処理するクラス FriendlinessEvaluator を作成します。
import os
import json
import sys
from promptflow.client import load_flow
class FriendlinessEvaluator:
def __init__(self, model_config):
current_dir = os.path.dirname(__file__)
prompty_path = os.path.join(current_dir, "friendliness.prompty")
self._flow = load_flow(source=prompty_path, model={"configuration": model_config})
def __call__(self, *, response: str, **kwargs):
llm_response = self._flow(response=response)
try:
response = json.loads(llm_response)
except Exception as ex:
response = llm_response
return response
次に、自分だけのPromptyベースの評価ツールを作成し、データの行で実行してください:
from friendliness.friend import FriendlinessEvaluator
friendliness_eval = FriendlinessEvaluator(model_config)
friendliness_score = friendliness_eval(response="I will not apologize for my behavior!")
プロンプトベースの評価者出力:親しみ評価者
{
'score': 1,
'reason': 'The response is hostile and unapologetic, lacking warmth or approachability.'
}