

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 了解模型评测作业的结果
<a name="clarify-foundation-model-evaluate-results"></a>

通过以下章节了解如何解释模型评测作业的结果。自动和人工模型评测作业保存在 Amazon S3 中的输出 JSON 数据各不相同。您可以使用 Studio 在 Amazon S3 中找到作业结果的保存位置。为此，请在 Studio 中打开**模型评测**主页，然后从表格中选择作业。

## 在 Studio 中查看模型评测结果
<a name="model-evaluation-console-results"></a>

模型评测作业完成后，您可以使用以下步骤查看模型在您提供的数据集上的表现：

1. 从 Studio 导航窗格中选择**作业**，然后选择**模型评测**。

1. 在**模型评测**页面上，成功提交的作业会出现在列表中。列表包括任务名称、状态、模型名称、评估类型和创建日期。

1. 如果模型评测成功完成，您可以点击任务名称查看评估结果摘要。

1. 要查看人工分析报告，请选择要检查的作业名称。

有关解释模型评测结果的信息，请参阅要解释其结果的模型评测任务类型对应的主题：
+ [了解人工评估作业的结果](clarify-foundation-model-evaluate-results-human.md)
+ [了解自动评估作业的结果](clarify-foundation-model-evaluate-auto-ui-results.md)

# 了解人工评估作业的结果
<a name="clarify-foundation-model-evaluate-results-human"></a>

创建使用人工的模型评测任务时，您选择了一个或多个*指标类型*。当作业组成员在工作人员门户中评估响应时，他们的响应会保存在 `humanAnswers` json 对象中。这些响应的存储方式会根据创建任务时选择的指标类型而改变。

下文将解释这些差异并举例说明。

## JSON 输出参考
<a name="clarify-foundation-model-evaluate-results-human-ref"></a>

模型评测任务完成后，结果会以 JSON 文件的形式保存在 Amazon S3 中。JSON 对象包含三个高级节点 `humanEvaluationResult`、`inputRecord` 和 `modelResponses`。`humanEvaluationResult` 键是一个高级节点，包含分配给模型评测作业的工作团队的回复。`inputRecord` 键是一个高级节点，包含创建模型评测任务时提供给模型的提示。`modelResponses` 键是一个高级节点，包含对模型提示的回复。

下表总结了在模型评测任务的 JSON 输出中发现的键值对。

接下来的章节将详细介绍每个键值对。


****  

