TwelveLabs Marengo Embed 2.7 - Amazon Bedrock

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

TwelveLabs Marengo Embed 2.7

TwelveLabs Marengo Embed 2.7 モデルは、動画、テキスト、オーディオ、または画像入力から埋め込みを生成します。これらの埋め込みは、類似度検索、クラスタリング、その他の機械学習タスクに使用できます。

  • プロバイダー — TwelveLabs

  • モデル ID — twelvelabs.marengo-embed-2-7-v1:0

このTwelveLabs Marengo Embed 2.7モデルは、次の表の Amazon Bedrock ランタイムオペレーションをサポートしています。

API オペレーション サポートされているモデルタイプ 入力モダリティ 出力モダリティ

InvokeModel

推論プロファイル

テキスト

イメージ

埋め込み

StartAsyncInvoke ベースモデル

動画

音声

イメージ

テキスト

埋め込み

注記

を使用してInvokeModel、検索クエリの埋め込みを生成します。StartAsyncInvoke を使用して、アセットの埋め込みを大規模に生成します。

入力には、次のクォータが適用されます。

入力モダリティ 最大値
テキスト 77 トークン
イメージ 5 MB
動画 (S3) 2 GB
オーディオ (S3) 2 GB
注記

base64 エンコードを使用してオーディオまたはビデオをインラインで定義する場合は、リクエストボディペイロードが Amazon Bedrock 25 MB モデルの呼び出しクォータを超えないようにしてください。

TwelveLabs Marengo Embed 2.7 リクエストパラメータ

リクエストを行うとき、モデル固有の入力を指定するフィールドは API オペレーションによって異なります。

モデル入力の形式は、入力モダリティによって異なります。

