[アップデート] Amazon Bedrock の RAG Evaluation 機能が一般提供されました
こんにちは!クラウド事業本部コンサルティング部のたかくに(@takakuni_)です。
Amazon Bedrock の RAG Evaluation 機能が一般提供されました
Amazon Bedrock の RAG Evaluation
Amazon Bedrock の RAG Evaluation は RAG の性能を評価するための機能です。
RAG に対して、以下のような想定する質問と期待する回答のセットをデータセットとして用意し、期待した回答に沿っているか評価する機能です。
{"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"}]}]}]}
図にすると、次のような動きになります。
re:Invent 2024 の時は Amazon Knowledge bases の RAG Evaluation 機能としてリリースされていました。が、Amazon Bedrock の RAG Evaluation に名前が変わっていますね。
Bring your own inference responses
実は一般提供に際して、新たに Bring your own inference responses
というオプションが追加されました。
Brand new - more flexibility! As of today, in addition to Bedrock Knowledge Bases, Amazon Bedrock’s RAG evaluations supports custom RAG pipeline evaluations. Customers evaluating custom RAG pipelines can now bring their input-output pairs and retrieved contexts into the evaluation job directly in their input dataset, enabling them to bypass the call to a Bedrock Knowledge Base ("bring your own inference responses"). We also added citation precision and citation coverage metrics for Bedrock Knowledge Bases evaluation. If you use a Bedrock Knowledge Base as part of your evaluation, you can incorporate Amazon Bedrock Guardrails directly.
これは、従来のデータセットに必要だった質問する内容と期待する回答に加えて、RAG が生成した結果とモデル ID(識別できればなんでもOK)をデータセットのキーに加えて判定を行う機能です。これにより、RAG の応答と評価を疎結合にできる機能です。
疎結合にすることで、特定のフォーマットに従えば、Amazon Bedrock Knowledge bases 以外の RAG の応答結果も RAG Evalutaion で評価できるようになります。
このように共通の仕組みで複数の RAG システムを評価できるようになったのは嬉しいのではないでしょうか。
たとえば、Amazon Bedrock Knowledge bases 以外の身近な RAG として、Amazon Q Business が挙げられますね。
特定のデータフォーマット
先ほど、「特定のフォーマットに従えば、Amazon Bedrock Knowledge bases 以外の RAG の応答結果も RAG Evalutaion で評価できる」と説明しました。
具体的には以下のデータフォーマットに従う必要があります。(実際には JSON Lines フォーマットに従う必要があります。)
output キーが追加の対象ですね。
検索結果のみ評価する場合
{
"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."
}
]
}
],
+ "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"
+ }
+ }
+ ]
+ }
+ }
}
]
}
検索および回答を評価する場合
{
"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"
}
]
}
],
+ "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"
+ }
+ }
+ ]
+ },
+ "citations": [
+ {
+ "generatedResponsePart": {
+ "textResponsePart": {
+ "span": {
+ "start": start number,
+ "end": end number
+ },
+ "text": "The generated response"
+ }
+ },
+ "retrievedReferences": [
+ {
+ "name": "(Optional) a name for your reference",
+ "content": {
+ "text": "A retrieved reference"
+ },
+ "metadata": {
+ "(Optional) a key for your metadata": "(Optional) a value for your metadata"
+ }
+ }
+ ]
+ }
+ ]
+ }
}
]
}
それ以外は従来の RAG Evaluation で評価できそうです。
まとめ
以上、「Amazon Bedrock の RAG Evaluation 機能が一般提供されました」でした。
機会があれば、別のエントリで Amazon Q Business の評価を RAG Evaluation で評価できればと思いました。
このブログがどなたかの参考になれば幸いです。クラウド事業本部コンサルティング部のたかくに(@takakuni_)でした!