本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
准备用于微调图像和文本处理模型的数据
注意
有关微调 Amazon Nova 模型的信息,请参阅微调 Amazon Nova 模型。
在微调图像-文本转文本模型时,每个 JSON 对象代表一个示例,其中包含一个采用 messages 数组结构的对话,此数组由交替排列的 JSON 对象组成,分别代表用户输入和助手响应。用户输入可以同时包含文本和图像,而助手响应始终为文本形式。此结构同时支持单回合和多回合对话流程,可让模型高效处理各类任务。Meta Llama-3.2 11B Vision Instruct 和 Meta Llama-3.2 90B Vision
Instruct 支持的图像格式包括:gif、jpeg、png 和 webp。
要允许 Amazon Bedrock 访问图像文件,请将类似于 访问训练文件和验证文件以及在 S3 中写入输出文件的权限 中的 IAM 策略的策略添加到您在控制台中设置或系统自动设置的 Amazon Bedrock 模型自定义服务角色。您在训练数据集内提供的 Amazon S3 路径必须位于您在策略中指定的文件夹中。
单回合对话
在单回合对话中,每个 JSON 对象均由一条用户消息和一条助手消息组成。用户消息包含一个设置为 user 的角色字段和一个包含数组的 content 字段,数组中的 type 字段(text 或 image)描述了输入模态。对于文本输入,content 字段包含一个 text 字段,该字段包含用户的问题或提示。对于图像输入,content 字段指定图像 format(例如,jpeg、png),其 source 包含一个指向图像的 Amazon S3 位置的 uri。uri 表示存储在 Amazon S3 存储桶中的图像的唯一路径,其格式通常为 s3://<bucket-name>/<path-to-file>。助手消息包括一个设置为 assistant 的 role 字段和一个包含数组的 content 字段,此数组中的 type 字段设置为 text,text 字段包含助手生成的响应。
示例格式
{ "schemaVersion": "bedrock-conversation-2024", "system": [{ "text": "You are a smart assistant that answers questions respectfully" }], "messages": [{ "role": "user", "content": [{ "text": "What does the text in this image say?" }, { "image": { "format": "png", "source": { "s3Location": { "uri": "s3://your-bucket/your-path/your-image.png", "bucketOwner": "your-aws-account-id" } } } } ] }, { "role": "assistant", "content": [{ "text": "The text in the attached image says 'LOL'." }] } ] }
多回合对话
在多回合对话中,每个 JSON 对象均包含一系列角色交替的消息,其中用户消息与助手消息的结构保持一致,以实现连贯的交互。用户消息包括一个设置为 user 的 role 字段和一个描述输入模态的 content 字段。对于文本输入,content 字段中有一个包含用户的问题或后续信息的 text 字段,而对于图像输入,该字段指定图像 format 及其 source(其中包含一个指向图像的 Amazon S3 位置的 uri)。uri 用作格式为 s3://<bucket-name>/<path-to-file> 的唯一标识符,并且可让模型访问指定的 Amazon S3 存储桶中的对象。助手消息包括一个设置为 assistant 的 role 字段和一个包含数组的 content 字段,此数组中的 type 字段设置为 text,text 字段包含助手生成的响应。对话可跨多轮交互,使助手能够保持上下文连贯性并提供一致的响应。
示例格式
{ "schemaVersion": "bedrock-conversation-2024", "system": [{ "text": "You are a smart assistant that answers questions respectfully" }], "messages": [{ "role": "user", "content": [{ "text": "What does the text in this image say?" }, { "image": { "format": "png", "source": { "s3Location": { "uri": "s3://your-bucket/your-path/your-image.png", "bucketOwner": "your-aws-account-id" } } } } ] }, { "role": "assistant", "content": [{ "text": "The text in the attached image says 'LOL'." }] }, { "role": "user", "content": [{ "text": "What does the text in this image say?" } ] }, { "role": "assistant", "content": [{ "text": "The text in the attached image says 'LOL'." }] } ] }