Text
{ "inputType": "text", "inputText": "string", "textTruncate": "string }
Inline image
{ "inputType": "image", "mediaSource": { "base64String": "base64-encoded string" } }
S3 image
{ "inputType": "image", "mediaSource": { "s3Location": { "uri": "string", "bucketOwner": "string" } } }
Inline video
{ "inputType": "video", "mediaSource": { "s3Location": { "base64String": "base64-encoded string" } }, "startSec": double, "lengthSec": double, "useFixedLengthSec": double, "embeddingOption": "visual-text" | "visual-image" | "audio" }
S3 video
{ "inputType": "image", "mediaSource": { "s3Location": { "uri": "string", "bucketOwner": "string" } }, "startSec": double, "lengthSec": double, "useFixedLengthSec": double, "minClipSec": int, "embeddingOption": ["string"] }
Inline audio
{ "inputType": "audio", "mediaSource": { "base64String": "base64-encoded string" }, "startSec": double, "lengthSec": double, "useFixedLengthSec": double }
S3 audio
{ "inputType": "audio", "mediaSource": { "s3Location": { "uri": "string", "bucketOwner": "string" } }, "startSec": double, "lengthSec": double, "useFixedLengthSec": double }

入力パラメータの詳細については、以下のセクションを展開してください。

埋め込みのモダリティ。

  • タイプ: 文字列

  • 必須: はい

  • 有効な値: video | text | audio | image

埋め込むテキスト。

  • タイプ: 文字列

  • 必須: はい (互換性のある入力タイプの場合)

  • 互換性のある入力タイプ: テキスト

プラットフォームがテキストを切り捨てる方法を指定します。

  • タイプ: 文字列

  • 必須: いいえ

  • 有効な値:

    • end – テキストの末尾を切り捨てます。

    • none – テキストが制限を超えた場合にエラーを返します。

  • デフォルト値: end

  • 互換性のある入力タイプ: テキスト

メディアソースに関する情報が含まれます。

  • タイプ: オブジェクト

  • 必須: はい (互換性のあるタイプの場合)

  • 互換性のある入力タイプ: Image、Video、Audio

リクエストボディ内のmediaSourceオブジェクトの形式は、メディアが Base64-encodedされた文字列として定義されているか、S3 の場所として定義されているかによって異なります。

  • Base64-encoded文字列

    { "mediaSource": { "base64String": "base64-encoded string" } }
    • base64String – メディアの Base64-encodedされた文字列。

  • S3 の場所 – S3 URI と を指定します。

    { "s3Location": { "uri": "string", "bucketOwner": "string" } }
    • uri – メディアを含む S3 URI。

    • bucketOwner – S3 バケット所有者の AWS アカウント ID。

取得する埋め込みのタイプを指定します。

  • タイプ: リスト

  • 必須: いいえ

  • リストメンバーの有効な値:

    • visual-text – テキスト検索用に最適化されたビジュアル埋め込み。

    • visual-image – イメージ検索用に最適化されたビジュアル埋め込み。

    • audio – ビデオ内のオーディオの埋め込み。

  • デフォルト値: ["visual-text"、"visual-image"、"audio"]

  • 互換性のある入力タイプ: ビデオ、オーディオ

処理を開始するクリップの秒単位の時間ポイント。

  • 型: 倍精度

  • 必須: いいえ

  • 最小値: 0

  • デフォルト値: 0

  • 互換性のある入力タイプ: ビデオ、オーディオ

処理を停止する時点からカウントされる秒単位のstartSec時間。

  • 型: 倍精度

  • 必須: いいえ

  • 有効な値: 0 - メディアの期間

  • デフォルト値: メディアの期間

  • 互換性のある入力タイプ: ビデオ、オーディオ

例:

  • startSec: 5

  • lengthSec: 20

  • 結果: クリップは 0:05 から 0:20 まで処理されます。

モデルが埋め込みを生成する各クリップの期間。

  • 型: 倍精度

  • 必須: いいえ

  • 値パラメータ: 2~10。以上である必要がありますminClipSec

  • デフォルト値: メディアのタイプによって異なります。

    • 動画: ショット境界検出で動的に分割

    • オーディオ: 均等に分割され、可能な限り 10 に近くなります。例:

      • 50 秒のクリップは 5 つの 10 秒セグメントに分割されます。

      • 16 秒のクリップは 2 つの 8 秒セグメントに分割されます。

  • 互換性のある入力タイプ: – ビデオ、オーディオ

  • 注: 以上である必要がありますminClipSec

各クリップの最小値を秒単位で設定します。

  • タイプ: int

  • 必須: いいえ

  • 値パラメータ: 範囲: 1~5

  • デフォルト値: 4

  • 互換性のある入力タイプ: 動画

  • 注: 以下である必要がありますuseFixedLengthSec

TwelveLabs Marengo Embed 2.7レスポンス

出力埋め込みおよび関連するメタデータの場所は、呼び出し方法によって異なります。

  • InvokeModel – レスポンス本文。

  • StartAsyncInvoke – 非同期呼び出しジョブが完了した後s3OutputDataConfig、 で定義された S3 バケット。

複数の埋め込みベクトルがある場合、出力はオブジェクトのリストであり、それぞれにベクトルとそれに関連するメタデータが含まれます。

出力埋め込みベクトルの形式は次のとおりです。

{ "embedding": ["string"], "embeddingOption": "visual-text" | "visual-image" | "audio", "startSec": double, "endsec": double }

レスポンスパラメータの詳細については、以下のセクションを展開してください。

入力のベクトル表現を埋め込みます。

  • タイプ: doubles のリスト

埋め込みのタイプ。

  • タイプ: 文字列

  • 指定できる値:

    • visual-text – テキスト検索用に最適化されたビジュアル埋め込み。

    • visual-image – イメージ検索用に最適化されたビジュアル埋め込み。

    • audio – ビデオ内のオーディオの埋め込み。

  • 互換性のある入力タイプ: 動画

クリップの開始オフセット。

  • 型: 倍精度

  • 互換性のある入力タイプ: ビデオ、オーディオ

クリップの終了オフセット。秒単位。

  • 型: 倍精度

  • 互換性のある入力タイプ: ビデオ、オーディオ

TwelveLabs Marengo Embed 2.7 コードの例

このセクションでは、Python を使用してさまざまな入力タイプでTwelveLabs Marengo Embed 2.7モデルを使用する方法を示します。

注記

現在、InvokeModel はテキストとイメージの入力のみをサポートしています。

次のステップでコードをまとめます。

1. モデル固有の入力を定義する

入力タイプに応じてモデル固有の入力を定義します。

Text
# Create the model-specific input model_id = "twelvelabs.marengo-embed-2-7-v1:0" # Replace the us prefix depending on your region inference_profile_id = "us.twelvelabs.marengo-embed-2-7-v1:0" model_input = { "inputType": "text", "inputText": "man walking a dog" }
Inline image
# Create the model-specific input model_id = "twelvelabs.marengo-embed-2-7-v1:0" # Replace the us prefix depending on your region inference_profile_id = "us.twelvelabs.marengo-embed-2-7-v1:0" model_input = { "inputType": "image", "mediaSource": { "base64String": "example-base64-image" } }
S3 image
# Create the model-specific input model_id = "twelvelabs.marengo-embed-2-7-v1:0" # Replace the us prefix depending on your region inference_profile_id = "us.twelvelabs.marengo-embed-2-7-v1:0" model_input = { "inputType": "image", "mediaSource": { "s3Location": { "uri": "s3://amzn-s3-demo-bucket/my_image.png", "bucketOwner": "123456789012" } } }
Inline video
# Create the model-specific input model_id = "twelvelabs.marengo-embed-2-7-v1:0" # Replace the us prefix depending on your region inference_profile_id = "us.twelvelabs.marengo-embed-2-7-v1:0" model_input = { "inputType": "video", "mediaSource": { "base64String": "base_64_encoded_string_of_video" }, "startSec": 0, "lengthSec": 13, "useFixedLengthSec": 5, "embeddingOption": [ "visual-text", "audio" ] }
S3 video
# Create the model-specific input model_id = "twelvelabs.marengo-embed-2-7-v1:0" # Replace the us prefix depending on your region inference_profile_id = "us.twelvelabs.marengo-embed-2-7-v1:0" model_input = { "inputType": "video", "mediaSource": { "s3Location": { "uri": "amzn-s3-demo-bucket/my-video.mp4", "bucketOwner": "123456789012" } }, "startSec": 0, "lengthSec": 13, "useFixedLengthSec": 5, "embeddingOption": [ "visual-text", "audio" ] }
Inline audio
# Create the model-specific input model_id = "twelvelabs.marengo-embed-2-7-v1:0" # Replace the us prefix depending on your region inference_profile_id = "us.twelvelabs.marengo-embed-2-7-v1:0" model_input = { "inputType": "audio", "mediaSource": { "base64String": "base_64_encoded_string_of_audio" }, "startSec": 0, "lengthSec": 13, "useFixedLengthSec": 10 }
S3 audio
# Create the model-specific input model_id = "twelvelabs.marengo-embed-2-7-v1:0" # Replace the us prefix depending on your region inference_profile_id = "us.twelvelabs.marengo-embed-2-7-v1:0" model_input = { "inputType": "audio", "mediaSource": { "s3Location": { "uri": "s3://amzn-s3-demo-bucket/my-audio.wav", "bucketOwner": "123456789012" } }, "startSec": 0, "lengthSec": 13, "useFixedLengthSec": 10 }
2. モデル入力を使用してモデル呼び出しを実行する

次に、選択したモデル呼び出し方法に対応するコードスニペットを追加します。

InvokeModel
# Run model invocation with InvokeModel import boto3 import json # Initialize the Bedrock Runtime client client = boto3.client('bedrock-runtime') # Make the request response = client.invoke_model( modelId=inference_profile_id, body=json.dumps(model_input) ) # Print the response body response_body = json.loads(response['body'].read().decode('utf-8')) print(response_body)
StartAsyncInvoke
# Run model invocation asynchronously import boto3 import json # Initalize the Bedrock Runtime client. client = boto3.client("bedrock-runtime") try: # Start the asynchronous job invocation = client.start_async_invoke( modelId=model_id, modelInput=model_input, outputDataConfig={ "s3OutputDataConfig": { "s3Uri": "s3://&example-s3-destination-bucket;" } } ) # Print the response JSON print("Response:") print(json.dumps(invocation, indent=2, default=str)) except Exception as e: # Implement error handling here. message = e.response["Error"]["Message"] print(f"Error: {message}")