[アップデート] Amazon Bedrock Data Automation でモダリティの有効化/モダリティコントロールがサポートされました
こんにちは!クラウド事業本部コンサルティング部のたかくに(@takakuni_)です。
Amazon Bedrock Data Automation でモダリティの有効化/モダリティコントロールがサポートされました。
以下のアップデートを抽出してお届けしています。
アップデート内容
今回のアップデートで Amazon Bedrock Data Automation(以後、BDA)はモダリティに関して以下の機能を提供しました。
- モダリティ有効化
- モダリティルーティング
モダリティ有効化
モダリティ有効化は「アセット内にある、ドキュメントは抽出するけど動画は抽出しない」といった、各モダリティごとに BDA で抽出する/しないを選択できるようになりました。
以前までは、対応するすべてのモダリティを抽出する挙動だったため、特定のモダリティの抽出処理を除きたい場合はユーザー自身で、アセットから取り除く必要がありました。今回のアップデートで BDA プロジェクト側に、モダリティ有効化/無効化を選択できるオプションが増えたため、ユーザー側で取り除く必要がなくなりました。
有効/無効にできるモダリティは以下のとおりです。
- ドキュメントモダリティ
- イメージモダリティ
- ビデオモダリティ
- オーディオモダリティ
モダリティルーティング
続いてモダリティルーティングです。これは、あるモダリティから特定のモダリティのみ抽出する。といったルーティングオプションが増えました。(説明が難しいですね。)
たとえば次の処理ができるようになりました。
- PNG(画像モダリティ)からドキュメントのみ抽出する
- PNG(画像モダリティ)から画像のみ抽出する
- MP4(動画モダリティ)から音声のみ抽出する
- MP4(動画モダリティ)から映像のみ抽出する
Routing files to certain processing types
デフォルトのルーティングは、次のように抽出されます。
ファイルタイプ | 挙動 |
---|---|
PNG | セマンティック分類器を使い、画像または文書で判定し、どちらかで抽出 |
JPEG | セマンティック分類器を使い、画像または文書で判定し、どちらかで抽出 |
PDF, TIFF | 文書を抽出 |
MP4, MOV | 動画を抽出 |
AMR, FLAC, M4A, MP3, OGG, WEBM, WAV | 音声を抽出 |
やってみる
それでは BDA を利用して、モダリティの有効化/モダリティルーティングを試してみましょう。
今回は次の検証を行います。
- イメージモダリティ、ドキュメントモダリティを無効化してみる
- モダリティルーティングを利用し、動画から音声のみ抽出する
プロジェクトの作成
まずは、プロジェクトの作成を行います。名前は任意で指定します。
プロジェクトを確認すると詳細設定
が増えています。モダリティ有効化、手動モダリティルーティングが設定できますね。
前までは KMS の設定のみが利用できていました。
イメージモダリティ、ドキュメントモダリティの無効化と手動モダリティルーティングにて、MP4 に対して AUDIO のみ抽出するよう設定します。
データの抽出
まずはモダリティの有効/無効を試します。以下の PDF を PNG に変換して利用します。
続いて動画ファイルを用意します。先日、ブログで利用した動画を利用しました。
Amazon Nova Sonic Conversation
元データを保管する S3 バケットと抽出データ保管先の S3 バケットを用意しておきましょう。
元データを保管する S3 バケット
抽出データ保管先の S3 バケット
まずは、PNG 形式のオブジェクトに対して InvokeDataAutomationAsync API を実行します。
aws bedrock-data-automation-runtime invoke-data-automation-async \
--region us-east-1 \
--input-configuration "s3Uri=s3://bedrock-bda-us-east-1-hoge/lending_package_ID_Card.png" \
--output-configuration "s3Uri=s3://kb-bda-output-data-123456789012-use-1/data" \
--data-automation-configuration "dataAutomationProjectArn='arn:aws:bedrock:us-east-1:123456789012:data-automation-project/2abb9bbb5477',stage=LIVE" \
--data-automation-profile-arn "arn:aws:bedrock:us-east-1:123456789012:data-automation-profile/us.data-automation-v1"
すると、Input file cannot be processed as it resolves to a disabled modality.
のように、処理ができない旨が記載されていますね。アプリケーションで実装するなら、この Error を Expect する必要がありそうです。
~ $ aws bedrock-data-automation-runtime invoke-data-automation-async --region us-east-1 --input-configuration "s3Uri=s3://bedrock-bda-us-east-1-hoge/lending_package_ID_Card.png" --output-configuration "s3Uri=s3://kb-bda-output-data-123456789012-use-1/data" --data-automation-configuration "dataAutomationProjectArn='arn:aws:bedrock:us-east-1:123456789012:data-automation-project/2abb9bbb5477',stage=LIVE" --data-automation-profile-arn "arn:aws:bedrock:us-east-1:123456789012:data-automation-profile/us.data-automation-v1"
An error occurred (ValidationException) when calling the InvokeDataAutomationAsync operation: Input file cannot be processed as it resolves to a disabled modality.
~ $ aws bedrock-data-automation-runtime invoke-data-automation-async \
> --region us-east-1 \
> --input-configuration "s3Uri=s3://bedrock-bda-us-east-1-hoge/lending_package_ID_Card.png" \
> --output-configuration "s3Uri=s3://kb-bda-output-data-123456789012-use-1/data" \
> --data-automation-configuration "dataAutomationProjectArn='arn:aws:bedrock:us-east-1:123456789012:data-automation-project/2abb9bbb5477',stage=LIVE" \
> --data-automation-profile-arn "arn:aws:bedrock:us-east-1:123456789012:data-automation-profile/us.data-automation-v1"
An error occurred (ValidationException) when calling the InvokeDataAutomationAsync operation: Input file cannot be processed as it resolves to a disabled modality.
続いて、動画ファイルに対して InvokeDataAutomationAsync API を実行します。
aws bedrock-data-automation-runtime invoke-data-automation-async \
--region us-east-1 \
--input-configuration "s3Uri=s3://bedrock-bda-us-east-1-hoge/Amazon Nova Sonic Conversation.mp4" \
--output-configuration "s3Uri=s3://kb-bda-output-data-123456789012-use-1/data" \
--data-automation-configuration "dataAutomationProjectArn='arn:aws:bedrock:us-east-1:123456789012:data-automation-project/2abb9bbb5477',stage=LIVE" \
--data-automation-profile-arn "arn:aws:bedrock:us-east-1:123456789012:data-automation-profile/us.data-automation-v1"
こちらは、Invocation ID が発行されました。
~ $ aws bedrock-data-automation-runtime invoke-data-automation-async \
> --region us-east-1 \
> --input-configuration "s3Uri=s3://bedrock-bda-us-east-1-hoge/Amazon Nova Sonic Conversation.mp4" \
> --output-configuration "s3Uri=s3://kb-bda-output-data-123456789012-use-1/data" \
> --data-automation-configuration "dataAutomationProjectArn='arn:aws:bedrock:us-east-1:123456789012:data-automation-project/2abb9bbb5477',stage=LIVE" \
> --data-automation-profile-arn "arn:aws:bedrock:us-east-1:123456789012:data-automation-profile/us.data-automation-v1"
{
"invocationArn": "arn:aws:bedrock:us-east-1:123456789012:data-automation-invocation/a9f850b9-0acb-4bb6-8b1e-cace09443cc4"
}
実行結果を確認すると確かに、動画ファイルが AUDIO として変換され抽出されています。
{
"metadata": {
"asset_id": "0",
"semantic_modality": "AUDIO",
"s3_bucket": "bedrock-bda-us-east-1-hoge",
"s3_key": "Amazon Nova Sonic Conversation.mp4",
"sample_rate": 44100,
"bitrate": 48072,
"number_of_channels": 2,
"codec": "aac",
"duration_millis": 32322,
"format": "mov,mp4,m4a,3gp,3g2,mj2"
},
"audio_segments": [
{
"start_timestamp_millis": 1850,
"end_timestamp_millis": 3789,
"segment_index": 0,
"type": "TRANSCRIPT",
"text": "Hi there, how are you doing today?"
},
{
"start_timestamp_millis": 4630,
"end_timestamp_millis": 9840,
"segment_index": 1,
"type": "TRANSCRIPT",
"text": "Hey, I'm doing great, thanks for asking. How about you? Hope your day is going well. Uh, I'm fine."
},
{
"start_timestamp_millis": 11590,
"end_timestamp_millis": 14539,
"segment_index": 2,
"type": "TRANSCRIPT",
"text": "Glad to hear you're managing. Anything fun planned for today?"
},
{
"start_timestamp_millis": 15430,
"end_timestamp_millis": 19489,
"segment_index": 3,
"type": "TRANSCRIPT",
"text": "today it's what's really hard because I have a lot of meeting."
},
{
"start_timestamp_millis": 20510,
"end_timestamp_millis": 23979,
"segment_index": 4,
"type": "TRANSCRIPT",
"text": "Meetings can be tough. Maybe take a short break to recharge."
},
{
"start_timestamp_millis": 24709,
"end_timestamp_millis": 25260,
"segment_index": 5,
"type": "TRANSCRIPT",
"text": "thank you."
},
{
"start_timestamp_millis": 26329,
"end_timestamp_millis": 27079,
"segment_index": 6,
"type": "TRANSCRIPT",
"text": "You're welcome."
}
],
"audio": {
"transcript": {
"representation": {
"text": "Hi there, how are you doing today? Hey, I'm doing great, thanks for asking. How about you? Hope your day is going well. Uh, I'm fine. Glad to hear you're managing. Anything fun planned for today? today it's what's really hard because I have a lot of meeting. Meetings can be tough. Maybe take a short break to recharge. thank you. You're welcome."
}
}
},
"statistics": {
"word_count": 63
}
}
まとめ
以上、「Amazon Bedrock Data Automation でモダリティの有効化/モダリティコントロールがサポートされました。」でした。
このブログがどなたかの参考になれば幸いです。クラウド事業本部コンサルティング部のたかくに(@takakuni_)でした!