次の方法で共有


Azure OpenAI 評価 (プレビュー)

大規模な言語モデルの評価は、さまざまなタスクとディメンションのパフォーマンスを測定する上で重要なステップです。 これは、トレーニングによるパフォーマンスの向上 (または損失) を評価することが重要な微調整されたモデルでは特に重要です。 徹底的な評価は、さまざまなバージョンのモデルがアプリケーションまたはシナリオに与える影響を理解するのに役立ちます。

Azure OpenAI 評価を使用すると、開発者は、予想される入力/出力ペアをテストするために実行する評価を作成し、精度、信頼性、全体的なパフォーマンスなどの主要なメトリック間でモデルのパフォーマンスを評価できます。

評価のサポート

リージョン別の提供状況

  • オーストラリア東部
  • ブラジル南部
  • カナダ中部
  • 米国中部
  • 米国東部 2
  • フランス中部
  • ドイツ中西部
  • イタリア北部
  • 東日本
  • 西日本
  • 韓国中部
  • 米国中北部
  • ノルウェー東部
  • ポーランド中部
  • 南アフリカ北部
  • 東南アジア
  • スペイン中部
  • スウェーデン中部
  • スイス北部
  • スイス西部
  • アラブ首長国連邦北部
  • 英国南部
  • 英国西部
  • 西ヨーロッパ
  • 米国西部
  • 米国西部 2
  • 米国西部 3

優先リージョンがない場合は、 Azure OpenAI リージョン を参照し、それが Azure OpenAI リージョンの可用性ゾーンの 1 つであるかどうかを確認します。

サポートされるデプロイの種類

  • Standard
  • グローバル標準
  • データ ゾーン標準
  • プロビジョニング済みマネージド
  • グローバル プロビジョニング済みマネージド
  • データ ゾーン プロビジョニング済みマネージド

Evaluation API (プレビュー)

Evaluation API を使用すると、API 呼び出しを通じてモデルの出力を直接テストし、モデルの品質とパフォーマンスをプログラムで評価できます。 Evaluation API を使用するには、 REST API のドキュメントを参照してください。

評価パイプライン

テスト データ

テスト対象のグランド トゥルース データセットを組み立てる必要があります。 通常、データセットの作成は反復的なプロセスであり、評価は時間の経過に伴ってシナリオとの関連を保ち続けます。 通常、このグランド トゥルース データセットは手動で作成され、モデルからの期待される動作を表します。 データセットにもラベルが付き、予想される回答が含まれます。

センチメント有効な JSON または XML などの一部の評価テストでは、グランド トゥルース データは必要ありません。

データ ソースは JSONL 形式である必要があります。 JSONL 評価データセットの 2 つの例を次に示します。

評価形式

{"question": "Find the degree for the given field extension Q(sqrt(2), sqrt(3), sqrt(18)) over Q.", "subject": "abstract_algebra", "A": "0", "B": "4", "C": "2", "D": "6", "answer": "B", "completion": "B"}
{"question": "Let p = (1, 2, 5, 4)(2, 3) in S_5 . Find the index of <p> in S_5.", "subject": "abstract_algebra", "A": "8", "B": "2", "C": "24", "D": "120", "answer": "C", "completion": "C"}
{"question": "Find all zeros in the indicated finite field of the given polynomial with coefficients in that field. x^5 + 3x^3 + x^2 + 2x in Z_5", "subject": "abstract_algebra", "A": "0", "B": "1", "C": "0,1", "D": "0,4", "answer": "D", "completion": "D"}

評価ファイルをアップロードして選択すると、最初の 3 行のプレビューが返されます。

質問と回答のペアに対してアップロードされた評価トレーニング ファイルのプレビューを示すスクリーンショット。

以前にアップロードした既存のデータセットを選択するか、新しいデータセットをアップロードできます。

応答を作成する (省略可能)

評価で使用するプロンプトは、運用環境で使用する予定のプロンプトと一致する必要があります。 これらのプロンプトは、モデルが従う手順を示します。 プレイグラウンド エクスペリエンスと同様に、複数の入力を作成して、プロンプトに少数ショットの例を含めることができます。 詳細については、「プロンプト エンジニアリングの手法」で、プロンプト設計とプロンプト エンジニアリングの高度な手法の詳細を参照してください。

{{input.column_name}} の形式を使用して、プロンプト内の入力データを参照できます。ここで、column_name は、入力ファイル内の列の名前に対応します。

評価中に生成された出力は、{{sample.output_text}} の形式を使用して後続の手順で参照されます。

データを正しく参照するには、二重中かっこを使用する必要があります。

モデル デプロイ

Azure OpenAI では、評価に使用するモデル デプロイを作成する必要があります。 ニーズに応じて、1 つのモデルまたは複数のモデルを選択してデプロイできます。 これらのモデルデプロイは、ベース モデルまたは微調整されたモデルを、選択したテスト条件で採点するときに使用されます。 また、デプロイされたモデルを使用して、指定されたプロンプトに対する応答を自動生成することもできます。

