AWS Machine Learning Blog

Pegasus 1.5 from TwelveLabs is now available in Amazon Bedrock

6.9内容质量
Pegasus 1.5 from TwelveLabs is now available in Amazon Bedrock

TL;DR · AI 摘要

Pegasus 1.5 from TwelveLabs is now available in Amazon Bedrock Artificial Intelligence Pegasus 1.5 from TwelveLabs is no...

核心要点

  • 主题聚焦:Pegasus 1.5 from TwelveLabs is now available in
  • 来源:AWS Machine Learning Blog,建议结合原文判断细节。
  • AI 分析暂不可用,本条为保底评分与摘要。
#AI#编程#后端#云计算#安全
打开原文

TwelveLabs 的 Pegasus 1.5 现已上线 Amazon Bedrock | 人工智能

TwelveLabs 的 Pegasus 1.5 现已上线 Amazon Bedrock

2026年10月9日,我们宣布 TwelveLabs 的 Pegasus 1.5 现已上线 Amazon Bedrock。Pegasus 1.5 是一个视频语言模型,能够将长视频内容转换为结构化的时间戳元数据。您只需描述对工作流程重要的关键时刻,模型就会以 JSON 格式返回所有匹配的视频片段。

视频作为非结构化数据中重要且复杂的类别,但目前大部分视频仍无法搜索且未被充分利用。从这些内容中提取结构化、可操作的洞察信息,过去通常需要耗费大量人力的 manual review 或分散的工具链。

在早期版本的 Pegasus 中,您只需将视频片段指向模型并提出问题即可获得答案。现在,Pegasus 1.5 能够分析整个视频,找出所有符合用户自定义条件的片段,并返回结构化的时间戳元数据。同时新增了视频分割、结合参考图像的多模态提示以及实时处理功能。

通过 Amazon Bedrock 上的 Pegasus 1.5,您无需预索引即可直接从 Amazon Simple Storage Service (Amazon S3) URI 或 base64 字符串分析视频,且数据始终保留在 AWS 数据边界内。

本文将介绍 Pegasus 1.5 的新功能、模型在 Amazon Bedrock 上的封装方式以及如何发送首个请求。随后我们将演示视频分割、结构化 JSON 输出和多模态提示的使用方法。

Pegasus 1.5 的新功能

与早期版本相比,Pegasus 1.5 包含以下改进:

  • 基于时间的元数据生成。您可以定义对工作流程重要的片段、事件或领域特定提示(如编辑片段、体育比赛、发言人切换或品牌出现)。Pegasus 1.5 会以 JSON 格式返回所有匹配片段,并包含起止时间及请求字段的填充内容。
  • 多模态提示。片段定义可以结合文本描述与视觉参考。这使得可以定位特定产品、logo 或人物,同时识别其在屏幕上的行为。
  • 实时处理。无需数据摄取管道或预索引步骤。视频可直接从 Amazon S3 发送,结果会包含在响应中。
  • 扩展的处理能力。Pegasus 1.5 单次请求可分析长达两小时的视频(此前 Pegasus 1.2 仅支持一小时)。

Pegasus 1.5 保留并增强了使 Pegasus 1.2 成为强大视频理解工具的核心能力,包括:

  • 视频到文本生成:基于视频内容生成详细文本描述。
  • 细粒度视觉理解:分析视频帧中的物体、屏幕文字和数字内容。
  • 时间定位:准确识别视频中特定事件的时间戳。
  • 多模态理解:结合视觉、音频和文本信息进行综合分析。
  • 多语言支持:全面支持英语,部分支持阿拉伯语、中文、法语、德语、意大利语、日语、韩语、葡萄牙语、俄语、西班牙语、泰语和越南语。

Pegasus 1.5 接收视频以及文本提示或一组分段定义,并返回文本或 JSON 格式的数据。您可以通过 bedrock-runtime 端点使用 InvokeModel API 调用它,或者在需要流式传输响应时使用 InvokeModelWithResponseStream。

设置

值

模型 ID

code
twelvelabs.pegasus-1-5-v1:0

AWS 区域

美国西部(俄勒冈),

code
us-west-2

推理方式

按需

API

code
InvokeModel

,

code
InvokeModelWithResponseStream

每个请求会在两种分析模式中运行,通过 analysisMode 字段选择模式:

