

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# retrieve-and-generate RAG 評価ジョブのプロンプトデータセットの作成
<a name="knowledge-base-evaluation-prompt-retrieve-generate"></a>

retrieve-and-generate 評価ジョブには、JSON Lines 形式を使用したプロンプトデータセットが必要です。データセットには最大 1000 個のプロンプトを含めることができます

## Amazon Bedrock がナレッジベースを呼び出す retrieve-and-generate 評価ジョブのデータセットを準備する
<a name="knowledge-base-evaluation-prompt-retrieve-generate-invoke"></a>

Amazon Bedrock がナレッジベースを呼び出す取得のみの評価ジョブを作成するには、プロンプトデータセットに次のキーと値のペアが含まれている必要があります。
+ `referenceResponses` – この親キーは、[https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_RetrieveAndGenerate.html](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_RetrieveAndGenerate.html) から返される予定のグラウンドトゥルース応答を指定するために使用されます。グラウンドトゥルースは `text` キーに指定します。`referenceResponses` は、評価ジョブで**コンテキストカバレッジ**メトリクスを選択した場合に必要です。
+ `prompt` – この親キーは、評価ジョブの実行中にモデルが応答するプロンプト (ユーザークエリ) を指定するために使用されます。

以下は、6 つの入力を含み、JSON Lines 形式を使用するカスタムデータセットの例です。

```
{"conversationTurns":[{"prompt":{"content":[{"text":{{"Provide the prompt you want to use during inference"}}}]},"referenceResponses":[{"content":[{"text":{{"Specify a ground-truth response"}}}]}]}]}
{"conversationTurns":[{"prompt":{"content":[{"text":{{"Provide the prompt you want to use during inference"}}}]},"referenceResponses":[{"content":[{"text":{{"Specify a ground-truth response"}}}]}]}]}
{"conversationTurns":[{"prompt":{"content":[{"text":{{"Provide the prompt you want to use during inference"}}}]},"referenceResponses":[{"content":[{"text":{{"Specify a ground-truth response"}}}]}]}]}
{"conversationTurns":[{"prompt":{"content":[{"text":{{"Provide the prompt you want to use during inference"}}}]},"referenceResponses":[{"content":[{"text":{{"Specify a ground-truth response"}}}]}]}]}
{"conversationTurns":[{"prompt":{"content":[{"text":{{"Provide the prompt you want to use during inference"}}}]},"referenceResponses":[{"content":[{"text":{{"Specify a ground-truth response"}}}]}]}]}
{"conversationTurns":[{"prompt":{"content":[{"text":{{"Provide the prompt you want to use during inference"}}}]},"referenceResponses":[{"content":[{"text":{{"Specify a ground-truth response"}}}]}]}]}
```

次のプロンプトは、わかりやすいように展開されています。実際のプロンプトデータセットでは、各行 (プロンプト) が有効な JSON オブジェクトである必要があります。

```
{
    "conversationTurns": [
        {
            "prompt": {
                "content": [
                    {
                        "text": "What is the recommended service interval for your product?"
                    }
                ]
            },
            "referenceResponses": [
                {
                    "content": [
                        {
                            "text": "The recommended service interval for our product is two years."
                        }
                    ]
                }
            ]
        }
    ]
}
```

## 独自の推論レスポンスデータを使用して retrieve-and-generate 評価ジョブのデータセットを準備する
<a name="knowledge-base-evaluation-prompt-retrieve-generate-byoir"></a>

独自の推論レスポンスデータを指定する retrieve-and-generate 評価ジョブを作成する場合、プロンプトデータセットは会話のターンのリストであり、ターンごとに以下が含まれます。1 つのジョブで評価できる RAG ソースは 1 つだけです。
+ `prompt` – 結果を生成するためにモデルに指定したプロンプト。
+ `referenceResponses` – この親キーは、取得結果と入力クエリが取り込まれた後の LLM からの最終出力として予想されるグラウンドトゥルース応答を指定するために使用されます。
+ `referenceContexts` (オプション) – このオプションの親キーは、RAG ソースから取得される予定のグラウンドトゥルース文章を指定するために使用されます。このキーは、独自のカスタム評価メトリクスで使用する場合にのみ含める必要があります。Amazon Bedrock が提供する組み込みメトリクスは、このプロパティを使用しません。
+ `output` – RAG ソースからの出力。以下で構成されます。
  + `text` — RAG システムの LLM からの最終出力。
  + `retrievedPassages` – この親キーは、RAG ソースが取得したコンテンツを指定するために使用されます。

`output` データには、推論レスポンスの生成に使用した RAG ソースを定義する文字列 `knowledgeBaseIdentifier` も含まれている必要があります。使用した LLM を識別するオプションの `modelIdentifier` 文字列を含めることもできます。`retrievalResults` および `retrievedReferences` では、オプションの名前とメタデータを指定できます。

以下は、6 つの入力を含み、JSON Lines 形式を使用するカスタムデータセットの例です。