一覧で使用できるデプロイは、Azure OpenAI リソース内で作成したデプロイによって異なります。 目的のデプロイが見つからない場合は、Azure OpenAI 評価ページから新しいデプロイを作成できます。

テスト条件

テスト条件は、ターゲット モデルによって生成された各出力の有効性を評価するために使用されます。 これらのテストでは、一貫性を確保するために、入力データと出力データを比較します。 さまざまなレベルで出力の品質と関連性をテストおよび測定するために、さまざまな条件を柔軟に構成できます。

さまざまなテスト条件の選択を示すスクリーンショット。

各テスト条件をクリックすると、さまざまな種類の採点者と、独自の評価データセットと条件に従って変更できる事前設定されたスキーマが表示されます。

評価テスト条件のオプションを示すスクリーンショット。

作業の開始

評価の作成

  1. Azure AI Foundry ポータル内で Azure OpenAI 評価 (プレビュー) を選択します。 このビューをオプションとして表示するには、まず、サポートされているリージョンの既存の Azure OpenAI リソースを選択します。

  2. [+ 新しい評価] を選択する

    新しい評価が選択された Azure OpenAI 評価 UX のスクリーンショット。

  3. 評価用のテスト データを提供する方法を選択します。 保存されているチャット入力候補をインポートしたり、指定された既定のテンプレートを使用してデータを作成したり、独自のデータをアップロードしたりすることができます。 独自のデータをアップロードする手順を見てみましょう。

    Azure OpenAI の新しい評価の作成のスクリーンショット。

  4. .jsonl形式の評価データを選択します。 既存のデータが既にある場合は、データを選択するか、新しいデータをアップロードできます。

    データ アップロード オプションのスクリーンショット。

    新しいデータをアップロードすると、右側にプレビューとしてファイルの最初の 3 行が表示されます。

    選択例を含むデータアップロードのスクリーンショット。

    サンプル のテスト ファイルが必要な場合は、このサンプル .jsonl テキストを使用できます。 このサンプルには、さまざまな技術的なコンテンツの文が含まれており、これらの文のセマンティック類似性を評価します。

    {"input": [{"role": "system", "content": "Provide a clear and concise summary of the technical content, highlighting key concepts and their relationships. Focus on the main ideas and practical implications."}, {"role": "user", "content": "Tokenization is a key step in preprocessing for natural language processing, involving the division of text into smaller components called tokens. These can be words, subwords, or characters, depending on the method chosen. Word tokenization divides text at word boundaries, while subword techniques like Byte Pair Encoding (BPE) or WordPiece can manage unknown words by breaking them into subunits. Character tokenization splits text into individual characters, useful for multiple languages and misspellings. The tokenization method chosen greatly affects model performance and its capacity to handle various languages and vocabularies."}], "output": "Tokenization divides text into smaller units (tokens) for NLP applications, using word, subword (e.g., BPE), or character methods. Each has unique benefits, impacting model performance and language processing capabilities."}      
    {"input": [{"role": "system", "content": "Create a comprehensive yet concise summary that captures the essential technical details and significance of the topic."}, {"role": "user", "content": "Self-attention mechanisms are vital in modern transformer models, allowing them to evaluate the relevance of different parts of an input sequence when processing each element. In self-attention, each position in a sequence learns to focus on all other positions, forming a weighted sum of their values. Attention weights are derived using queries, keys, and values, with compatibility between a query and key determining attention to each value. This mechanism enables capturing long-range dependencies and relationships within a sequence, making it effective for tasks needing context understanding and inter-part relationships."}], "output": "Self-attention is crucial in transformers, enabling each sequence position to evaluate and collect data from all others. It uses queries, keys, and values for attention weights, effectively capturing long-range dependencies and contextual links."}      
    {"input": [{"role": "system", "content": "Synthesize the technical information into a brief, accurate summary that maintains the core concepts and their significance."}, {"role": "user", "content": "The transformer architecture significantly changed natural language processing by introducing a new method for sequence processing. Unlike recurrent neural networks, transformers process whole sequences at once using self-attention. The architecture consists of an encoder and decoder, each with multiple layers of multi-head attention, feed-forward networks, and normalization layers. The encoder processes the input sequence, and the decoder produces the output sequence. Positional encodings are added to retain sequence order information since the model lacks inherent sequence position awareness. This architecture underlies many leading language models like BERT and GPT."}], "output": "Transformers are a transformative neural architecture processing sequences with self-attention instead of recurrence. Their encoder-decoder design, with multi-head attention and position encodings, is fundamental to modern language models like BERT and GPT."}      
    {"input": [{"role": "system", "content": "Distill the technical content into a clear, concise summary that preserves the most important concepts and their practical applications."}, {"role": "user", "content": "Cosine similarity is a metric for measuring similarity between vectors by calculating the cosine of the angle between them. The outcome ranges from -1 to 1, with 1 indicating identical orientation, 0 orthogonality, and -1 opposite orientation. In machine learning and NLP, cosine similarity is useful for comparing document vectors, word embeddings, or any high-dimensional representations. It's often preferred over Euclidean distance because it's invariant to vector magnitude, focusing instead on orientation. This makes it particularly useful for comparing documents or embeddings of various lengths or scales."}], "output": "Cosine similarity evaluates vector similarity by computing their angle's cosine, with values from -1 to 1. It's widely used in ML and NLP for comparing document vectors and embeddings due to its magnitude-invariant nature."}      
    {"input": [{"role": "system", "content": "Provide a succinct summary that captures the key technical concepts and their relationships while maintaining clarity and accuracy."}, {"role": "user", "content": "Neural network activation functions are crucial for introducing non-linearity to deep learning models. Commonly used activation functions include ReLU (Rectified Linear Unit), which outputs the input directly if positive and zero otherwise, sigmoid, which compresses values between 0 and 1, and tanh, which normalizes values between -1 and 1. Each function has specific benefits and applications: ReLU avoids vanishing gradients and enables sparse activation, sigmoid is useful for binary classification, and tanh is often used in hidden layers for its zero-centered output. The activation function choice greatly affects model training dynamics and ultimate performance."}], "output": "Activation functions introduce non-linearity to neural networks, with ReLU, sigmoid, and tanh being the most common. Each serves distinct purposes: ReLU prevents vanishing gradients, sigmoid is suitable for binary classification, and tanh offers zero-centered output, all affecting model performance differently."}      
    {"input": [{"role": "system", "content": "Create a focused summary that emphasizes the main technical concepts and their practical implications while maintaining accuracy."}, {"role": "user", "content": "Batch normalization is a technique that stabilizes and accelerates deep neural network training by normalizing each layer's inputs. It normalizes activations using the mean and variance computed over the current data batch. This normalization reduces internal covariate shift, where the input distribution changes during training. Batch normalization includes learnable parameters (gamma and beta) allowing the network to reverse normalization if necessary. Benefits include enabling higher learning rates, lessening the importance of precise parameter initialization, and serving as a regularizer, potentially removing the need for dropout."}], "output": "Batch normalization stabilizes neural network training by normalizing layer inputs using batch statistics. It addresses internal covariate shift with learnable parameters, allowing higher learning rates and improved training dynamics, while offering regularization benefits."}      
    {"input": [{"role": "system", "content": "Summarize the technical content while preserving the essential concepts and their interconnections, ensuring clarity and precision."}, {"role": "user", "content": "Gradient descent optimization algorithms are foundational to training machine learning models. The basic version updates parameters in the steepest descent direction of the loss function. Variants like Stochastic Gradient Descent (SGD) use random samples to estimate gradients, enhancing computational efficiency. Advanced optimizers like Adam combine momentum (helping overcome local minima) and RMSprop (adapting learning rates for each parameter). These optimizers maintain running averages of gradients and their squares, enabling adaptive learning rates and more efficient training. The optimizer choice can significantly influence model convergence speed and final performance."}], "output": "Gradient descent algorithms optimize ML models by updating parameters based on loss gradients. Variants like SGD use sampling for efficiency, while advanced optimizers like Adam combine momentum with adaptive learning rates for improved training performance."}      
    {"input": [{"role": "system", "content": "Deliver a concise yet comprehensive summary that highlights the key technical aspects and their practical significance."}, {"role": "user", "content": "Cross-validation is a resampling method used to evaluate machine learning models on limited data. The most common form, k-fold cross-validation, involves dividing the dataset into k equal parts, training the model on k-1 folds while validating on the remaining fold, and rotating through all combinations. This provides a more robust model performance assessment than a single train-test split, helping detect overfitting and estimate model generalization to unseen data. Variations include stratified k-fold (maintaining class distribution), leave-one-out (k equals dataset size), and time series cross-validation for temporal data."}], "output": "Cross-validation evaluates ML models by training and testing on different data splits, typically using k-fold methodology. This approach offers better performance assessment than single splits, with variations for different data types and requirements."}      
    {"input": [{"role": "system", "content": "Generate a clear and focused summary that captures the essential technical details while maintaining their relationships and significance."}, {"role": "user", "content": "Transfer learning is a machine learning method where a model developed for one task is reused as the starting point for a model on a second task. This approach is powerful in deep learning, where pre-trained models on large datasets (like ImageNet for computer vision or BERT for NLP) are fine-tuned on specific downstream tasks. Transfer learning reduces the need for large amounts of task-specific training data and computational resources, as the model has already learned useful features from the source domain. Common strategies include feature extraction (freezing pre-trained layers) and fine-tuning (updating all or some pre-trained weights)."}], "output": "Transfer learning reuses models trained on one task for different tasks, particularly effective in deep learning. It leverages pre-trained models through feature extraction or fine-tuning, reducing data and computational needs for new tasks."}      
    {"input": [{"role": "system", "content": "Provide a precise and informative summary that distills the key technical concepts while maintaining their relationships and practical importance."}, {"role": "user", "content": "Ensemble methods combine multiple machine learning models to create a more robust and accurate predictor. Common techniques include bagging (training models on random data subsets), boosting (sequentially training models to correct earlier errors), and stacking (using a meta-model to combine base model predictions). Random Forests, a popular bagging method, create multiple decision trees using random feature subsets. Gradient Boosting builds trees sequentially, with each tree correcting the errors of previous ones. These methods often outperform single models by reducing overfitting and variance while capturing different data aspects."}], "output": "Ensemble methods enhance prediction accuracy by combining multiple models through techniques like bagging, boosting, and stacking. Popular implementations include Random Forests (using multiple trees with random features) and Gradient Boosting (sequential error correction), offering better performance than single models."}
    
  5. テスト データからの入力を使用して新しい応答を作成する場合は、[ 新しい応答の生成] を選択できます。 これにより、評価ファイルの入力フィールドが個々のプロンプトに挿入され、選択したモデルで出力が生成されます。

