View a markdown version of this page

Fine-tune Amazon Nova 具有监督微调功能的模型 - Amazon Bedrock

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

Fine-tune Amazon Nova 具有监督微调功能的模型

Amazon Nova2.0 SFT 数据使用与 Amazon Nova 1.0 相同的 Converse API 格式,但增加了可选的推理内容字段。有关完整的格式规范,请参阅ReasoningContentBlockConverse API 架构

支持的功能:

  • 输入类型:用户内容块中的文本、图像或视频

  • 助手内容- Text-only 回复和推理内容

  • 数据集构成:必须为同构数据。选择以下选项之一:纯文字转弯、文字+图像转弯或文字+视频转弯

重要

不得在同一数据集中或不同对话轮次间混合使用图像和视频。

目前的局限性:

  • 工具用法-尽管输入格式支持使用工具,但 Amazon Nova 2.0 SFT 目前不支持使用工具。添加工具部分可能会导致您的任务失败。

  • 多模态推理内容 — 尽管 Converse 格式支持基于图像的推理内容,但 2.0 SFT 不支持这一点。Amazon Nova

  • 验证集-用户界面可能支持提供验证集,但在 SFT 训练期间不支持提供验证集。

支持的媒体格式:

  • 图像:PNG、JPEG、GIF

  • 视频:MOV、MKV、MP4

数据格式示例

Text-only

此示例显示了与 Amazon Nova 1.0 兼容的基本纯文本格式。

{ "schemaVersion": "bedrock-conversation-2024", "system": [ { "text": "You are a digital assistant with a friendly personality" } ], "messages": [ { "role": "user", "content": [ { "text": "What country is right next to Australia?" } ] }, { "role": "assistant", "content": [ { "text": "The closest country is New Zealand" } ] } ] }
Text with reasoning

此示例显示了带有 Amazon Nova 2.0 可选推理内容的文本。

{ "schemaVersion": "bedrock-conversation-2024", "system": [ { "text": "You are a digital assistant with a friendly personality" } ], "messages": [ { "role": "user", "content": [ { "text": "What country is right next to Australia?" } ] }, { "role": "assistant", "content": [ { "reasoningContent": { "reasoningText": { "text": "I need to use my world knowledge of geography to answer this question" } } }, { "text": "The closest country to Australia is New Zealand, located to the southeast across the Tasman Sea." } ] } ] }
注意

当前,内部reasoningText仅支持reasoningContent。多模态推理内容尚不可用。

Image + text

此示例说明如何在文本中包含图像输入。

{ "schemaVersion": "bedrock-conversation-2024", "system": [ { "text": "You are a helpful assistant." } ], "messages": [ { "role": "user", "content": [ { "image": { "format": "jpeg", "source": { "s3Location": { "uri": "s3://your-bucket/your-path/your-image.jpg", "bucketOwner": "your-aws-account-id" } } } }, { "text": "Which country is highlighted in the image?" } ] }, { "role": "assistant", "content": [ { "reasoningContent": { "reasoningText": { "text": "I will determine the highlighted country by examining its location on the map and using my geographical knowledge" } } }, { "text": "The highlighted country is New Zealand" } ] } ] }
Video + text

此示例说明如何在文本中加入视频输入。

{ "schemaVersion": "bedrock-conversation-2024", "system": [ { "text": "You are a helpful assistant." } ], "messages": [ { "role": "user", "content": [ { "video": { "format": "mp4", "source": { "s3Location": { "uri": "s3://your-bucket/your-path/your-video.mp4", "bucketOwner": "your-aws-account-id" } } } }, { "text": "What is shown in this video?" } ] }, { "role": "assistant", "content": [ { "reasoningContent": { "reasoningText": { "text": "I will analyze the video content to identify key elements" } } }, { "text": "The video shows a map with New Zealand highlighted" } ] } ] }

推理内容

推理内容(亦称思维链)会记录模型在生成最终答案前的中间思考步骤。在 assistant 轮次中,可通过 reasoningContent 字段加入这些推理轨迹。

损失是如何计算的:

  • 包含推理内容:训练损失同时计入推理词元和最终输出词元

  • 不含推理内容:训练损失仅基于最终输出词元计算

何时启用推理模式:reasoning_enabled: true在训练配置中设置您希望模型在生成最终输出之前生成思维标记,或者需要提高复杂推理任务的性能。设置reasoning_enabled: false当你在训练那些无法从明确的推理步骤中受益的简单任务时。

注意

无论您的训练数据是否包含推理内容,您都可以启用推理模式。但是,建议在训练数据中加入推理轨迹,以便模型可以从这些示例中学习并提高推理质量。

格式指南:

  • 使用纯文本进行推理内容。

  • 除非您的任务特别要求,</thinking>否则请避免使用<thinking>和之类的标记标记。

  • 确保推理内容清晰且与问题解决过程相关。

有效的推理内容应包括:

  • 中间思考与分析

  • 逻辑推导与推理步骤

  • Step-by-step 解决问题的方法

  • 推理步骤与结论之间的明确关联

如果数据集缺失推理轨迹,可借助 Nova Premier 等具备推理能力的模型来生成。将输入-输出对提供给模型,记录其推理过程,从而构建包含推理内容的增强型数据集。

数据集准备指南

下表提供了准备训练数据集的指南。

数据集准备指南
指南 说明
尺寸和质量
  • 建议大小:2,000-10,000 个样本

  • 最低样本数:200

  • 优先考虑质量而不是数量。确保示例准确且注释良好。

  • 数据集应密切反映您的生产用例。

多样性

包括执行以下操作的不同示例:

  • 覆盖所有预期输入类型

  • 包含不同难度级别的样本

  • 纳入边界情况与各类变体

  • 避免模型过拟合于单一模式

输出格式

在助手响应中明确指定所需的输出格式。示例包括 JSON 结构、表格、CSV 格式或特定于您的应用程序的自定义格式。

Multi-turn 对话
  • 损失仅在助手回合中计算,不计算用户回合。

  • 每个助手回复的格式都应正确。

  • 在对话回合中保持一致性。

质量清单
  • 足够的数据集大小(2,000-10,000 个样本)

  • 涵盖所有使用案例的多样化样本

  • 输出格式清晰统一

  • 标签与标注准确无误

  • 贴合实际生产场景

  • 无矛盾或歧义内容