[アップデート] Amazon Bedrock Knowledge bases の GraphRAG が一般提供を開始しました
こんにちは!クラウド事業本部コンサルティング部のたかくに(@takakuni_)です。
Amazon Bedrock Knowledge bases の GraphRAG が一般提供を開始しました。
AWS Blogs も公開されています。
Amazon Bedrock Knowledge bases の GraphRAG
Amazon Bedrock Knowledge bases の GraphRAG は re:Invent 2024 に登場した機能で、グラフデータベースに Amazon Neptune Analytics を用いて GraphRAG を実装する機能です。
通常のベクトル検索に加えて、ドキュメント間の関連性に関わる情報をグラフデータベース内に保存し、従来の RAG を拡張した機能になります。
アップデート内容
一般提供に際して、何か追加のアップデートがあったか調べてみましたが、とくに変化はなさそうでした。
ただ、商用利用可能になっただけでも非常に嬉しいですね。
サポートされているリージョンには、東京リージョンも含まれています。
GraphRAG is available in the following AWS Regions:
- Europe (Frankfurt)
- Europe (London)
- Europe (Ireland)
- US West (Oregon)
- US East (N. Virginia)
- Asia Pacific (Tokyo)
やってみた
今回は簡単にではありますが、 GpaphRAG を体験してみたいと思います。
利用するリージョン/モデルの情報は以下のとおりです。すでにモデル有効化は済んでいるとします。
- 東京リージョン
- エンべディングモデル:Titan Text Embeddingsv2, 1024 次元
- グラフ構築時に利用するモデル:Claude 3 Haiku
- 回答生成で利用するモデル:Claude 3.5 Sonnet v2
ナレッジベースの画面より、ナレッジベースを作成に移ります。
適宜、名前をつけデータソースには Amazon S3 を選択します。
執筆時点では GraphRAG の制約事項に、データソースは Amazon S3 のみサポートされている旨が記載されていました
GraphRAG only supports Amazon S3 as the data source.
ベクトルデータベースを選択します。Amazon Neptune Analytics (GraphRAG) - new
と記載されています。(Preview が外れていますね。)
ちなみに、作成したベクトルストアを選択
を選ぶと自身で作成した Neputune Analytics を選択できます。
作成を押して数分待つと、ステータスが利用可能な、ナレッジベースが作成できました。
S3 には次の 3 つのファイルをアップロードしました。
Example Corp はウィジェットを販売している
イギリスは最大のウィジェット市場である
ウィジェットは中国からイギリスに出荷されている
イギリスの港で遅延が発生している
数十秒ほどで同期が完了しました。
Amazon Bedrock のモデル実行ログをみてみました。グラフ化は次のように行われていました。
- モデルが利用可能かどうかのチェック(同期の初回に実行)
- グラフの構築(繰り返し実行)
モデルが利用可能かどうかのチェック
Anthropic Claude Haiku 3 に対して、Bedrock Knowledge Base verifying access to requested model
とプロンプトを投げていますね。
{
"schemaType": "ModelInvocationLog",
"schemaVersion": "1.0",
"timestamp": "2025-03-09T08:14:09Z",
"accountId": "123456789012",
"identity": {
"arn": "arn:aws:sts::123456789012:assumed-role/AmazonBedrockExecutionRoleForKnowledgeBase_1dz6y/BKB-CP-EF1XBIB9ZO-HJkYjEKUNjMEpnA="
},
"region": "ap-northeast-1",
"requestId": "150a7e31-6736-47e3-a671-f520be4b599d",
"operation": "InvokeModel",
"modelId": "arn:aws:bedrock:ap-northeast-1::foundation-model/anthropic.claude-3-haiku-20240307-v1:0",
"input": {
"inputContentType": "application/json",
"inputBodyJson": {
"anthropic_version": "bedrock-2023-05-31",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Bedrock Knowledge Base verifying access to requested model"
}
]
}
],
"system": "",
"max_tokens": 2048,
"temperature": 0,
"top_p": 1,
"stop_sequences": [
"\nObservation"
],
"top_k": 50
},
"inputTokenCount": 18
},
"output": {
"outputContentType": "application/json",
"outputBodyJson": {
"id": "msg_bdrk_01DpL8fUg4o4FWNsHYWGgU7t",
"type": "message",
"role": "assistant",
"model": "claude-3-haiku-20240307",
"content": [
{
"type": "text",
"text": "I'm afraid I don't have access to any Bedrock Knowledge Base or models. I'm Claude, an AI assistant created by Anthropic to be helpful, harmless, and honest. I don't have the capability to verify access to any external knowledge bases or models. I can only respond based on the information and capabilities I was trained on by Anthropic. Please let me know if there is anything else I can assist with!"
}
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 18,
"output_tokens": 93
}
},
"outputTokenCount": 93
}
}
グラフの構築(繰り返し実行)
利用可能かどうかをチェックしたのち、グラフの構築に移ります。
対象のドキュメント部分について、エンティティの抽出を行っています。回答結果では、うまく entities タグで囲めていますね。
{
"schemaType": "ModelInvocationLog",
"schemaVersion": "1.0",
"timestamp": "2025-03-09T08:14:13Z",
"accountId": "123456789012",
"identity": {
"arn": "arn:aws:sts::123456789012:assumed-role/AmazonBedrockExecutionRoleForKnowledgeBase_1dz6y/GraphEntityExtractionTask-VJSCBJTIFC"
},
"region": "ap-northeast-1",
"requestId": "f6b90802-47b5-48e1-899a-9bdf921d1870",
"operation": "Converse",
"modelId": "arn:aws:bedrock:ap-northeast-1::foundation-model/anthropic.claude-3-haiku-20240307-v1:0",
"input": {
"inputContentType": "application/json",
"inputBodyJson": {
"messages": [
{
"role": "user",
"content": [
{
"text": "Example Corp はウィジェットを販売している"
}
]
}
],
"system": [
{
"text": "Given the following text, extract all important entities such as names, locations, organizations, and other relevant named entities.\nInstructions:\n 1. Extract all important entities (names, locations, organizations, etc.) from the text.\n 2. If there are no specific entities in the given text, please respond an empty <entities> tag set.\nYour response should be structured as follows:\n <entities>\n entity1\n entity2\n entity3\n ...\n </entities>\n"
}
]
},
"inputTokenCount": 125
},
"output": {
"outputContentType": "application/json",
"outputBodyJson": {
"output": {
"message": {
"role": "assistant",
"content": [
{
"text": "<entities>\nExample Corp\n</entities>"
}
]
}
},
"stopReason": "end_turn",
"metrics": {
"latencyMs": 295
},
"usage": {
"inputTokens": 125,
"outputTokens": 13,
"totalTokens": 138
}
},
"outputTokenCount": 13
}
}
質問
イギリスでのウィジェット販売の見通しはどうか?
と言った、各チャンクの関連性を意識しないと回答できない問題を質問してみましたが、うまく回答できていますね。
まとめ
以上、「Amazon Bedrock Knowledge bases の GraphRAG が一般提供を開始しました。」でした。
過去事例や同業種の顧客が抱える課題など、関連性を交えた内容を RAG で取り出したいケースでは、より深い回答に期待できますね。
再掲になりますが、AWS Blogs でもユースケースが挙げられているため利用検討されている方は、ぜひご覧ください。
このブログがどなたかの参考になれば幸いです。
クラウド事業本部コンサルティング部のたかくに(@takakuni_)でした!