選択したインポート テスト データを示す UX のスクリーンショット。

選択したモデルを選択します。 モデルがない場合は、新しいモデル デプロイを作成できます。 選択したモデルは入力データを受け取り、独自の一意の出力を生成します。この場合、 {{sample.output_text}}という変数に格納されます。 その後、その出力をテスト基準の一部として後で使用します。 または、独自のカスタム システム メッセージと個々のメッセージの例を手動で指定することもできます。

モデル応答を生成するための UX のスクリーンショット。

  1. テスト条件を作成するには、[追加] を選択 します。 提供したサンプル ファイルでは、セマンティックの類似性を評価します。 セマンティック類似性のテスト基準プリセットを含む モデル スコアラーを選択します。

    モデル スコアラーが強調表示されているセマンティック類似性 UX 構成のスクリーンショット。

    上部にある [セマンティック類似性 ] を選択します。 一番下までスクロールし、Userセクションで{{item.output}}Ground truthとして指定し、{{sample.output_text}}としてOutputを指定します。 これにより、評価 .jsonl ファイル (提供されたサンプル ファイル) からの元の参照出力が取得され、前の手順で選択したモデルによって生成された出力と比較されます。

    生成された出力を含むセマンティック類似性 UX 構成のスクリーンショット。

セマンティック類似性 UX 構成のスクリーンショット。

  1. [ 追加] を選択して、このテスト条件を追加します。 追加のテスト条件を追加する場合は、この手順で追加できます。

  2. 評価を作成する準備ができました。 評価名を指定し、すべてが正しいことを確認し、 送信 して評価ジョブを作成します。 評価ジョブの状態ページが表示され、状態が [待機中] と表示されます。

