0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Amazon Bedrock Knowledge Bases で基盤モデルを使用して画像を解析してみた

Last updated at Posted at 2025-10-08

はじめに

テキスト解析は経験あるのですが,
基盤モデルを使用した解析をしたことがないのでどんなものか試してみます.

スクリーンショット 2025-10-07 18.23.05.png

このオプションを選択すると、視覚的に豊かな文書や画像を処理できます。

画像を基盤モデルに解析させることで,
ナレッジベースからどのような結果を得ることができるのか気になっています.

やってみた

S3 のデータソースバケットに下記2つの画像を保存しておきます.
コーギーとアメショです.
dog-corgi.jpeg
cat-american-shorthair.jpeg

データソース設定

S3 の URI でデータソースバケットを指定して,
解析戦略でパーサーとしての基盤モデルを選択し, Claude Sonnet 4.5 を選択.
他はデフォルトのままです.
スクリーンショット 2025-10-08 19.44.53.png

なお, 基盤モデルに対してプロンプトを指定できるようです.

デフォルトのパーサー向けの指示
Extract the content from an image page and output in Markdown syntax. Enclose the content in the <markdown></markdown> tag and do not use code blocks. If the image is empty then output a <markdown></markdown> without anything in it.

Follow these steps:

1. Examine the provided page carefully.

2. Identify all elements present in the page, including headers, body text, footnotes, tables, images, captions, and page numbers, etc.

3. Use markdown syntax to format your output:
    - Headings: # for main, ## for sections, ### for subsections, etc.
    - Lists: * or - for bulleted, 1. 2. 3. for numbered
    - Do not repeat yourself

4. If the element is an image (not table)
    - If the information in the image can be represented by a table, generate the table containing the information of the image
    - Otherwise provide a detailed description about the information in image
    - Classify the element as one of: Chart, Diagram, Logo, Icon, Natural Image, Screenshot, Other. Enclose the class in <figure_type></figure_type>
    - Enclose <figure_type></figure_type>, the table or description, and the figure title or caption (if available), in <figure></figure> tags
    - Do not transcribe text in the image after providing the table or description

5. If the element is a table
    - Create a markdown table, ensuring every row has the same number of columns
    - Maintain cell alignment as closely as possible
    - Do not split a table into multiple tables
    - If a merged cell spans multiple rows or columns, place the text in the top-left cell and output ' ' for other
    - Use | for column separators, |-|-| for header row separators
    - If a cell has multiple items, list them in separate rows
    - If the table contains sub-headers, separate the sub-headers from the headers in another row

6. If the element is a paragraph
    - Transcribe each text element precisely as it appears

7. If the element is a header, footer, footnote, page number
    - Transcribe each text element precisely as it appears

Output Example:
<markdown>
<figure>
<figure_type>Chart</figure_type>
Figure 3: This chart shows annual sales in millions. The year 2020 was significantly down due to the COVID-19 pandemic.
A bar chart showing annual sales figures, with the y-axis labeled "Sales ($Million)" and the x-axis labeled "Year". The chart has bars for 2018 ($12M), 2019 ($18M), 2020 ($8M), and 2021 ($22M).
</figure>

<figure>
<figure_type>Chart</figure_type>
Figure 3: This chart shows annual sales in millions. The year 2020 was significantly down due to the COVID-19 pandemic.
| Year | Sales ($Million) |
|-|-|
| 2018 | $12M |
| 2019 | $18M |
| 2020 | $8M |
| 2021 | $22M |
</figure>

# Annual Report

## Financial Highlights

<figure>
<figure_type>Logo</figure_type>
The logo of Apple Inc.
</figure>

* Revenue: $40M
* Profit: $12M
* EPS: $1.25

| | Year Ended December 31, | |
| | 2021 | 2022 |
|-|-|-|
| Cash provided by (used in): | | |
| Operating activities | $ 46,327 | $ 46,752 |
| Investing activities | (58,154) | (37,601) |
| Financing activities | 6,291 | 9,718 |

</markdown>

データストレージと処理を設定

下記の通り設定しました.
スクリーンショット 2025-10-08 19.51.25.png

なお, 埋め込みモデルで選択できるのは text-to-text モデルのみでした.
スクリーンショット 2025-10-08 19.54.24.png

確認して作成

スクリーンショット 2025-10-08 20.00.04.png

ナレッジベースを同期

ナレッジベースの作成が完了したら
同期ボタンを押してデータソースとナレッジベースを同期させます.
スクリーンショット 2025-10-08 20.01.46.png

検索してみた

ナレッジベースのテスト画面で雑に検索してみました.
ソースチャンクを見ると, 基盤モデルで画像を解析することで抽出されたインサイト(今回は動物の特徴等)をベクトルデータベースに登録しているようです.
スクリーンショット 2025-10-08 20.26.33.png

ちなみに, 画像や画像 URL はもらえませんでした.
(メタデータに含まれているので後者はできそうな気はしているのですが)
スクリーンショット 2025-10-08 20.35.22.png

まとめ

画像のインサイトを抽出できる!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?