

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# Amazon Bedrock에서 RAG 평가를 위한 프롬프트 데이터세트 생성
<a name="knowledge-base-evaluation-prompt"></a>

Amazon Bedrock Knowledge Base 또는 자체 검색 증강 생성(RAG) 시스템에 대한 검색 및 생성을 평가하려면 프롬프트 데이터세트를 제공합니다. 자체 RAG 시스템에서 응답 데이터를 제공하면 Amazon Bedrock은 지식 기반 간접 호출 단계를 건너뛰고 데이터에 대한 평가 작업을 직접 수행합니다.

프롬프트 데이터세트는 Amazon S3에 저장해야 하며, JSON 라인 형식을 사용하고 `.jsonl` 파일 확장자를 사용해야 합니다. 각 줄은 유효한 JSON 객체여야 합니다. 평가 작업당 데이터세트에 최대 1,000개의 프롬프트가 있을 수 있습니다. 검색 및 생성 작업의 경우 각 대화의 최대 회전 수는 5입니다. 검색 전용 평가의 경우 한 번만 지정할 수 있습니다.

콘솔을 사용하여 생성한 작업의 경우 S3 버킷에서 Cross Origin Resource Sharing(CORS) 구성을 업데이트해야 합니다. 필수 CORS 권한에 대해 알아보려면 [S3 버킷에 대한 필수 Cross Origin Resource Sharing(CORS) 권한](model-evaluation-security-cors.md) 섹션을 참조하세요.

선택한 평가 작업 유형에 따라 필요한 키 값 쌍에 대해 자세히 알아보려면 다음 주제를 참조하세요.

**Topics**
+ [검색 전용 RAG 평가 작업을 위한 프롬프트 데이터세트 생성](knowledge-base-evaluation-prompt-retrieve.md)
+ [RAG 평가 작업 검색 및 생성을 위한 프롬프트 데이터세트 생성](knowledge-base-evaluation-prompt-retrieve-generate.md)

# 검색 전용 RAG 평가 작업을 위한 프롬프트 데이터세트 생성
<a name="knowledge-base-evaluation-prompt-retrieve"></a>

검색 전용 평가 작업에는 JSON 라인 형식을 사용하는 프롬프트 데이터세트가 필요합니다. 데이터세트에 최대 1,000개의 프롬프트를 포함할 수 있습니다.

## Amazon Bedrock이 지식 기반을 호출하는 검색 전용 평가 작업을 위한 데이터세트 준비
<a name="knowledge-base-evaluation-prompt-retrieve-invoke"></a>

Amazon Bedrock이 지식 기반을 호출하는 검색 전용 평가 작업을 생성하려면 프롬프트 데이터세트에 다음 키-값 페어가 포함되어야 합니다.
+ `referenceResponses` - 이 상위 키는 종단 간 RAG 시스템이 반환할 것으로 예상되는 실측 응답을 지정하는 데 사용됩니다. 이 파라미터는 지식 기반에서 검색될 것으로 예상되는 구절 또는 청크를 나타내지 않습니다. `text` 키에 실측 정보를 지정합니다. 평가 작업에서 **컨텍스트 적용 범위** 지표를 선택하는 경우 `referenceResponses`가 필요합니다.
+ `prompt` - 이 상위 키는 RAG 시스템이 응답할 프롬프트(사용자 쿼리)를 지정하는 데 사용됩니다.

다음은 6개의 입력이 포함되고 JSON 라인 형식을 사용하는 사용자 지정 데이터세트의 예제입니다.

```
{"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."
                        }
                    ]
                }
            ]
        }
    ]
}
```

## 자체 추론 응답 데이터를 사용하여 검색 전용 평가 작업을 위한 데이터세트 준비
<a name="knowledge-base-evaluation-prompt-retrieve-byoir"></a>