評価ジョブ送信 UX のスクリーンショット。 状態が大気中の評価ジョブ送信 UX のスクリーンショット。

  1. 評価ジョブが作成されたら、ジョブを選択して、ジョブの完全な詳細を表示できます。

合格と不合格が混在する、完了したセマンティック類似性テストのスクリーンショット。

  1. セマンティック類似性の [View output details]\(出力詳細の表示\) に、合格したテストをコピーして貼り付けられる JSON 表現が含まれます。

出力の詳細を示す評価状態 UX のスクリーンショット。

  1. 評価ジョブ ページの左上隅にある [ + 実行の追加] ボタンを選択して、Eval 実行をさらに追加することもできます。

評価の作成

評価を作成するには、データ ソース構成と評価テスト条件を指定します。 データ ソース構成を定義する方法の 1 つを次に示します。1 つまたは複数のテスト条件を指定することもできます。

import asyncio
import json
import requests

async def create_eval():
    response = await asyncio.to_thread(
        requests.post,
        f'{API_ENDPOINT}/openai/v1/evals',
        headers={
            'api-key': API_KEY,
            'aoai-evals': 'preview'
        },
        json={
            'name': 'My Evaluation',
            'data_source_config': {
                'type': 'custom',
                'item_schema': {
                'type': 'object',
                'properties': {
                    'question': {
                    'type': 'string'
                    },
                    'subject': {
                    'type': 'string'
                    },
                    'A': {
                    'type': 'string'
                    },
                    'B': {
                    'type': 'string'
                    },
                    'C': {
                    'type': 'string'
                    },
                    'D': {
                    'type': 'string'
                    },
                    'answer': {
                    'type': 'string'
                    },
                    'completion': {
                    'type': 'string'
                    }
                }
                }
            },
            'testing_criteria': [
                {
                'type': 'string_check',
                'reference': '{{item.completion}}',
                'input': '{{item.answer}}',
                'operation': 'eq',
                'name': 'string check'
                }
            ]
        })

    print(response.status_code)
    print(json.dumps(response.json(), indent=2))