分析模式

analysisMode

您发送

您得到

通用模式

code
general

(默认)

在

code
inputPrompt

中发送文本提示

在

code
message

中返回文本答案,或在提供模式时返回 JSON

基于时间的元数据

code
time_based_metadata

在

code
responseFormat

中发送分段定义

返回包含开始和结束时间以及您请求字段的

code
segments

列表

您可以通过两种方式将视频指向模型。S3 位置(s3Location)需要对象的 URI 和存储桶所有者账户 ID,适合长视频。Base64 字符串(base64String)将视频嵌入请求体中,最大 25 MB,适合短视频。

为按应用跟踪成本,请从 Pegasus 1.5 模型创建一个应用推理配置文件,进行标记,并通过其 Amazon 资源名称(ARN)而非模型 ID 调用。

开始使用 Pegasus 1.5

以下部分概述了如何开始使用 Pegasus 1.5。

先决条件

开始之前,请确保您具备以下条件:

  • 一个具有 Amazon Bedrock 访问权限的活动 AWS 账户。
  • Python 3.10 或更高版本,并已安装 Python 的 AWS SDK(Boto3)。
  • 对 bedrock:InvokeModel 和 bedrock:InvokeModelWithResponseStream 的 AWS 身份和访问管理(IAM)权限。
  • 在 Amazon Bedrock 控制台中已启用 TwelveLabs Pegasus 1.5 的模型访问权限。
  • 存储在 Amazon S3 存储桶中的视频,或可以内联发送的短视频。

以下策略为 Pegasus 1.5 授予了两种调用操作权限。

code
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "bedrock:InvokeModel",
                "bedrock:InvokeModelWithResponseStream"
            ],
            "Resource": [
                "arn:aws:bedrock:us-west-2::foundation-model/twelvelabs.pegasus-1-5-v1:0"
            ]
        }
    ]
}

Boto3 使用您的常规 AWS 凭据对请求进行签名。您也可以通过在 AWS_BEARER_TOKEN_BEDROCK 环境变量中设置 Amazon Bedrock API 密钥进行身份验证。在生产环境中,建议使用通过 IAM 凭据生成的短期密钥(使用 aws-bedrock-token-generator 包),因为它们会自动过期。使用 bearer-token 身份验证还需要 bedrock:CallWithBearerToken 权限。

发送第一个请求

安装 Boto3:

code
pip install boto3

以下示例以通用模式分析存储在 Amazon S3 中的视频。此示例使用全局跨区域推理(CRIS)端点。若要针对美国地理区域端点,请将端点 URL 中的 “global.” 替换为 “us.”。

code
import boto3
import json
from botocore.config import Config

AWS_REGION = "us-west-2"
MODEL_ID = "global.twelvelabs.pegasus-1-5-v1:0"

bedrock_runtime = boto3.client( service_name="bedrock-runtime", region_name=AWS_REGION, config=Config(

对于视频分割等耗时操作,延长read_timeout

read_timeout=900, retries={"max_attempts": 0}, connect_timeout=10, ), )

分析存储在Amazon S3中的视频

payload = { "inputPrompt": "总结这个视频并识别讨论的关键主题。", "mediaSource": { "s3Location": { "uri": "s3://amzn-s3-demo-pegasus-15/your-video.mp4", "bucketOwner": "your-account-id" } }, "temperature": 0.2, "maxOutputTokens": 4096, "includeMetering": True }

response = bedrock_runtime.invoke_model( modelId=MODEL_ID, body=json.dumps(payload) ) result = json.loads(response["body"].read()) print(result["message"])

code

响应内容包含在message字段中,输入输出的token数量分别在input_tokens和output_tokens字段中,生成结束原因在stopReason字段中。当stopReason为"length"时,表示输出已达到maxOutputTokens限制,此时应检查输出内容:

if result["stopReason"] == "length": print("回答被截断。请提高maxOutputTokens参数值后重试。") print("输入token数:", result["input_tokens"], "输出token数:", result["output_tokens"])

code

通用模式请求参数说明:

字段

必填

描述

是

关于视频的问题或指令

mediaSource.s3Location.uri

code

必须提供一个视频源

视频的S3 URI

mediaSource.s3Location.bucketOwner

code

需与

uri

code