```
{"conversationTurns":[{"prompt":{"content":[{"text":"Provide the prompt you used to generate the response"}]},"referenceResponses":[{"content":[{"text":"A ground truth for the final response generated by the LLM"}]}],"referenceContexts":[{"content":[{"text":"A ground truth for a received passage"}]}],"output":{"text":"The output of the LLM","modelIdentifier":"(Optional) a string identifying your model","knowledgeBaseIdentifier":"A string identifying your RAG source","retrievedPassages":{"retrievalResults":[{"name":"(Optional) a name for your retrieval","content":{"text":"The retrieved content"},"metadata":{"(Optional) a key for your metadata":"(Optional) a value for your metadata"}}]}}}]}
{"conversationTurns":[{"prompt":{"content":[{"text":"Provide the prompt you used to generate the response"}]},"referenceResponses":[{"content":[{"text":"A ground truth for the final response generated by the LLM"}]}],"referenceContexts":[{"content":[{"text":"A ground truth for a received passage"}]}],"output":{"text":"The output of the LLM","modelIdentifier":"(Optional) a string identifying your model","knowledgeBaseIdentifier":"A string identifying your RAG source","retrievedPassages":{"retrievalResults":[{"name":"(Optional) a name for your retrieval","content":{"text":"The retrieved content"},"metadata":{"(Optional) a key for your metadata":"(Optional) a value for your metadata"}}]}}}]}
{"conversationTurns":[{"prompt":{"content":[{"text":"Provide the prompt you used to generate the response"}]},"referenceResponses":[{"content":[{"text":"A ground truth for the final response generated by the LLM"}]}],"referenceContexts":[{"content":[{"text":"A ground truth for a received passage"}]}],"output":{"text":"The output of the LLM","modelIdentifier":"(Optional) a string identifying your model","knowledgeBaseIdentifier":"A string identifying your RAG source","retrievedPassages":{"retrievalResults":[{"name":"(Optional) a name for your retrieval","content":{"text":"The retrieved content"},"metadata":{"(Optional) a key for your metadata":"(Optional) a value for your metadata"}}]}}}]}
{"conversationTurns":[{"prompt":{"content":[{"text":"Provide the prompt you used to generate the response"}]},"referenceResponses":[{"content":[{"text":"A ground truth for the final response generated by the LLM"}]}],"referenceContexts":[{"content":[{"text":"A ground truth for a received passage"}]}],"output":{"text":"The output of the LLM","modelIdentifier":"(Optional) a string identifying your model","knowledgeBaseIdentifier":"A string identifying your RAG source","retrievedPassages":{"retrievalResults":[{"name":"(Optional) a name for your retrieval","content":{"text":"The retrieved content"},"metadata":{"(Optional) a key for your metadata":"(Optional) a value for your metadata"}}]}}}]}
{"conversationTurns":[{"prompt":{"content":[{"text":"Provide the prompt you used to generate the response"}]},"referenceResponses":[{"content":[{"text":"A ground truth for the final response generated by the LLM"}]}],"referenceContexts":[{"content":[{"text":"A ground truth for a received passage"}]}],"output":{"text":"The output of the LLM","modelIdentifier":"(Optional) a string identifying your model","knowledgeBaseIdentifier":"A string identifying your RAG source","retrievedPassages":{"retrievalResults":[{"name":"(Optional) a name for your retrieval","content":{"text":"The retrieved content"},"metadata":{"(Optional) a key for your metadata":"(Optional) a value for your metadata"}}]}}}]}
{"conversationTurns":[{"prompt":{"content":[{"text":"Provide the prompt you used to generate the response"}]},"referenceResponses":[{"content":[{"text":"A ground truth for the final response generated by the LLM"}]}],"referenceContexts":[{"content":[{"text":"A ground truth for a received passage"}]}],"output":{"text":"The output of the LLM","modelIdentifier":"(Optional) a string identifying your model","knowledgeBaseIdentifier":"A string identifying your RAG source","retrievedPassages":{"retrievalResults":[{"name":"(Optional) a name for your retrieval","content":{"text":"The retrieved content"},"metadata":{"(Optional) a key for your metadata":"(Optional) a value for your metadata"}}]}}}]}
```

以下は、わかりやすいように展開されたプロンプトデータセット形式を示しています。実際のプロンプトデータセットでは、各行 (プロンプト) が有効な JSON オブジェクトである必要があります。

```
{
    "conversationTurns": [
        {
            "prompt": {
                "content": [
                    {
                        "text": "Provide the prompt you used to generate the responses"
                    }
                ]
            },
            "referenceResponses": [
                {
                    "content": [
                        {
                            "text": "A ground truth for the final response generated by the LLM"
                        }
                    ]
                }
            ],
            "referenceContexts": [
                {
                    "content": [
                        {
                            "text": "A ground truth for a received passage"
                        }
                    ]
                }
            ],
            "output": {
                "text": "The output of the LLM",
                "modelIdentifier": "(Optional) a string identifying your model",
                "knowledgeBaseIdentifier": "A string identifying your RAG source",
                "retrievedPassages": {
                    "retrievalResults": [
                        {
                            "name": "(Optional) a name for your retrieval",
                            "content": {
                                "text": "The retrieved content"
                            },
                            "metadata": {
                                "(Optional) a key for your metadata": "(Optional) a value for your metadata"
                            }
                        }
                    ]
                }
            }
        }
    ]
}
```