1 回の実行を作成する

Azure OpenAI Evaluation では、評価ジョブの下に複数の実行を作成できます。 既存の評価に 1 つの評価実行を追加する場合は、既存の評価の eval_id を指定できます。

import asyncio
import requests
import json


response = await asyncio.to_thread(
    requests.post,
    f'{API_ENDPOINT}/openai/v1/evals/{eval_id}/runs',
    headers={
        'api-key': API_KEY,
        'aoai-evals': 'preview'
    },
    json={
        "name": "No sample",
        "metadata": {
            "sample_generation": "off",
            "file_format": "jsonl"
        },
        "data_source": {
            "type": "jsonl",
            "source": {
            "type": "file_id",
            "id": "file-75099d8d4b5b4abca7cc91e9eca7bba1"
            }
        }
    })

print(response.status_code)
print(json.dumps(response.json(), indent=2))

既存の評価を更新する

import asyncio
import requests
import json

async def update_eval():
    response = await asyncio.to_thread(
        requests.post,
        f'{API_ENDPOINT}/openai/v1/evals/{eval_id}',
        headers={
            'api-key': API_KEY,
            'aoai-evals': 'preview'
        },
        json={
            "name": "Updated Eval Name",
            "metadata": {
                "sample_generation": "off",
                "file_format": "jsonl",
                "updated": "metadata"
            }
        })

    print(response.status_code)
    print(json.dumps(response.json(), indent=2))

評価結果

評価が完了したら、 eval_idを指定することで、評価ジョブの評価結果をフェッチできます。

import asyncio
import requests

async def get_eval():
    response = await asyncio.to_thread(
        requests.get,
        f'{API_ENDPOINT}/openai/v1/evals/{eval_id}',
        headers={
            'api-key': API_KEY,
            'aoai-evals': 'preview'
        })

    print(response.status_code)
    print(response.json())

単一評価の実行結果

既存の評価ジョブで 1 つの評価実行を作成する方法と同様に、1 回の実行の結果を取得することもできます。

import asyncio
import requests
import json

async def get_eval_run():
    response = await asyncio.to_thread(
        requests.get,
        f'{API_ENDPOINT}/openai/v1/evals/eval_67fd95c864f08190817f0dff5f42f49e/runs/evalrun_67fe987a6c548190ba6f33f7cd89343d',
        headers={
            'api-key': API_KEY,
            'aoai-evals': 'preview'
        })

    print(response.status_code)
    print(json.dumps(response.json(), indent=2))

上記の例のパラメーターに加えて、必要に応じて、より具体的なドリルダウン用のこれらのパラメーターを評価結果に追加できます。