一起使用

拥有该存储桶的AWS账户ID

mediaSource.base64String

code

Base64编码的视频,最大25MB

temperature

code

否

输出随机性,取值范围0-1,默认0.2

maxOutputTokens

code

生成的最大token数,范围512-98,304

回答必须遵循的JSON Schema

analysisMode

code

(默认)或

对于短视频片段,可以使用base64编码直接传输视频而非从S3获取:

import base64

with open("your-video.mp4", "rb") as f: video_b64 = base64.b64encode(f.read()).decode("utf-8")

payload["mediaSource"] = {"base64String": video_b64} response = bedrock_runtime.invoke_model(modelId=MODEL_ID, body=json.dumps(payload)) print(json.loads(response["body"].read())["message"])

code

注意上述示例使用了可选参数includeMetering。设置includeMetering: True会使Pegasus 1.5在非流式响应中增加两个计费字段:outputTokenCount和inputVideoSecond(分析视频的持续时间,单位秒)。

### 流式传输响应

对于交互式应用,InvokeModelWithResponseStream会以生成块的方式返回响应。每个块包含message字段中的文本片段:

response = bedrock_runtime.invoke_model_with_response_stream( modelId=MODEL_ID, body=json.dumps(payload) ) for event in response["body"]: chunk = json.loads(event["chunk"]["bytes"]) print(chunk.get("message", ""), end="", flush=True) print()

code

### 返回结构化JSON

在通用模式下,可以限制回答遵循特定JSON Schema,使下游代码可直接解析。设置responseFormat.type为json_schema并在jsonSchema字段中指定模式。回答会以JSON字符串形式出现在message字段中:

payload = { "inputPrompt": "分析此视频并返回结构化摘要。", "mediaSource": { "s3Location": { "uri": "s3://amzn-s3-demo-pegasus-15/your-video.mp4", "bucketOwner": "your-account-id" } }, "temperature": 0, "maxOutputTokens": 2048, "includeMetering": True, "responseFormat": { "type": "json_schema", "jsonSchema": { "type": "object", "properties": { "summary": {"type": "string"}, "key_scenes": {"type": "array", "items": {"type": "string"}}, "setting": {"type": "string"} }, "required": ["summary", "key_scenes", "setting"] } } } response = bedrock_runtime.invoke_model(modelId=MODEL_ID, body=json.dumps(payload)) summary = json.loads(json.loads(response["body"].read())["message"]) print(summary["summary"]) for scene in summary["key_scenes"]: print(" -", scene)

code

### 视频分段:将视频转换为结构化数据

基于时间的元数据生成是Pegasus 1.5与早期版本最大的区别。您不再使用提示语,而是发送一个或多个分段定义,模型会返回与每个定义匹配的视频分段。

将analysisMode设置为time_based_metadata,responseFormat.type设置为segment_definitions。定义会替代inputPrompt,因此请省略该字段。每个定义包含:

- id:定义的名称,返回每个匹配分段的ID。

- description:匹配分段的特征描述。

- fields:为每个分段提取的值,每个值包含名称、类型(字符串、布尔值、数字、整数、数组或时间戳)和描述。

以下示例识别新闻播报中的每个编辑部分,并返回每个部分的标题、摘要和关键主题:

payload = { "analysisMode": "time_based_metadata", "mediaSource": { "s3Location": { "uri": "s3://amzn-s3-demo-pegasus-15/news-broadcast.mp4", "bucketOwner": "your-account-id" } }, "responseFormat": { "type": "segment_definitions", "segmentTimeFormat": "hh:mm:ss", "segmentDefinitions": [ { "id": "editorial_section", "description": "广播中一个明确的编辑部分," "例如新闻故事、主题或节目片段。", "fields": [ {"name": "segment_title", "type": "string", "description": "描述性标题"}, {"name": "summary", "type": "string", "description": "段落内容的简要摘要"}, {"name": "key_topics", "type": "array", "items": {"type": "string"}, "description": "讨论的主要主题"} ] } ] }, "temperature": 0, "maxOutputTokens": 32768, "includeMetering": True } response = bedrock_runtime.invoke_model( modelId=MODEL_ID, contentType="application/json", accept="application/json", body=json.dumps(payload) ) result = json.loads(response["body"].read()) for segment in result["segments"]: print(segment["start_sec"], "-", segment["end_sec"], segment["segment_title"]) print(" ", segment["summary"]) print(" topics:", ", ".join(segment["key_topics"]))