자체 추론 응답 데이터를 제공하는 검색 전용 평가 작업을 생성하려면 프롬프트 데이터세트에 다음이 포함되어야 합니다.
+ `prompt` - 이 상위 키는 추론 응답 데이터를 생성하는 데 사용한 프롬프트(사용자 쿼리)를 지정하는 데 사용됩니다.
+ `referenceResponses` - 이 상위 키는 종단 간 RAG 시스템이 반환할 것으로 예상되는 실측 응답을 지정하는 데 사용됩니다. 이 파라미터는 지식 기반에서 검색할 것으로 예상되는 구절 또는 청크를 나타내지 않습니다. `text` 키에 실측 정보를 지정합니다. 평가 작업에서 **컨텍스트 적용 범위** 지표를 선택하는 경우 `referenceResponses`가 필요합니다.
+ `referenceContexts`(선택 사항) - 이 선택적 상위 키는 RAG 소스에서 검색할 것으로 예상되는 실측 구절을 지정하는 데 사용됩니다. 이 키를 사용자 지정 평가 지표에 사용하려면 이 키만 포함하면 됩니다. Amazon Bedrock에서 제공하는 기본 제공 지표는 이 속성을 사용하지 않습니다.
+ `knowledgeBaseIdentifier` - 검색 결과를 생성하는 데 사용되는 RAG 소스를 식별하는 고객 정의 문자열입니다.
+ `retrievedResults` - 검색 결과 목록이 있는 JSON 객체입니다. 각 결과에 대해 키-값 쌍으로 지정된 선택적 `name` 및 `metadata`를 제공할 수 있습니다.

다음은 6개의 입력이 포함되고 JSON 라인 형식을 사용하는 사용자 지정 데이터세트의 예제입니다.

```
{"conversationTurns":[{"prompt":{"content":[{"text":"The prompt you used to generate your response"}]},"referenceResponses":[{"content":[{"text":"A ground-truth response"}]}],"referenceContexts":[{"content":[{"text":"A ground truth for a received passage"}]}],"output":{"knowledgeBaseIdentifier":"A string identifying your RAG source","retrievedResults":{"retrievalResults":[{"name":"(Optional) a name for your reference context","content":{"text":"The output from your RAG inference"},"metadata":{"(Optional) a key for your metadata":"(Optional) a metadata value"}}]}}}]}
{"conversationTurns":[{"prompt":{"content":[{"text":"The prompt you used to generate your response"}]},"referenceResponses":[{"content":[{"text":"A ground-truth response"}]}],"referenceContexts":[{"content":[{"text":"A ground truth for a received passage"}]}],"output":{"knowledgeBaseIdentifier":"A string identifying your RAG source","retrievedResults":{"retrievalResults":[{"name":"(Optional) a name for your reference context","content":{"text":"The output from your RAG inference"},"metadata":{"(Optional) a key for your metadata":"(Optional) a metadata value"}}]}}}]}
{"conversationTurns":[{"prompt":{"content":[{"text":"The prompt you used to generate your response"}]},"referenceResponses":[{"content":[{"text":"A ground-truth response"}]}],"referenceContexts":[{"content":[{"text":"A ground truth for a received passage"}]}],"output":{"knowledgeBaseIdentifier":"A string identifying your RAG source","retrievedResults":{"retrievalResults":[{"name":"(Optional) a name for your reference context","content":{"text":"The output from your RAG inference"},"metadata":{"(Optional) a key for your metadata":"(Optional) a metadata value"}}]}}}]}
{"conversationTurns":[{"prompt":{"content":[{"text":"The prompt you used to generate your response"}]},"referenceResponses":[{"content":[{"text":"A ground-truth response"}]}],"referenceContexts":[{"content":[{"text":"A ground truth for a received passage"}]}],"output":{"knowledgeBaseIdentifier":"A string identifying your RAG source","retrievedResults":{"retrievalResults":[{"name":"(Optional) a name for your reference context","content":{"text":"The output from your RAG inference"},"metadata":{"(Optional) a key for your metadata":"(Optional) a metadata value"}}]}}}]}
{"conversationTurns":[{"prompt":{"content":[{"text":"The prompt you used to generate your response"}]},"referenceResponses":[{"content":[{"text":"A ground-truth response"}]}],"referenceContexts":[{"content":[{"text":"A ground truth for a received passage"}]}],"output":{"knowledgeBaseIdentifier":"A string identifying your RAG source","retrievedResults":{"retrievalResults":[{"name":"(Optional) a name for your reference context","content":{"text":"The output from your RAG inference"},"metadata":{"(Optional) a key for your metadata":"(Optional) a metadata value"}}]}}}]}
{"conversationTurns":[{"prompt":{"content":[{"text":"The prompt you used to generate your response"}]},"referenceResponses":[{"content":[{"text":"A ground-truth response"}]}],"referenceContexts":[{"content":[{"text":"A ground truth for a received passage"}]}],"output":{"knowledgeBaseIdentifier":"A string identifying your RAG source","retrievedResults":{"retrievalResults":[{"name":"(Optional) a name for your reference context","content":{"text":"The output from your RAG inference"},"metadata":{"(Optional) a key for your metadata":"(Optional) a metadata value"}}]}}}]}
```

