Amazon Bedrock Knowledge Basesでマルチモーダル処理がサポートされました

記事タイトルとURLをコピーする

サーバーワークスの村上です。

ナレッジベースでマルチモーダル処理がサポートされたとのことで早速試してみます。

aws.amazon.com

個人的なまとめ

私見も含んだまとめです。

  • Parsing Strategyが3つに増えた
    • デフォルト
    • Amazon Bedrock Data Automation as parser ← New!!
    • Use foundation model for paring
  • Amazon Bedrock Data Automation as parserではパース処理に生成AIを活用する。
    • 画像は生成AIを使って説明文を生成。その説明文を検索対象にできる。
    • プロンプトは変更不可
    • 細部の情報が失われる可能性あり(後述)
    • 料金は0.010ドル/ページ
  • Use foundation model for paringではパース処理に生成AIを活用する。
    • 画像は生成AIを使って説明文を生成。その説明文を検索対象にできる。
    • プロンプトは変更可能
    • 料金は使用する生成AIモデルに準ずる

(おさらい)これまでパース処理は2種類

ドキュメントからテキスト情報を抽出するパース処理では、これまで2種類の方法がありました。

  • デフォルト
  • Advanced Parsing(Use foundation model for paring)※PDFのみ

Advanced Parsingは、レイアウトが崩れてしまいがちな表をマークダウンでパースしてくれたり、画像情報をLLMにテキストで説明させて検索可能にしてくれたりするオプションです。詳細は以下のブログをご参照ください。

blog.serverworks.co.jp

re:Invent2024以降のパース処理は3種類

「Amazon Bedrock Data Automation as parser」が加わり合計3つになりました(現在はオレゴンリージョンのみ)。

Amazon Bedrock Data Automation(プレビュー)は画像・動画・音声などからインサイトを得る機能

Amazon Bedrock Data Automation は Amazon Bedrock Knowledge Bases とは独立した機能です。

aws.amazon.com

コンソール上でも入口が別になっています。

Amazon Bedrock Data Automation単体で使用する場合は動画などのデータも処理可能です。

試しに以前、生成AIで作ってみた動画をアップロードすると要約してくれました。

動画の要約なども可能

blog.serverworks.co.jp

Data Automationを使ったパース処理でサポートされるファイル形式

さきほど、Amazon Bedrock Data Automationは動画や音声も処理できると記載しましたが、Amazon Bedrock Knowledge Basesにおけるパース処理としては、動画や音声は対応しておらずPDFや画像などに対応しているようです。

Parsing options for your data source - Amazon Bedrock

試してみて分かったこと

手順としては、Amazon Bedrock Knowledge Basesを作成する際のParsing strategyで「Amazon Bedrock Data Automation as parser」を選択する流れになります。

試してみて分かったことを記載していきます。

ドキュメントを画像としてS3に保存しレスポンスの生成に使っている

作成時、Multimodal storage destinationとしてドキュメントから抽出した画像を保存するS3バケットを指定します。

ドキュメント内にある画像だけ保存されるのかと思っていましたが、テキストも含めたページ全体が画像として保存され、RAG の Source chunk として表示されるようです!

以下は動作確認した際の Source chunk を確認していますが、テキストではなくページ全体の画像が表示されていることが分かります。

※ デフォルトだとソースチャンクはテキストです。

デフォルトだとソースチャンクはテキスト

埋め込みモデルはこれまでどおりテキスト埋め込みモデル

アップデートのタイトル的に、マルチモーダル埋め込みモデルを使えるようになったのかと思ってしまいましたが、埋め込みモデルはこれまでどおりテキスト埋め込みモデルのみ選択可能です。

Amazon Bedrock Data Automation(BDA)の公式ドキュメントには以下のように記載されており、Advanced Parsingのように生成AIを使って、画像を含むドキュメントを構造化されたテキストに変換しているのだろうと推測します。

BDA leverages generative AI to automate the transformation of multi-modal data into structured formats
BDAはジェネレーティブAIを活用し、マルチモーダルデータの構造化変換を自動化する Data automation - Amazon Bedrock

よって、画像埋め込みをしているのではないことが分かりました。

取得できるメタデータにも違いがある

取得できるメタデータも少し違いました。

デフォルトの場合は、x-amz-bedrock-kb-source-urix-amz-bedrock-kb-data-source-idがメタデータとして取得可能です。

Amazon Bedrock Data Automation as parser を利用した場合、追加でx-amz-bedrock-kb-descriptionx-amz-bedrock-kb-byte-content-sourceが取得可能です。

x-amz-bedrock-kb-descriptionは、パースしたドキュメントのテキスト情報、x-amz-bedrock-kb-byte-content-sourceは保存した画像のS3 URIになっています。

詳細は下表の例を見ていただけますと幸いです。

