

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

# TwelveLabs Marengo Embed 2.7
<a name="model-parameters-marengo"></a>

TwelveLabs Marengo Embed 2.7 モデルは、動画、テキスト、音声、または画像の入力から埋め込みを生成します。これらの埋め込みは、類似度検索やクラスタリングのような機械学習タスクに使用できます。
+ プロバイダー — TwelveLabs
+ モデル ID — twelvelabs.marengo-embed-2-7-v1:0

TwelveLabs Marengo Embed 2.7 モデルは、次の表の Amazon Bedrock ランタイムオペレーションをサポートしています。
+ 別の API メソッドのユースケースの詳細については、「[推論リクエストの実行](inference.md)」を参照してください。
+ モデルタイプの詳細については、「[推論リクエストの実行](inference.md)」を参照してください。
  + モデル IDs のリストと、 TwelveLabs Marengo Embed 2.7 でサポートされているモデルと AWS リージョンを確認するには、 の表でモデルを検索します[Amazon Bedrock でサポートされている基盤モデル](models-supported.md)。
  + 推論プロファイル ID の完全なリストについては、「[推論プロファイルでサポートされているリージョンおよびモデル](inference-profiles-support.md)」を参照してください。推論プロファイル ID は AWS リージョンに基づいています。


****  

| API オペレーション: | サポートされているモデルタイプ | 入力モダリティ | 出力モダリティ | 
| --- | --- | --- | --- | 
| InvokeModel | [推論プロファイル](inference-profiles-support.md) | テキスト<br />イメージ | 埋め込み | 
| StartAsyncInvoke | [ベースモデル](models-supported.md) | 動画<br />音声<br />画像<br />テキスト | 埋め込み | 

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

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


****  

| 入力モダリティ | 最大値 | 
| --- | --- | 
| テキスト | 77 トークン | 
| 画像 | 5 MB | 
| 動画 (S3) | 2 GB | 
| 音声 (S3) | 2 GB | 

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