名前 必須 タイプ 説明
エンドポイント パス イエス 文字列 サポートされている Azure OpenAI エンドポイント (プロトコルとホスト名など: https://aoairesource.openai.azure.com。"aoairesource" を Azure OpenAI リソース名に置き換えます)。 https://{your-resource-name}.openai.azure.com
エヴァル-ID パス イエス 文字列 実行を取得する評価の ID。
実行識別子 パス イエス 文字列 出力項目を取得する実行の ID。
after クエリ いいえ 文字列 前の改ページ調整要求からの最後の出力項目の識別子。
リミット クエリ いいえ 整数 取得する出力項目の数。
状態 クエリ いいえ 文字列 指定できる値: fail、pass。 状態で出力項目をフィルタリングする。 失敗した出力項目でフィルター処理に失敗するか、渡された出力項目でフィルター処理する場合に使用します。
順序 クエリ いいえ 文字列 指定できる値: asc、desc。 タイムスタンプによる出力項目の並べ替え順序。 昇順には asc、降順には desc を使用します。 既定値は asc です。
APIバージョン クエリ イエス 文字列 要求された API バージョン。

評価リスト

作成されたすべての評価ジョブの一覧を表示するには:

import asyncio
import requests
import json

async def get_eval_list():
    response = await asyncio.to_thread(
        requests.get,
        f'{API_ENDPOINT}/openai/v1/evals',
        headers={
            'api-key': API_KEY,
            'aoai-evals': 'preview'
        })

    print(response.status_code)
    print(json.dumps(response.json(), indent=2))

実行の出力の詳細

1 回の評価実行について、採点者から生成された個々の出力を表示できます。

import asyncio
import requests
import json

async def get_eval_output_item_list():
    response = await asyncio.to_thread(
        requests.get,
        f'{API_ENDPOINT}/openai/v1/evals/eval_67fd95c864f08190817f0dff5f42f49e/runs/evalrun_67fe987a6c548190ba6f33f7cd89343d/output_items',
        headers={
            'api-key': API_KEY,
            'aoai-evals': 'preview'
        })

    print(response.status_code)
    print(json.dumps(response.json(), indent=2))

表示する特定の出力結果がある場合は、出力項目 ID を指定できます。

import asyncio
import requests
import json

async def get_eval_output_item():
    response = await asyncio.to_thread(
        requests.get,
        f'{API_ENDPOINT}/openai/v1/evals/eval_67fd95c864f08190817f0dff5f42f49e/runs/evalrun_67fe987a6c548190ba6f33f7cd89343d/output_items/outputitem_67fe988369308190b50d805120945deb',
        headers={'api-key': API_KEY})

    print(response.status_code)
    print(json.dumps(response.json(), indent=2))

評価の作成

評価を作成するには、データ ソース構成と評価テスト条件を指定します。 データ ソース構成を定義する方法の 1 つを次に示します。1 つまたは複数のテスト条件を指定することもできます。

curl -X POST "$AZURE_OPENAI_ENDPOINT/openai/v1/evals" \
  -H "Content-Type: application/json" \
  -H "api-key: $AZURE_OPENAI_API_KEY" \
  -H "aoai-evals: preview" \
  -d '{
    "name": "Math Quiz",
    "data_source_config": {
      "type": "custom",
      "include_sample_schema": true,
      "item_schema": {
        "type": "object",
        "properties": {
          "question": { "type": "string" },
          "A": { "type": "string" },
          "B": { "type": "string" },
          "C": { "type": "string" },
          "D": { "type": "string" },
          "answer": { "type": "string" }
        }
      }
    },
    "testing_criteria": [
      {
        "type": "string_check",
        "reference": "{{item.answer}}",
        "input": "{{sample.output_text}}",
        "operation": "eq",
        "name": "string check"
      }
    ]
  }'

1 回の実行を作成する

Azure OpenAI Evaluation では、評価ジョブの下に複数の実行を作成できます。 eval-idを指定することで、前の手順で作成した評価ジョブに新しい評価実行を追加できます。

curl -X POST "$AZURE_OPENAI_ENDPOINT/openai/v1/evals/{eval-id}/runs" \
  -H "Content-Type: application/json" \
  -H "api-key: $AZURE_OPENAI_API_KEY" 
  -H "aoai-evals: preview" \

既存の評価を更新する

curl -X POST "$AZURE_OPENAI_ENDPOINT/openai/v1/evals/{eval-id} \
  -H "Content-Type: application/json" \
  -H "api-key: $AZURE_OPENAI_API_KEY" 
  -H "aoai-evals: preview" \

評価結果

評価が完了したら、 eval_idを指定することで、評価ジョブの評価結果をフェッチできます。

curl -X GET "$AZURE_OPENAI_ENDPOINT/openai/v1/evals/{eval-id}" \
  -H "Content-Type: application/json" \
  -H "api-key: $AZURE_OPENAI_API_KEY" 
  -H "aoai-evals: preview" \

単一評価の実行結果

既存の評価ジョブで 1 つの評価実行を作成する方法と同様に、1 回の実行の結果を取得することもできます。

curl -X GET "$AZURE_OPENAI_ENDPOINT/openai/v1/evals/{eval-id}/runs/{run-id}" \
  -H "Content-Type: application/json" \
  -H "api-key: $AZURE_OPENAI_API_KEY" 
  -H "aoai-evals: preview" \

上記の例のパラメーターに加えて、必要に応じて、より具体的なドリルダウン用のこれらのパラメーターを評価結果に追加できます。