code

当使用体育比赛片段进行测试时,之前的示例代码可能会生成如下所示的输出。

{ "segments": [ { "start_sec": "00:04:24", "end_sec": "00:05:22", "segment_title": "Substitutions and Added Time", "summary": "The referee announces three minutes of added time, and both teams make substitutions in preparation for a potential penalty shootout.", "key_topics": ["Substitutions", "Added time", "Penalty shootout preparation", "Tactical changes"] }, { "start_sec": "00:05:22", "end_sec": "00:08:57", "segment_title": "Last Gasp Attempts and Final Whistle", "summary": "The final minutes of the match see intense action from both sides, with several close calls before the referee blows the final whistle, ending the game in a 3-3 draw.", "key_topics": ["Final whistle", "Draw"] }, { "start_sec": "00:08:57", "end_sec": "00:09:29", "segment_title": "Match Conclusion and Penalty Shootout Setup", "summary": "The match concludes with a 3-3 draw, leading to a penalty shootout. Players from both teams shake hands and prepare for the decisive moments.", "key_topics": ["Match conclusion", "Penalty shootout", "Player handshakes", "Final"] } ], "definition_errors": [], "input_tokens": 249408, "output_tokens": 802, "stopReason": "stop", "finish_reason": "stop" }

code

每个片段都包含 start_sec、end_sec 以及您定义的字段。segmentTimeFormat 控制时间的显示方式:seconds 返回可用于计算的数字,而 hh:mm:ss 和 hh:mm:ss.fff 返回可读的字符串格式时间戳。响应结果还包含一个 definition_errors 列表,当所有定义都成功处理时该列表为空。

单个请求可以包含多个片段定义,例如一个用于编辑部分,另一个用于屏幕上的品牌展示。Pegasus 1.5 会将所有匹配结果返回在同一个 segments 列表中,并通过 _definition_id 标记每个片段以便区分。以下示例在之前的请求中添加了第二个定义并分组结果:

from collections import defaultdict

payload["responseFormat"]["segmentDefinitions"].append({ "id": "brand_appearance", "description": "A shot where a company logo or branded product " "is clearly visible on screen.", "fields": [ {"name": "brand", "type": "string", "description": "The brand shown"}, {"name": "is_prominent", "type": "boolean", "description": "Whether the brand is the main focus of the shot"} ] }) response = bedrock_runtime.invoke_model(modelId=MODEL_ID, body=json.dumps(payload)) result = json.loads(response["body"].read()) by_definition = defaultdict(list) for segment in result["segments"]: by_definition[segment["_definition_id"]].append(segment) for definition_id, segments in by_definition.items(): print(definition_id, len(segments), "segments")

code

由于模式只需定义一次,相同的定义可以应用于整个视频库,为每个资产生成一致的元数据。

### 多模态提示:向查询中添加视觉上下文

Pegasus 1.5 引入了多模态提示功能,因此您可以在文本提示中包含参考图像。当您需要询问模型关于某些更容易展示而非描述的具体对象、人物或场景时,这项功能非常有用。

例如,您可以提供产品图像并要求模型识别该产品在视频中出现的所有时刻。或者您可以提供特定标志的参考图像,并要求模型检测品牌出现情况及其时间戳。这种能力提升了视频分析的精确度,同时开启了视觉品牌监控、产品植入分析和图像引导内容搜索等应用场景。

参考图像根据模式的不同具有不同的附加方式。在常规模式下,将它们放入 promptV2.mediaSources 中,并与 promptV2.inputText 中的问题一同放置。在分割模式(analysisMode: time_based_metadata)下,需要将它们附加到 responseFormat.segmentDefinitions 中每个片段定义的 mediaSources。这样定义可以同时匹配视觉参考和文本描述。每张图像都需要名称、media_type 为 image,以及一个来源:要么是内联的 base64String,要么是包含 uri 和 bucketOwner 的 s3Location。单个请求最多可携带 30 张参考图像。

常规模式请求询问模型参考图像中显示的对象。以下示例负载和响应展示了常规模式的示例。