**Topics**
+ [TwelveLabs Marengo Embed 2.7 リクエストパラメータ](#model-parameters-marengo-async-request)
+ [TwelveLabs Marengo Embed 2.7レスポンス](#model-parameters-marengo-response)
+ [TwelveLabs Marengo Embed 2.7 コードの例](#model-parameters-marengo-examples)

## TwelveLabs Marengo Embed 2.7 リクエストパラメータ
<a name="model-parameters-marengo-async-request"></a>

リクエストを行う際に、モデル固有の入力が指定されるフィールドは、API オペレーションによって異なります。
+ [InvokeModel](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModel.html) – リクエストの `body`。
+ [StartAsyncInvoke](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_StartAsyncInvoke.html) – リクエスト本文の `modelInput` フィールド。

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

------
#### [ 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}}
}
```

------

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

### inputType
<a name="model-parameters-marengo-inputType"></a>

埋め込み用のモダリティ。
+ **タイプ:** 文字列
+ **必須**: はい
+ 有効な値: `video` \| `text` \| `audio` \| `image`

### inputText
<a name="model-parameters-marengo-inputText"></a>

埋め込むテキスト。
+ **タイプ:** 文字列
+ **必須:** はい (互換性のある入力タイプの場合)
+ **互換性のある入力タイプ:** テキスト

### textTruncate
<a name="model-parameters-marengo-textTruncate"></a>

プラットフォームでのテキストの切り捨て方法を指定します。
+ **タイプ:** 文字列
+ **必須:** いいえ
+ **有効な値:**
  + `end` – テキストの末尾を切り捨てます。
  + `none` – テキストが制限を超えた場合にエラーを返します
+ **デフォルト値:** end
+ **互換性のある入力タイプ:** テキスト

### mediaSource
<a name="model-parameters-marengo-mediaSource"></a>

メディアソースに関する情報が含まれます。
+ **タイプ:** オブジェクト
+ **必須:** はい (互換性のあるタイプの場合)
+ **互換性のある入力タイプ:** 画像、動画、音声

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

  ```
  {
      "mediaSource": {
          "base64String": "base64-encoded string"
      }
  }
  ```
  + `base64String` – メディアに対して Base64 でエンコードされた文字列。
+ **S3 の場所** – S3 URI とバケット所有者を指定します。

  ```
  {
      "s3Location": {
          "uri": "string",
          "bucketOwner": "string"
      }
  }
  ```
  + `uri` – メディアを含む S3 URI。
  + `bucketOwner` – S3 バケット所有者の AWS アカウント ID。

### embeddingOption
<a name="model-parameters-marengo-embeddingOption"></a>

取得する埋め込みのタイプを指定します。
+ **タイプ**: リスト
+ **必須:** いいえ
+ **リストメンバーの有効な値:**
  + `visual-text` – テキスト検索用に最適化されたビジュアル埋め込み。
  + `visual-image` – 画像検索用に最適化されたビジュアル埋め込み。
  + `audio` – 動画内の音声の埋め込み。
+ **デフォルト値:** ["visual-text", "visual-image", "audio"]
+ **互換性のある入力タイプ:** 動画、音声

### startSec
<a name="model-parameters-marengo-startSec"></a>

処理が開始されるクリップの時点 (秒単位)。
+ 型: 倍精度
+ **必須:** いいえ
+ **最小値:** 0
+ **デフォルト値:** 0
+ **互換性のある入力タイプ:** 動画、音声

### lengthSec
<a name="model-parameters-marengo-lengthSec"></a>

処理を停止するまでの時間 (秒単位)。`startSec` 時点からカウントされます。
+ 型: 倍精度
+ **必須:** いいえ
+ **有効な値:** 0～メディアの時間
+ **デフォルト値:** メディアの時間
+ **互換性のある入力タイプ:** 動画、音声

例:
+ startSec: 5
+ lengthSec: 20
+ 結果: クリップは 0:05 から 0:25 (5 秒 \+ 20 秒) まで処理されます。

### useFixedLengthSec
<a name="model-parameters-marengo-useFixedLengthSec"></a>

モデルが埋め込みを生成する対象となる各クリップの時間。
+ 型: 倍精度
+ **必須:** いいえ
+ **値パラメータ:** 2～10。`minClipSec` 以上である必要があります。
+ **デフォルト値:** メディアのタイプによって異なります。
  + **動画:** ショット境界検出によって動的に分割されます。
  + **音声:** できるだけ 10 秒に近いセグメントで均等に分割されます。

    例:
    + 50 秒のクリップは 5 つの 10 秒のセグメントに分割されます。
    + 16 秒のクリップは 2 つの 8 秒のセグメントに分割されます。
+ **互換性のある入力タイプ:** – 動画、音声
+ **注:** `minClipSec` 以上である必要があります。

### minClipSec
<a name="model-parameters-marengo-minClipSec"></a>

各クリップの最小値を秒単位で設定します。
+ **タイプ:** int
+ **必須:** いいえ
+ **値パラメータ:** 範囲: 1～5
+ **デフォルト値:** 4
+ **互換性のある入力タイプ:** 動画
+ **注:** `useFixedLengthSec` 以下である必要があります。

## TwelveLabs Marengo Embed 2.7レスポンス
<a name="model-parameters-marengo-response"></a>

出力埋め込みおよび関連するメタデータの場所は、呼び出しメソッドによって異なります。
+ [InvokeModel](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModel.html) – レスポンス本文内。
+ [StartAsyncInvoke](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_StartAsyncInvoke.html) – 非同期呼び出しジョブが完了した後、`s3OutputDataConfig` で定義される S3 バケット内。

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

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

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

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

### 埋め込み
<a name="model-parameters-marengo-embedding"></a>

入力のベクトル表現を埋め込みます。
+ **タイプ:** double のリスト

### embeddingOption
<a name="model-parameters-marengo-embeddingOption"></a>

埋め込みのタイプ。
+ **タイプ:** 文字列
+ **指定できる値:**
  + `visual-text` – テキスト検索用に最適化されたビジュアル埋め込み。
  + `visual-image` – 画像検索用に最適化されたビジュアル埋め込み。
  + `audio` – 動画内の音声の埋め込み。
+ **互換性のある入力タイプ:** 動画

### startSec
<a name="model-parameters-marengo-startSec"></a>

クリップの開始オフセット。
+ 型: 倍精度
+ **互換性のある入力タイプ:** 動画、音声

### endSec
<a name="model-parameters-marengo-endSec"></a>

クリップの終了オフセット (秒単位)。
+ 型: 倍精度
+ **互換性のある入力タイプ:** 動画、音声

## TwelveLabs Marengo Embed 2.7 コードの例
<a name="model-parameters-marengo-examples"></a>

このセクションでは、Python を使用して異なる入力タイプを備えた TwelveLabs Marengo Embed 2.7 モデルを使用する方法を示します。この例では、モデル固有の入力を定義し、モデル呼び出しを実行する方法を示します。

**注記**  
InvokeModel はテキストとイメージの入力のみをサポートします。ビデオおよびオーディオ入力の場合は、StartAsyncInvoke を使用します。

次の手順でコードを組み立てます。

**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}")
```

------