

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# 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-methods.md) 섹션을 참조하세요.
+ 사용자 정의 모델 유형에 대한 자세한 내용은 [Amazon Bedrock에서 추론이 작동하는 방식추론 작동 방식](inference-how.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) |  텍스트 이미지  |  임베딩  | 
| StartAsyncInvoke | [기본 모델](models-supported.md) |  비디오 오디오 이미지 텍스트  |  임베딩  | 

**참고**  
`InvokeModel`을 사용하여 검색 쿼리에 대한 임베딩을 생성합니다. `StartAsyncInvoke`를 사용하여 자산에 대한 임베딩을 대규모로 생성합니다.

입력에는 다음과 같은 할당량이 적용됩니다.


****  

| 입력 양식 | 최대 | 
| --- | --- | 
| 텍스트 | 토큰 77개 | 
| 이미지 | 5MB | 
| 비디오(S3) | 2GB | 
| 오디오(S3) | 2GB | 

**참고**  
base64 인코딩을 사용하여 오디오 또는 비디오를 인라인으로 정의하는 경우 요청 본문 페이로드가 Amazon Bedrock 25MB 모델 간접 호출 할당량을 초과하지 않는지 확인합니다.

**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` \$1 `text` \$1 `audio` \$1 `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>

처리가 시작되어야 하는 클립의 초 단위 시점입니다.
+ **유형**: Double
+ **필수 항목 여부**: 아니요
+ **최솟값:** 0
+ **기본값:** 0
+ **호환되는 입력 유형:** 비디오, 오디오

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

처리가 중지되어야 하는 `startSec` 시점부터 계산되는 초 단위 시간입니다.
+ **유형**: Double
+ **필수 항목 여부**: 아니요
+ **유효한 값:** 0 - 미디어 기간
+ **기본값:** 미디어 기간
+ **호환되는 입력 유형:** 비디오, 오디오

예제:
+ startSec: 5
+ lengthSec: 20
+ 결과: 클립은 0:05에서 0:25(5초 \$1 20초)까지 처리됩니다.

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

모델이 임베딩을 생성해야 하는 각 클립의 기간입니다.
+ **유형**: Double
+ **필수 항목 여부**: 아니요
+ **값 파라미터:** 2\$110. `minClipSec`보다 크거나 같아야 합니다.
+ **기본값:** 미디어 유형에 따라 다름:
  + **비디오:** 샷 경계 감지로 동적으로 나뉩니다.
  + **오디오:** 가능한 한 10초에 가까운 세그먼트로 균등하게 분할됩니다.

    예시:
    + 50초 클립은 5개의 10초 세그먼트로 나뉩니다.
    + 16초 클립은 8초 세그먼트 2개로 나뉩니다.
+ **호환되는 입력 유형:** - 비디오, 오디오
+ **참고:** `minClipSec`보다 크거나 같아야 합니다.

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

각 클립의 최솟값을 초 단위로 설정합니다.
+ **유형:** int
+ **필수 항목 여부**: 아니요
+ **값 파라미터:** 범위: 1\$15
+ **기본값:** 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>

클립의 시작 오프셋입니다.
+ **유형**: Double
+ **호환되는 입력 유형:** 비디오, 오디오

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

클립의 끝 오프셋으로, 초 단위입니다.
+ **유형**: Double
+ **호환되는 입력 유형:** 비디오, 오디오

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

------