翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
Bedrock Data Automation API を使用する
Amazon Bedrock データ自動化 (BDA) 機能は、データを処理するための合理化された API ワークフローを提供します。すべてのモダリティにおいて、このワークフローは、プロジェクトの作成、分析の呼び出し、結果の取得の 3 つの主要なステップで構成されます。処理されたデータのカスタム出力を取得するには、分析オペレーションを呼び出すときにブループリント ARN を指定します。
データ自動化プロジェクトを作成する
BDA を使用してファイルの処理を開始するには、まずデータ自動化プロジェクトを作成する必要があります。これは、CreateDataAutomationProject オペレーションまたは Amazon Amazon Bedrock コンソールの 2 つの方法で実行できます。
API を使用する
API を使用してプロジェクトを作成する場合は、CreateDataAutomationProject を呼び出します。プロジェクトを作成するときは、よく処理するファイルの種類 (使用する予定のモダリティ) の設定を定義する必要があります。画像の標準出力を設定する方法の例を次に示します。
{ "standardOutputConfiguration": { "image": { "state": "ENABLED", "extraction": { "category": { "state": "ENABLED", "types": [ "CONTENT_MODERATION", "TEXT_DETECTION" ] }, "boundingBox": { "state": "ENABLED" } }, "generativeField": { "state": "ENABLED", "types": [ "IMAGE_SUMMARY", "IAB" ] } } } }
API により入力設定が検証されます。一意の ARN を持つ新しいプロジェクトが作成されます。後で使用できるようにプロジェクト設定が保存されます。パラメータを指定せずにプロジェクトを作成した場合、デフォルト設定が適用されます。例えば、画像を処理する場合、画像の要約とテキスト検出がデフォルトで有効になります。
AWS アカウントごとに作成できるプロジェクトの数には制限があります。特定の設定の組み合わせは許可されないか、追加のアクセス許可が必要になる場合があります。
標準出力設定とカスタム出力設定の両方を使用した JSON レスポンスの構造は次のとおりです。
{ "semanticModality": "IMAGE", "outputSegments": [ { "customOutputStatus": "MATCH", "standardOutput": { "image": { "summary": "This image shows a white Nike running shoe with a black Nike swoosh logo on the side. The shoe has a modern design with a thick, cushioned sole and a sleek upper part. The word \"ROUKEA\" is visible on the sole of the shoe, repeated twice. The shoe appears to be designed for comfort and performance, suitable for running or athletic activities. The background is plain and dark, highlighting the shoe.", "iab_categories": [ { "category": "Style and Fashion", "confidence": 0.9890000000000001, "taxonomy_level": 1, "parent_name": "", "id": "0ebe86c8-e9af-43f6-a7bb-182a61d2e1fd", "type": "IAB" }, { "category": "Men's Fashion", "confidence": 0.9890000000000001, "taxonomy_level": 2, "parent_name": "Style and Fashion", "id": "13bd456a-3e1b-4681-b0dd-f42a8d5e5ad5", "type": "IAB" }, { "category": "Style and Fashion", "confidence": 0.853, "taxonomy_level": 1, "parent_name": "", "id": "177b29a1-0e40-45c1-8540-5f49a3d7ded3", "type": "IAB" }, { "category": "Women's Fashion", "confidence": 0.853, "taxonomy_level": 2, "parent_name": "Style and Fashion", "id": "f0197ede-3ba6-498b-8f7b-43fecc5735ef", "type": "IAB" } ], "content_moderation": [], "logos": [ { "id": "2e109eb6-39f5-4782-826f-911b62d277fb", "type": "LOGOS", "confidence": 0.9170872209665809, "name": "nike", "locations": [ { "bounding_box": { "left": 0.3977411523719743, "top": 0.4922481227565456, "width": 0.2574246356942061, "height": 0.15461772197001689 } } ] } ], "text_words": [ { "id": "f70301df-5725-405e-b50c-612e352467bf", "type": "TEXT_WORD", "confidence": 0.10091366487951722, "text": "ROUKEA", "locations": [ { "bounding_box": { "left": 0.6486002310163024, "top": 0.6783271480251003, "width": 0.13219473954570082, "height": 0.05802226710963898 }, "polygon": [ { "x": 0.6486002310163024, "y": 0.7025876947351404 }, { "x": 0.7760931467045249, "y": 0.6783271480251003 }, { "x": 0.7807949705620032, "y": 0.7120888684246991 }, { "x": 0.6533020989743271, "y": 0.7363494151347393 } ] } ], "line_id": "9147fec0-d869-4d58-933e-93eb7164c404" } ], "text_lines": [ { "id": "9147fec0-d869-4d58-933e-93eb7164c404", "type": "TEXT_LINE", "confidence": 0.10091366487951722, "text": "ROUKEA", "locations": [ { "bounding_box": { "left": 0.6486002310163024, "top": 0.6783271480251003, "width": 0.13219473954570082, "height": 0.05802226710963898 }, "polygon": [ { "x": 0.6486002310163024, "y": 0.7025876947351404 }, { "x": 0.7760931467045249, "y": 0.6783271480251003 }, { "x": 0.7807949705620032, "y": 0.7120888684246991 }, { "x": 0.6533020989743271, "y": 0.7363494151347393 } ] } ] } ] }, "statistics": { "iab_category_count": 4, "content_moderation_count": 0, "logo_count": 1, "line_count": 1, "word_count": 1 }, "metadata": { "semantic_modality": "IMAGE", "image_width_pixels": 173, "image_height_pixels": 148, "image_encoding": "jpeg", "s3_bucket": "test-bucket", "s3_key": "uploads/test-image.jpeg" } }, "customOutput": { "matched_blueprint": { "arn": "arn:aws:bedrock:us-east-1:123456789012:blueprint/test", "version": "1", "name": "test-blueprint", "confidence": 1.0 }, "inference_result": { "product_details": { "product_category": "footwear" }, "image_sentiment": "Positive", "image_background": "Solid color", "image_style": "Product image", "image_humor": false } } } ] }
データ自動化ステータスを取得する
処理ジョブのステータスをチェックして結果を取得するには、GetDataAutomationStatus を使用します。
GetDataAutomationStatus API を使用すると、ジョブの進行状況をモニタリングし、処理が完了したら結果にアクセスできます。InvokeDataAutomationAsync によって返される呼び出し ARN が API により受け入れられます。ジョブの現在のステータスがチェックされ、関連情報が返されます。ジョブが完了すると、S3 内の結果の場所が示されます。
ジョブがまだ進行中の場合は、現在の状態 (「InProgress」など) が返されます。ジョブが完了すると、S3 内の結果の場所とともに「Success」が返されます。エラーが発生した場合、エラーの詳細とともに「ServiceError」または「ClientError」が返されます。
リクエスト JSON は次の形式です。
{ "InvocationArn": "string" // Arn }
非同期出力レスポンス
ファイル処理の結果は、入力画像用に設定された S3 バケットに保存されます。出力には、InvokeDataAutomationAsync の呼び出しで指定されたファイルモダリティとオペレーションタイプの両方に応じて、一意の構造が含められます。
特定のモダリティの標準出力の詳細については、「Bedrock Data Automation の標準出力」を参照してください。
例えば、画像には以下の情報が含められる可能性があります。
画像の要約: 画像のわかりやすい要約またはキャプション。
IAB 分類: IAB 分類に基づく分類。
画像テキスト検出: 境界ボックス情報を含む抽出テキスト。
コンテンツモデレーション: 画像内の不適切、望ましくない、または不快なコンテンツを検出します。
以下は、画像処理の出力のスニペット例です。
{ "metadata": { "id": "image_123", "semantic_modality": "IMAGE", "s3_bucket": "my-s3-bucket", "s3_prefix": "images/", "image_width_pixels": 1920, "image_height_pixels": 1080 }, "image": { "summary": "A lively party scene with colorful decorations and supplies", "iab_categories": [ { "category": "Party Supplies", "confidence": 0.9, "parent_name": "Events & Attractions" } ], "content_moderation": [ { "category": "Drugs & Tobacco Paraphernalia & Use", "confidence": 0.7 } ], "text_words": [ { "id": "word_1", "text": "lively", "confidence": 0.9, "line_id": "line_1", "locations": [ { "bounding_box": { "left": 100, "top": 200, "width": 50, "height": 20 }, "polygon": [ { "x": 100, "y": 200 }, { "x": 150, "y": 200 }, { "x": 150, "y": 220 }, { "x": 100, "y": 220 } ] } ] } ] } }
この構造化された出力により、ダウンストリームアプリケーションとの統合とさらなる分析が容易になります。
ブループリント最適化 APIs
InvokeBlueprintOptimizationAsync
サンプルコンテンツアセットに正しい期待される結果を提供することで、ブループリントの精度を向上させることができます。ブループリント命令の最適化では、例を使用してブループリントフィールドの自然言語命令を絞り込むため、推論結果の精度が向上します。
ブループリントの場合、InvokeBlueprintOptimizationAsync API を呼び出して非同期最適化ジョブを開始し、グラウンドトゥルースデータに基づいてブループリントフィールドの手順を改善できます。
リクエスト本文
{ "blueprint": { "blueprintArn": "arn:aws:bedrock:us-east-1:123456789012:blueprint/my-document-processor", "stage": "DEVELOPMENT" }, "samples": [ { "assetS3Object": { "s3Uri": "s3://my-optimization-bucket/samples/document1.pdf" }, "groundTruthS3Object": { "s3Uri": "s3://my-optimization-bucket/ground-truth/document1-expected.json" } } ], "outputConfiguration": { "s3Object": { "s3Uri": "s3://my-optimization-bucket/results/optimization-output" } }, "dataAutomationProfileArn": "arn:aws:bedrock:us-east-1:123456789012:data-automation-profile/my-profile" }
応答
{ "invocationArn": "arn:aws:bedrock:us-east-1:123456789012:blueprint-optimization-invocation/opt-12345abcdef" }
重要
invocationArn を保存して、最適化ジョブのステータスをモニタリングします。
GetBlueprintOptimizationStatus
InvokeBlueprintOptimizationAsync 非同期 API を呼び出して出力されたブループリント最適化ジョブの現在のステータスと結果を取得します。GetBlueprintOptimizationStatus は、InvokeBlueprintOptimizationAsync によって返される呼び出し ARN を受け入れます。
応答
{ "status": "Success", "outputConfiguration": { "s3Object": { "s3Uri": "s3://my-optimization-bucket/results/optimization-output" } } }
ステータス値:
作成済み - ジョブが作成されました
InProgress - 最適化が実行中
Success - 最適化が正常に完了しました
ServiceError - 内部サービスエラーが発生しました
ClientError - 無効なリクエストパラメータ
CopyBlueprintStage
ソースステージからターゲットステージ (例: 開発ステージからライブステージへ)。これは、ステージ間で optimizationSamples フィールドを含むすべての設定を同期するために使用されます。
リクエスト本文
{ "blueprintArn": "arn:aws:bedrock:us-east-1:123456789012:blueprint/my-document-processor", "sourceStage": "DEVELOPMENT", "targetStage": "LIVE" }
ステージ値:
開発 - 開発/テストステージ
LIVE - 本番稼働ステージ
応答
{}
警告
このオペレーションはターゲットステージ設定を上書きし、簡単に元に戻すことはできません。LIVE ステージにコピーする前に、徹底的なテストを行ってください。