名前 必須 タイプ 説明
エンドポイント パス イエス 文字列 サポートされている Azure OpenAI エンドポイント (プロトコルとホスト名など: https://aoairesource.openai.azure.com。"aoairesource" を Azure OpenAI リソース名に置き換えます)。 https://{your-resource-name}.openai.azure.com
エヴァル-ID パス イエス 文字列 実行を取得する評価の ID。
実行識別子 パス イエス 文字列 出力項目を取得する実行の ID。
after クエリ いいえ 文字列 前の改ページ調整要求からの最後の出力項目の識別子。
リミット クエリ いいえ 整数 取得する出力項目の数。
状態 クエリ いいえ 文字列 指定できる値: fail、pass。 状態で出力項目をフィルタリングする。 失敗した出力項目でフィルター処理に失敗するか、渡された出力項目でフィルター処理する場合に使用します。
順序 クエリ いいえ 文字列 指定できる値: asc、desc。 タイムスタンプによる出力項目の並べ替え順序。 昇順には asc、降順には desc を使用します。 既定値は asc です。
APIバージョン クエリ イエス 文字列 要求された API バージョン。

評価リスト

作成されたすべての評価ジョブの一覧を表示するには:

curl -X GET "$AZURE_OPENAI_ENDPOINT/openai/v1/evals/{eval-id}/runs" \
  -H "Content-Type: application/json" \
  -H "api-key: $AZURE_OPENAI_API_KEY" 
  -H "aoai-evals: preview" \

実行の出力の詳細

1 回の評価実行について、採点者から生成された個々の出力を表示できます。

curl -X GET "$AZURE_OPENAI_ENDPOINT/openai/v1/evals/{eval-id}/runs/{run-id}/output_items" \
  -H "Content-Type: application/json" \
  -H "api-key: $AZURE_OPENAI_API_KEY" 
  -H "aoai-evals: preview" \

表示する特定の出力結果がある場合は、出力項目 ID を指定できます。

curl -X GET "$AZURE_OPENAI_ENDPOINT/openai/v1/evals/{eval-id}/runs/{run-id}/output_items/{output-item-id}" \
  -H "Content-Type: application/json" \
  -H "api-key: $AZURE_OPENAI_API_KEY"
  -H "aoai-evals: preview" \

テスト基準の種類

Azure OpenAI Evaluation では、提供された例で見たセマンティック類似性に加えて、さまざまな評価テスト条件が提供されます。 このセクションでは、各テスト条件について詳しく説明します。

事実性

エキスパートの回答と比較して、提出された回答の事実の正確性を評価します。

事実性は、提出された回答をエキスパートの回答と比較することで、実際の正確性を評価します。 グレーダーは、詳細な CoT (chain-of-thought) プロンプトを使用して、提出された回答がエキスパートの回答と一貫性があるか、そのサブセットであるか、そのスーパーセットであるか、競合しているかを判断します。 スタイル、文法、句読点の違いは無視され、事実に基づくコンテンツのみに焦点が当てられます。 事実性は、AI によって提供される回答の精度を保証するコンテンツ検証、教育ツールなど、その他の多くのシナリオで役立ちます。

事実性テスト条件のスクリーンショット。

このテスト条件の一部として使用されるプロンプト テキストを表示するには、プロンプトの横にあるドロップダウンを選択します。 現在のプロンプト テキストは次のとおりです。

Prompt
You are comparing a submitted answer to an expert answer on a given question.
Here is the data:
[BEGIN DATA]
************
[Question]: {input}
************
[Expert]: {ideal}
************
[Submission]: {completion}
************
[END DATA]
Compare the factual content of the submitted answer with the expert answer. Ignore any differences in style, grammar, or punctuation.
The submitted answer may either be a subset or superset of the expert answer, or it may conflict with it. Determine which case applies. Answer the question by selecting one of the following options:
(A) The submitted answer is a subset of the expert answer and is fully consistent with it.
(B) The submitted answer is a superset of the expert answer and is fully consistent with it.
(C) The submitted answer contains all the same details as the expert answer.
(D) There is a disagreement between the submitted answer and the expert answer.
(E) The answers differ, but these differences don't matter from the perspective of factuality.

セマンティックの類似性

モデルの応答と参照の類似性の度合いを測定します。 Grades: 1 (completely different) - 5 (very similar)

セマンティック類似性テスト条件のスクリーンショット。

センチメント

出力の感情的なトーンの特定を試みます。

センチメント テスト条件のスクリーンショット。

このテスト条件の一部として使用されるプロンプト テキストを表示するには、プロンプトの横にあるドロップダウンを選択します。 現在のプロンプト テキストは次のとおりです。

Prompt
You will be presented with a text generated by a large language model. Your job is to rate the sentiment of the text. Your options are:

A) Positive
B) Neutral
C) Negative
D) Unsure

[BEGIN TEXT]
***
[{text}]
***
[END TEXT]

First, write out in a step by step manner your reasoning about the answer to be sure that your conclusion is correct. Avoid simply stating the correct answers at the outset. Then print only the single character (without quotes or punctuation) on its own line corresponding to the correct answer. At the end, repeat just the letter again by itself on a new line

文字列チェック

出力が予想される文字列と正確に一致するかどうかを検証します。

文字列チェック テスト条件のスクリーンショット。

文字列チェックは、さまざまな評価基準を可能にする 2 つの文字列変数に対してさまざまなバイナリ操作を実行します。 これは、等価性、包含、特定のパターンなど、さまざまな文字列の関係の検証に役立ちます。 このエバリュエータでは、大文字と小文字を区別する比較と、大文字と小文字を区別しない比較を実行できます。 また、真または偽の結果に対して指定された成績を提供し、比較結果に基づいてカスタマイズされた評価結果を可能にします。 サポートされる操作の種類を次に示します。

  • equals: 出力文字列が評価文字列と正確に等しいかどうかを確認します。
  • contains: 評価文字列が出力文字列の substring であるかどうかを確認します。
  • starts-with: 出力文字列が評価文字列で始まるかどうかを確認します。
  • ends-with: 出力文字列が評価文字列で終わるかどうかを確認します。