| 参数 | 示例 | 说明 | 
| --- | --- | --- | 
|  `flowDefinitionArn`  |  arn:aws:sagemaker:us-west-2:111122223333:flow-definition/flow-definition-name  |  创建人为循环的人工审核工作流程（流程定义）的 ARN。  | 
| humanAnswers |  与所选评估指标相关的 JSON 对象列表。要了解更多信息，请参阅 [在 `humanAnswers` 下找到的键值对](#clarify-foundation-model-evaluate-humanAnswers)。  |  包含工人响应的 JSON 对象列表。  | 
|  `humanLoopName`  | system-generated-hash | 系统生成的 40 个字符的十六进制字符串。 | 
| inputRecord |  <pre>"inputRecord": {<br />    "prompt": {<br />        "text": "Who invented the airplane?"<br />    },<br />    "category": "Airplanes",<br />    "referenceResponse": {<br />        "text": "Orville and Wilbur Wright"<br />    },<br />    "responses":<br /><br />        [{<br />            "modelIdentifier": "meta-textgeneration-llama-codellama-7b",<br />            "text": "The Wright brothers, Orville and Wilbur Wright are widely credited with inventing and manufacturing the world's first successful airplane."<br />        }]<br />}</pre>  | 一个 JSON 对象，包含来自输入数据集的输入提示。 | 
| modelResponses |  <pre>"modelResponses": [{<br />    "modelIdentifier": "arn:aws:bedrock:us-west-2::foundation-model/model-id",<br />    "text": "the-models-response-to-the-prompt"<br />}]</pre>  | 来自模型的各个响应。 | 
| inputContent | <pre>{<br />    "additionalDataS3Uri":"s3://user-specified-S3-URI-path/datasets/dataset-name/records/record-number/human-loop-additional-data.json",<br />    "evaluationMetrics":[<br />        {<br />		  "description":"brief-name",<br />		  "metricName":"metric-name",<br />		  "metricType":"IndividualLikertScale"<br />	  }<br />    ],<br />    "instructions":"example instructions"<br />}</pre> |  在 Amazon S3 存储桶中启动人工循环所需的人工循环输入内容。  | 
| modelResponseIdMap | <pre>{<br />   "0": "sm-margaret-meta-textgeneration-llama-2-7b-1711485008-0612",<br />   "1": "jumpstart-dft-hf-llm-mistral-7b-ins-20240327-043352"<br />}</pre> |  描述每个模型在 `answerContent` 中的表示方式。  | 

### `humanEvaluationResult` 下找到的键值对
<a name="clarify-foundation-model-evaluate-humanEvaluationResult"></a>

 在模型评测作业输出的 `humanEvaluationResult` 下可以找到以下键值对。

有关与 `humanAnswers` 相关的键值对，请参阅 [在 `humanAnswers` 下找到的键值对](#clarify-foundation-model-evaluate-humanAnswers)。

**`flowDefinitionArn`**
+ 用于完成模型评测任务的流量定义 ARN。
+ *示例*`arn:aws:sagemaker:us-west-2:111122223333:flow-definition/flow-definition-name`：

**`humanLoopName`**
+ 系统生成的 40 个字符的十六进制字符串。

**`inputContent`**
+ 此键值描述了*指标类型*，以及您在工人门户中为工人提供的说明。
  + `additionalDataS3Uri`：Amazon S3 中保存工人指令的位置。
  + `instructions`：您在工人门户网站上向工人提供的说明。
  + `evaluationMetrics`：指标名称及其说明。键值 `metricType` 是为工人提供的评估模型响应的工具。

**`modelResponseIdMap`**
+ 该键值对标识了所选模型的全名，以及工人选择如何映射到 `humanAnswers` 键值对中的模型。

### 在 `inputRecord` 下找到的键值对
<a name="clarify-foundation-model-evaluate-inputRecord"></a>

以下条目描述了 `inputRecord` 键值对。

**`prompt`**
+ 发送给模型的提示文本。

**`category`**
+ 对提示进行分类的可选类别。在模型评测期间，工人可在工人门户网站上看到。
+ *示例*`"American cities"`：

**`referenceResponse`**
+ 输入 JSON 中的一个可选字段，用于指定在评估过程中希望作业人员参考的基本事实

**`responses`**
+ 输入 JSON 中的一个可选字段，包含来自其他模型的响应。

一个 JSON 输入记录示例。

```
{
  "prompt": {
     "text": "Who invented the airplane?"
  },
  "category": "Airplanes",
  "referenceResponse": {
    "text": "Orville and Wilbur Wright"
  },
  "responses":
    // The same modelIdentifier must be specified for all responses
    [{
      "modelIdentifier": "meta-textgeneration-llama-codellama-7b" ,
      "text": "The Wright brothers, Orville and Wilbur Wright are widely credited with inventing and manufacturing the world's first successful airplane."
    }]
}
```

### 在 `modelResponses` 下找到的键值对
<a name="clarify-foundation-model-evaluate-modelResponses"></a>

键值对数组，其中包含来自模型的响应，以及提供响应的模型。

**`text`**
+ 模特对提示的回答。

**`modelIdentifier`**
+ 模型的名称。

### 在 `humanAnswers` 下找到的键值对
<a name="clarify-foundation-model-evaluate-humanAnswers"></a>

键值对数组，其中包含模型的响应，以及工人对模型的评估方式。

**`acceptanceTime`**
+ 当工人在工人门户网站上接受任务时。

**`submissionTime`**
+ 工人何时提交答复。

**`timeSpentInSeconds`**
+ 工人完成任务的时间。

**`workerId`**
+ 完成任务的工人的 ID。

**`workerMetadata`**
+ 有关哪个工作团队被指派执行该模型评测任务的元数据。

#### `answerContent`JSON 数组的格式
<a name="clarify-foundation-model-evaluate-humanAnswers-answerconent"></a>

答案的结构取决于创建模型评测任务时所选择的评估指标。每个工人的回复或回答都会记录在一个新的 JSON 对象中。

**`answerContent`**
+ `evaluationResults` 包含工人的回复。
  + 选择**选择按钮**时，每个工人的结果都是 `"evaluationResults": "comparisonChoice"`。

    `metricName`：指标的名称

    `result`：该 JSON 对象使用 `0` 或 `1` 表示工人选择了哪个模型。要查看模型映射到哪个值，请使用 `modelResponseIdMap`。
  + 当选择**李克特量表，比较**时，每个工人的结果为 `"evaluationResults": "comparisonLikertScale"`。

    `metricName`：指标的名称。

    `leftModelResponseId`：表示工人入口左侧显示的是哪个 `modelResponseIdMap`。

    `rightModelResponseId`：表示工人入口左侧显示的是哪个 `modelResponseIdMap`。

    `result`：该 JSON 对象使用 `0` 或 `1` 表示工人选择了哪个模型。要查看模型映射到哪个值，请使用 `modelResponseIdMap`。
  + 选择**顺序分级**时，每个工人的结果都是 `"evaluationResults": "comparisonRank"`。

    `metricName`：指标的名称

    `result`：一个 JSON 对象数组。对于每个模型 (`modelResponseIdMap`)，工人都会提供一个 `rank`。

    ```
    "result": [{
    	"modelResponseId": "0",
    	"rank": 1
    }, {
    	"modelResponseId": "1",
    	"rank": 1
    }]
    ```
  + 当选择**李克特量表，评估单一模型响应**时，工人的结果将保存在 `"evaluationResults": "individualLikertScale"` 中。这是一个 JSON 数组，包含创建作业时指定的 `metricName` 得分。

    `metricName`：指标的名称。

    `modelResponseId`：得分的模型。要查看模型映射到哪个值，请使用 `modelResponseIdMap`。

    `result`：键值对，表示工人选择的李克特量表值。
  + 选择**拇指向上/拇指向下**时，作业程序的结果会被保存为一个 JSON 数组 `"evaluationResults": "thumbsUpDown"`。

    `metricName`：指标的名称。

    `result`：与 `metricName` 有关的 `true` 或 `false`。当工人选择拇指向上时，`"result" : true`。

## 模型评测作业输出示例
<a name="clarify-foundation-model-evaluate-results-human-example"></a>

下面的 JSON 对象是一个保存在 Amazon S3 中的模型评测任务输出示例。要了解每个键值对的更多信息，请参阅 [JSON 输出参考](#clarify-foundation-model-evaluate-results-human-ref)。

为清楚起见，本作业只包含两名工人的回复。为便于阅读，某些键值对也可能被截断

```
{
	"humanEvaluationResult": {
		"flowDefinitionArn": "arn:aws:sagemaker:us-west-2:111122223333:flow-definition/flow-definition-name",
        "humanAnswers": [
            {
                "acceptanceTime": "2024-06-07T22:31:57.066Z",
                "answerContent": {
                    "evaluationResults": {
                        "comparisonChoice": [
                            {
                                "metricName": "Fluency",
                                "result": {
                                    "modelResponseId": "0"
                                }
                            }
                        ],
                        "comparisonLikertScale": [
                            {
                                "leftModelResponseId": "0",
                                "metricName": "Coherence",
                                "result": 1,
                                "rightModelResponseId": "1"
                            }
                        ],
                        "comparisonRank": [
                            {
                                "metricName": "Toxicity",
                                "result": [
                                    {
                                        "modelResponseId": "0",
                                        "rank": 1
                                    },
                                    {
                                        "modelResponseId": "1",
                                        "rank": 1
                                    }
                                ]
                            }
                        ],
                        "individualLikertScale": [
                            {
                                "metricName": "Correctness",
                                "modelResponseId": "0",
                                "result": 2
                            },
                            {
                                "metricName": "Correctness",
                                "modelResponseId": "1",
                                "result": 3
                            },
                            {
                                "metricName": "Completeness",
                                "modelResponseId": "0",
                                "result": 1
                            },
                            {
                                "metricName": "Completeness",
                                "modelResponseId": "1",
                                "result": 4
                            }
                        ],
                        "thumbsUpDown": [
                            {
                                "metricName": "Accuracy",
                                "modelResponseId": "0",
                                "result": true
                            },
                            {
                                "metricName": "Accuracy",
                                "modelResponseId": "1",
                                "result": true
                            }
                        ]
                    }
                },
                "submissionTime": "2024-06-07T22:32:19.640Z",
                "timeSpentInSeconds": 22.574,
                "workerId": "ead1ba56c1278175",
                "workerMetadata": {
                    "identityData": {
                        "identityProviderType": "Cognito",
                        "issuer": "https://cognito-idp.us-west-2.amazonaws.com/us-west-2_WxGLvNMy4",
                        "sub": "cd2848f5-6105-4f72-b44e-68f9cb79ba07"
                    }
                }
            },
            {
                "acceptanceTime": "2024-06-07T22:32:19.721Z",
                "answerContent": {
                    "evaluationResults": {
                        "comparisonChoice": [
                            {
                                "metricName": "Fluency",
                                "result": {
                                    "modelResponseId": "1"
                                }
                            }
                        ],
                        "comparisonLikertScale": [
                            {
                                "leftModelResponseId": "0",
                                "metricName": "Coherence",
                                "result": 1,
                                "rightModelResponseId": "1"
                            }
                        ],
                        "comparisonRank": [
                            {
                                "metricName": "Toxicity",
                                "result": [
                                    {
                                        "modelResponseId": "0",
                                        "rank": 2
                                    },
                                    {
                                        "modelResponseId": "1",
                                        "rank": 1
                                    }
                                ]
                            }
                        ],
                        "individualLikertScale": [
                            {
                                "metricName": "Correctness",
                                "modelResponseId": "0",
                                "result": 3
                            },
                            {
                                "metricName": "Correctness",
                                "modelResponseId": "1",
                                "result": 4
                            },
                            {
                                "metricName": "Completeness",
                                "modelResponseId": "0",
                                "result": 1
                            },
                            {
                                "metricName": "Completeness",
                                "modelResponseId": "1",
                                "result": 5
                            }
                        ],
                        "thumbsUpDown": [
                            {
                                "metricName": "Accuracy",
                                "modelResponseId": "0",
                                "result": true
                            },
                            {
                                "metricName": "Accuracy",
                                "modelResponseId": "1",
                                "result": false
                            }
                        ]
                    }
                },
                "submissionTime": "2024-06-07T22:32:57.918Z",
                "timeSpentInSeconds": 38.197,
                "workerId": "bad258db224c3db6",
                "workerMetadata": {
                    "identityData": {
                        "identityProviderType": "Cognito",
                        "issuer": "https://cognito-idp.us-west-2.amazonaws.com/us-west-2_WxGLvNMy4",
                        "sub": "84d5194a-3eed-4ecc-926d-4b9e1b724094"
                    }
                }
            }
        ],
        "humanLoopName": "a757 11d3e75a 8d41f35b9873d 253f5b7bce0256e",
        "inputContent": {
            "additionalDataS3Uri": "s3://mgrt-test-us-west-2/test-2-workers-2-model/datasets/custom_dataset/0/task-input-additional-data.json",
            "instructions": "worker instructions provided by the model evaluation job administrator",
            "evaluationMetrics": [
                {
                    "metricName": "Fluency",
                    "metricType": "ComparisonChoice",
                    "description": "Measures the linguistic quality of a generated text."
                },
                {
                    "metricName": "Coherence",
                    "metricType": "ComparisonLikertScale",
                    "description": "Measures the organization and structure of a generated text."
                },
                {
                    "metricName": "Toxicity",
                    "metricType": "ComparisonRank",
                    "description": "Measures the harmfulness of a generated text."
                },
                {
                    "metricName": "Accuracy",
                    "metricType": "ThumbsUpDown",
                    "description": "Indicates the accuracy of a generated text."
                },
                {
                    "metricName": "Correctness",
                    "metricType": "IndividualLikertScale",
                    "description": "Measures a generated answer's satisfaction in the context of the question."
                },
                {
                    "metricName": "Completeness",
                    "metricType": "IndividualLikertScale",
                    "description": "Measures a generated answer's inclusion of all relevant information."
                }
            ],
            "disableRandomization": "true"
        },
        "modelResponseIdMap": {
            "0": "sm-margaret-meta-textgeneration-llama-2-7b-1711485008-0612",
            "1": "jumpstart-dft-hf-llm-mistral-7b-ins-20240327-043352"
        }
    },
    "inputRecord": {
        "prompt": {
            "text": "What is high intensity interval training?"
        },
        "category": "Fitness",
        "referenceResponse": {
            "text": "High-Intensity Interval Training (HIIT)"
        }
    },
    "modelResponses": [
        {
            "text": "High Intensity Interval Training (HIIT) is a form of exercise that alternates between periods of high intensity work and low intensity recovery.HIIT is an excellent way to increase your fitness and improve your health, but it can be difficult to get started.In this article, we will",
            "modelIdentifier": "sm-margaret-meta-textgeneration-llama-2-7b-1711485008-0612"
        },
        {
            "text": "High intensity interval training is a form of exercise consisting of short bursts of maximum effort followed by periods of rest. The theory behind HIIT is that it can often be more effective at improving cardiovascular and metabolic health than longer, lower intensity workouts.The work intervals can range in length depending on the specific type of exercise, but are typically between 20 and 90 seconds. The recovery periods are generally longer, lasting between 1 and 5 minutes. This pattern is then repeated for multiple sets.\n\nSince the work intervals are high intensity, they require more effort from your body and therefore result in a greater calorie burn. The body also continues to burn calories at an increased rate after the workout due to an effect called excess post exercise oxygen consumption (EPOC), also know as the afterburn effect.\n\nHIIT is a versatile form of training that can be adapted to different fitness levels and can be performed using a variety of exercises including cycling, running, bodyweight movements, and even swimming. It can be done in as little as 20 minutes once or twice a week, making it an efficient option for busy individuals.\n\nWhat are the benefits of high intensity interval training",
            "modelIdentifier": "jumpstart-dft-hf-llm-mistral-7b-ins-20240327-043352"
        }
    ]
}
```

# 了解自动评估作业的结果
<a name="clarify-foundation-model-evaluate-auto-ui-results"></a>

自动模型评测作业完成后，结果会保存在 Amazon S3 中。下文将介绍生成的文件以及如何解释这些文件。

## 解读 `output.json` 文件结构
<a name="clarify-foundation-model-evaluate-auto-ui-results-json"></a>

`output.json` 文件包含所选数据集和指标的综合得分。

输出示例如下

```
{
    "evaluations": [{
        "evaluation_name": "factual_knowledge",
        "dataset_name": "trex",
		## The structure of the prompt template changes based on the foundation model selected
		"prompt_template": "<s>[INST] <<SYS>>Answer the question at the end in as few words as possible. Do not repeat the question. Do not answer in complete sentences.<</SYS> Question: $feature [/INST]",
        "dataset_scores": [{
            "name": "factual_knowledge",
            "value": 0.2966666666666667
        }],
        "category_scores": [{
                "name": "Author",
                "scores": [{
                    "name": "factual_knowledge",
                    "value": 0.4117647058823529
                }]
            },
				....
            {
                "name": "Capitals",
                "scores": [{
                    "name": "factual_knowledge",
                    "value": 0.2857142857142857
                }]
            }
        ]
    }]
}
```

## 解读实例结果文件的结构
<a name="clarify-foundation-model-evaluate-auto-ui-results-jsonl"></a>

一个 *evaluation\$1name* \$1 *dataset\$1name* .jsonl 文件，其中包含每个 jsonlines 请求的实例化结果。如果您的 jsonlines 输入数据中有 `300` 请求，则此 jsonlines 输出文件包含 `300` 响应。输出文件包含对您的模型提出的请求，以及该评估的得分。整个实例的输出示例如下。

## 解读报告
<a name="clarify-foundation-model-evaluate-auto-ui-results-report"></a>

**评估报告**包含基础模型评测作业的结果。评估报告的内容取决于您用来评估模型的任务类型。每份报告都包含以下部分：

1. 评估任务下每次成功评估的**总分**。以一个数据集的评估为例，如果您对分类任务中的模型进行了准确性和语义鲁棒性评估，那么您的报告顶部就会出现一个汇总准确性和准确性语义鲁棒性评估结果的表格。使用其他数据集进行的其他评估可能采用不同的结构。

1. 评估作业的配置，包括模型名称、类型、使用的评估方法以及评估模型所依据的数据集。

1. **详细评估结果**部分总结了评估算法，提供了有关任何内置数据集的信息和链接、得分的计算方法，并用表格显示了一些样本数据及其相关得分。

1. **未完成的评估**部分包含未完成评估的列表。如果没有评估未完成，则省略报告的这一部分。