명확성을 위해 다음 프롬프트가 확장되었습니다. 실제 프롬프트 데이터세트에서 각 줄(프롬프트)은 유효한 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."
            }
          ]
        }
      ],
      "referenceContexts": [
        {
          "content": [
            {
              "text": "A ground truth for a received passage"
            }
          ]
        }
      ],
       "output": {
        "knowledgeBaseIdentifier": "RAG source 1",
        "retrievedResults": {
          "retrievalResults": [
            {
              "name": "(Optional) a name for your retrieval",
              "content": {
                "text": "The recommended service interval for our product is two years."
              },
              "metadata": {
                "(Optional) a key for your metadata": "(Optional) a value for your metadata"
              }
            }
          ]
        }
      }
    }
  ]
}
```

# RAG 평가 작업 검색 및 생성을 위한 프롬프트 데이터세트 생성
<a name="knowledge-base-evaluation-prompt-retrieve-generate"></a>

검색 및 생성 평가 작업에는 JSON 라인 형식을 사용하는 프롬프트 데이터세트가 필요합니다. 데이터세트에 최대 1,000개의 프롬프트를 포함할 수 있습니다

## Amazon Bedrock이 지식 기반을 호출하는 검색 및 생성 평가 작업을 위한 데이터세트 준비
<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 라인 형식을 사용하는 사용자 지정 데이터세트의 예제입니다.

```
{"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."
                        }
                    ]
                }
            ]
        }
    ]
}
```

## 자체 추론 응답 데이터를 사용하여 검색 및 생성 평가 작업을 위한 데이터세트 준비
<a name="knowledge-base-evaluation-prompt-retrieve-generate-byoir"></a>

자체 추론 응답 데이터를 제공하는 검색 및 생성 평가 작업을 생성하기 위해 프롬프트 데이터세트는 대화 턴 목록이며 각 턴에 대해 다음을 포함합니다. 작업당 하나의 RAG 소스만 평가할 수 있습니다.
+ `prompt` - 결과를 생성하기 위해 모델에 제공한 프롬프트입니다.
+ `referenceResponses` - 이 상위 키는 검색 결과 및 입력 쿼리를 수집한 후 LLM의 최종 출력에 대해 예상되는 실측 응답을 지정하는 데 사용됩니다.
+ `referenceContexts`(선택 사항) - 이 선택적 상위 키는 RAG 소스에서 검색할 것으로 예상되는 실측 구절을 지정하는 데 사용됩니다. 이 키를 사용자 지정 평가 지표에 사용하려면 이 키만 포함하면 됩니다. Amazon Bedrock에서 제공하는 기본 제공 지표는 이 속성을 사용하지 않습니다.
+ `output` - RAG 소스의 출력으로, 다음과 같이 구성됩니다.
  + `text` - RAG 시스템의 LLM에서 최종 출력입니다.
  + `retrievedPassages` - 이 상위 키는 RAG 소스가 검색한 콘텐츠를 지정하는 데 사용됩니다.

`output` 데이터에는 추론 응답을 생성하는 데 사용한 RAG 소스를 정의하는 `knowledgeBaseIdentifier` 문자열도 포함되어야 합니다. 사용한 LLM을 식별하는 선택적 `modelIdentifier` 문자열을 포함할 수도 있습니다. `retrievalResults` 및 `retrievedReferences`의 경우 선택적 이름과 메타데이터를 제공할 수 있습니다.

다음은 6개의 입력이 포함되고 JSON 라인 형식을 사용하는 사용자 지정 데이터세트의 예제입니다.

```
{"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"
                            }
                        }
                    ]
                }
            }
        }
    ]
}
```