テスト条件で特定のパラメーターを設定する場合は、"variable" と "template" から選択できるオプションがあります。 入力データ内の列を参照する場合は、"variable" を選択します。 固定の文字列指定する場合は、"template" を選択します。

有効な JSON または XML

出力が有効な JSON または XML であるかどうかを検証します。

有効な json または XML テスト条件のスクリーンショット。

スキーマに一致

出力が指定した構造に従っていることを確認します。

スキーマに一致テスト条件のスクリーンショット。

条件一致

モデルの応答が条件と一致するかどうかを評価します。 成績: 合格または不合格。

条件一致テストのスクリーンショット。

このテスト条件の一部として使用されるプロンプト テキストを表示するには、プロンプトの横にあるドロップダウンを選択します。 現在のプロンプト テキストは次のとおりです。

Prompt
Your job is to assess the final response of an assistant based on conversation history and provided criteria for what makes a good response from the assistant. Here is the data:

[BEGIN DATA]
***
[Conversation]: {conversation}
***
[Response]: {response}
***
[Criteria]: {criteria}
***
[END DATA]

Does the response meet the criteria? First, write out in a step by step manner your reasoning about the criteria to be sure that your conclusion is correct. Avoid simply stating the correct answers at the outset. Then print only the single character "Y" or "N" (without quotes or punctuation) on its own line corresponding to the correct answer. "Y" for yes if the response meets the criteria, and "N" for no if it does not. At the end, repeat just the letter again by itself on a new line.
Reasoning:

テキスト品質

参照テキストと比較して、テキストの品質を評価します。

テキスト品質テスト条件のスクリーンショット。

概要:

  • BLEU スコア: BLEU スコアを使用して、生成されたテキストの品質を 1 つ以上の高品質の参照翻訳と比較して評価します。
  • ROUGE スコア: ROUGE スコアを使用して、生成されたテキストの品質を参照概要と比較して評価します。
  • コサイン: コサイン類似性とも呼ばれ、モデル出力や参照テキストなどの 2 つのテキスト埋め込みがどの程度厳密に一致しているかを測定し、それらの間のセマンティック類似性を評価するのに役立ちます。 これは、ベクトル空間内の距離を測定することによって行われます。

[詳細]:

BLEU (BiLingual Evaluation Understudy) スコアは、自然言語処理 (NLP) と機械翻訳で一般に使用されています。 テキストの要約とテキストの生成というユース ケースで広く使用されています。 生成されたテキストが参照テキストとどの程度一致するかを評価します。 BLEU スコアの範囲は 0 から 1 であり、スコアが高いほど高い品質を示します。

ROUGE (Recall-Oriented Understudy for Gisting Evaluation) は、自動要約と機械翻訳を評価するために使用される一連のメトリックです。 生成されたテキストと参照の要約の間の重複を測定します。 ROUGE は、生成されたテキストが参照テキストをどの程度カバーしているかを評価する、リコール指向の測定に重点を置いています。 ROUGE スコアは、次のようなさまざまなメトリックを提供します。

  • ROUGE-1: 生成されたテキストと参照テキストの間のユニグラム (単一の単語) の重なり。
  • ROUGE-2: 生成されたテキストと参照テキストの間のビグラム (連続する 2 つの単語) の重なり。
  • ROUGE-3: 生成されたテキストと参照テキストの間のトリグラム (連続する 3 つの単語) の重なり。
  • ROUGE-4: 生成されたテキストと参照テキストの間に 4 グラム (4 つの連続する単語) の重なりがあります。
  • ROUGE-5: 生成されたテキストと参照テキストの間に 5 グラム (5 つの連続する単語) の重なりがあります。
  • ROUGE-L: 生成されたテキストと参照テキストの間の L-グラム(L個の連続した単語)の重複。

テキストの要約とドキュメントの比較は、特にテキストの一貫性と関連性が重要なシナリオにおいて、ROUGE に最適なユース ケースの 1 つです。

コサイン類似度は、モデル出力や参照テキストなどの 2 つのテキスト埋め込みがどの程度厳密に一致しているかを測定し、それらの間のセマンティック類似性を評価するのに役立ちます。 他のモデル ベースのエバリュエータと同じように、評価に使用するモデル デプロイを提供する必要があります。

Von Bedeutung

このエバリュエータでは、埋め込みモデルのみがサポートされています。

  • text-embedding-3-small
  • text-embedding-3-large
  • text-embedding-ada-002

カスタム プロンプト

モデルを使用して、出力を指定されたラベルのセットに分類します。 このエバリュエータは、定義する必要があるカスタム プロンプトを使用します。

カスタム プロンプトのテスト条件のスクリーンショット。