payload = { "analysisMode": "general", "mediaSource": {"s3Location": {"uri": "s3://...", "bucketOwner": "..."}}, "promptV2": { "inputText": "参考图像中的物体是否出现在这个视频中?", "mediaSources": [ {"name": "ref1", "media_type": "image", "base64String": "..."} ] } … }

code

{ "input_tokens": 144, "output_tokens": 11, "message": "是的,绿色的独木舟出现在视频中。", "stopReason": "stop" }

code

在分割模式下,参考图像位于定义内部,因此 Pegasus 仅返回该产品出现的片段。以下示例负载和响应展示了分割模式的示例。

payload = { "analysisMode": "time_based_metadata", "mediaSource": {"s3Location": {"uri": "s3://...", "bucketOwner": "..."}}, "responseFormat": { "type": "segment_definitions", "segmentTimeFormat": "hh:mm:ss", "segmentDefinitions": [ { "id": "product_appearance", "description": "展示参考图像中产品的镜头", "fields": [ {"name": "what", "type": "string", "description": "屏幕上的内容是什么"} ], "mediaSources": [ {"name": "ref1", "media_type": "image", "s3Location": {"uri": "s3://...", "bucketOwner": "..."}} ] } ] } }

code

{ "segments": [ {"start_sec": "00:00:00", "end_sec": "00:00:02", "what": "一家四口乘坐绿色独木舟,在平静的河流上划行,周围是高耸的红色岩层。"}, {"start_sec": "00:00:09", "end_sec": "00:00:10", "what": "一家人回到独木舟中,远离岸边划行,孩子们面带微笑,享受宁静的环境。"} ], "definition_errors": [], "input_tokens": 4498, "output_tokens": 292, "stopReason": "stop", "finish_reason": "stop" }

code

### 监控使用情况

Pegasus 1.5 在 AWS/Bedrock 命名空间下,以模型 ID 为前缀发布 Amazon CloudWatch 指标,包括调用次数(Invocations)、输出令牌数量(OutputTokenCount)、调用延迟(InvocationLatency)和调用客户端错误(InvocationClientErrors)。利用这些指标可跟踪使用量和延迟情况。当需要按应用程序细分使用情况时,可将其与应用程序推理配置文件结合使用。

## 应用场景

Pegasus 1.5 专为需要处理大量长视频内容的组织设计:

- **新闻和广播档案**:团队可一次性定义编辑片段、主题和发言人变化,从而对过去仅能通过文字关键词搜索的数年视频素材进行系统化分类。
- **体育赛事转播机构和联盟**:在完整比赛视频中检测精彩瞬间、得分事件和其他关键时刻,显著提升集锦制作效率。
- **流媒体应用**:场景级元数据支持基于时刻的推荐、上下文广告投放和分段级品牌安全审核。

在所有场景中,人工参与始终是工作流程的重要组成部分。其工作内容从手动查找和标记每个时刻,转变为审核和优化模型生成的元数据。

## 输入要求

Pegasus 1.5 支持以下视频规格:

- **时长**:最长 2 小时。
- **文件大小**:从 Amazon S3 最大 2 GB,或作为 base64 字符串最大 25 MB。
- **分辨率**:360×360 至 5184×2160。
- **宽高比**:1:1 至 2.4:1 之间,或其倒数。
- **格式**:FFmpeg 支持的格式。

## 现已发布

TwelveLabs Pegasus 1.5 今日已在美国西部(俄勒冈)AWS 区域的 Amazon Bedrock 上线。请查看完整的区域列表以获取未来更新信息,并访问 Amazon Bedrock 定价页面了解费用详情。Pegasus 1.5 通过 AWS Marketplace 计费,因此相关费用将显示在您的 AWS 账单和 AWS 成本分析器中,归类于 TwelveLabs 而非 Amazon Bedrock。

**开始使用方法**:

- 访问 Amazon Bedrock 上的 TwelveLabs 模型页面,了解该模型系列的更多信息。
- 查阅 Pegasus 1.5 模型卡片,获取功能支持、区域可用性和示例代码。
- 通过 AWS re:Post for Amazon Bedrock 或常规 AWS 支持渠道向我们反馈意见。

我们期待看到您使用 TwelveLabs Pegasus 1.5 在 Amazon Bedrock 上构建的创新应用。

## 作者简介

'\"`