Key Value
x-amz-bedrock-kb-source-uri s3://tmp-s3-data-automation/00.pdf
x-amz-bedrock-kb-description
<figure_type>LOGO</figure_type> Title: エンジニアのAWS資格取得推進 The image appears to be a logo or banner related to the promotion of AWS (Amazon Web Services) certifications for engineers.
# ---
<figure_type>LOGO</figure_type> Title: Serverworks The image shows the Serverworks logo, which consists of a stylized symbol in red and yellow colors along with the company name "Serverworks" in black text.
+1,000
<figure_type>LOGO</figure_type> Title: AWS 1000 Certified The image shows the AWS 1000 Certified logo, indicating that the subject has achieved the AWS 1000 certification.
<figure_type>CHART</figure_type> X 1. - X 2 . X 3 . 2025UITI 20243D152024Title: Engineering Personnel Headcount Trend The image shows a chart depicting the trend in engineering personnel headcount over time, with data for sales, manufacturing, and total headcount. The chart covers the period from 2021 to 2025, with projections for each year. The data is presented in a bar graph format, allowing for easy comparison of the different categories across the years. The chart covers the period from 2021 to 2025, with projections for each year. | Year | Sales | Manufacturing | | - | - | - | | 2021 | 92 | 0 | | 2022 | 110 | 0 | | 2023 | 139 | 0 | | 2024 | 141 | 16 | | 2025 | 161 | 26 |
<figure_type>CHART</figure_type> Title: AWS Certification Exam Registrations The image shows a chart depicting the number of AWS certification exam registrations over time. The data is presented in a line graph format, with the x-axis representing the year and the y-axis showing the number of registrations. The chart covers the period from 2021 to 2025, with projections for the future years. | Year | Registrations | | - | - | | 2021 2 月期 | 437 | | 2022 2 月期 | 609 | | 2023 2 月期 | 763 | | 2024 2 月期 | 916 | | 2025 2 月期 | 1033 |
31
x-amz-bedrock-kb-byte-content-source s3://tmp-data-automation-destination/aws/bedrock/knowledge_bases/NJ6LHBKPXJ/POONAH9VZQ/c039e536-6d7f-4d71-b89d-68f74813e7b7.png
x-amz-bedrock-kb-data-source-id POONAH9VZQ

Use foundation model for paring の方が精度は高そう

今回検証に以下のページを含むPDFを使いました。

今回検証に使用したドキュメントの1ページ

画像はどちらも対応できる

デフォルトのParsing Strategyを採用した場合に比べ、当然、画像情報は付加されます。

ページ右上にあるサーバーワークスのロゴに関する情報は、x-amz-bedrock-kb-descriptionに含まれていることが分かります。

<figure_type>LOGO</figure_type> Title: Serverworks The image shows the Serverworks logo, which consists of a stylized symbol in red and yellow colors along with the company name "Serverworks" in black text.

よって、「サーバーワークスのロゴは何色ですか」みたいな質問にも対応可能です。

Amazon Bedrock Data Automation as parser では一部情報が失われる可能性あり

一方でドキュメント内にあるテキストの情報が一部失われていることが分かります。

今回使用したドキュメントにはグラフの下にいくつか注釈があります。そのうちの「※ 2 . 2024年2月期から、社内SEやトレーニングを行うエンジニアを販管部門に変更しております。」という記載に関する質問をしてみました。

デフォルトのParsing Strategyの場合は当然ですが正しく回答できました。

デフォルトのParsing Strategyの場合、表の体裁は崩れているが正しく回答できている

Parsing strategyで「Amazon Bedrock Data Automation as parser」を選択した場合は正しく回答できませんでした。

Parsing strategyで「Amazon Bedrock Data Automation as parser」を選択した場合

これも、先述したx-amz-bedrock-kb-descriptionの内容を見ていただれば分かるのですが、注釈の内容が抜け落ちていることがわかります。

このあたりは、「Use foundation model for paring」に分がありそうですね。

以下は「Use foundation model for paring」を選択した場合ですが、表やグラフがマークダウン形式となり解釈性が向上しており、さらに細部の情報も保持されています。

「Use foundation model for paring」を選択した場合

コストメリットではAmazon Bedrock Data Automation as parserに軍配か

Amazon Bedrock Data Automationの料金は0.010ドル/ページです。

Parsing Strategyに Use foundation model for paring(Claude 3.5 Sonnet)を採用した場合、1000入力トークンあたり0.003ドル、1000出力トークンあたり0.015ドルです。

内容にも依りますが、Amazon Bedrock Data Automation にコストメリットがあるシーンが多そうです。

以上となります!

村上博哉 (執筆記事の一覧)

2020年4月入社。機械学習が好きです。記事へのご意見など:hiroya.murakami@serverworks.co.jp