

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

# Fine-tune Amazon Nova 具有监督微调功能的模型
<a name="nova-2-sft-data-prep"></a>

Amazon Nova2.0 SFT 数据使用与 Amazon Nova 1.0 相同的 Converse API 格式，但增加了可选的推理内容字段。有关完整的格式规范，请参阅[ReasoningContentBlock](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ReasoningContentBlock.html)和 [Converse API 架构](https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference-call.html)。

**支持的功能：**
+ **输入类型**：用户内容块中的文本、图像或视频
+ **助手内容**- Text-only 回复和推理内容
+ **数据集构成**：必须为同构数据。选择以下选项之一：纯文字转弯、文字\+图像转弯或文字\+视频转弯

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

**目前的局限性：**
+ **工具用法**-尽管输入格式支持使用工具，但 Amazon Nova 2.0 SFT 目前不支持使用工具。添加工具部分可能会导致您的任务失败。
+ **多模态推理内容** — 尽管 Converse 格式支持基于图像的推理内容，但 2.0 SFT 不支持这一点。Amazon Nova
+ **验证集**-用户界面可能支持提供验证集，但在 SFT 训练期间不支持提供验证集。

**支持的媒体格式：**
+ **图像**：PNG、JPEG、GIF
+ **视频**：MOV、MKV、MP4

## 数据格式示例
<a name="nova-2-sft-data-examples"></a>

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

------

## 推理内容
<a name="nova-2-reasoning-modes"></a>

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

**损失是如何计算的：**
+ **包含推理内容**：训练损失同时计入推理词元和最终输出词元
+ **不含推理内容**：训练损失仅基于最终输出词元计算

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

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

**格式指南：**
+ 使用纯文本进行推理内容。
+ 除非您的任务特别要求，`</thinking>`否则请避免使用`<thinking>`和之类的标记标记。
+ 确保推理内容清晰且与问题解决过程相关。

**有效的推理内容应包括：**
+ 中间思考与分析
+ 逻辑推导与推理步骤
+ Step-by-step 解决问题的方法
+ 推理步骤与结论之间的明确关联

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

## 数据集准备指南
<a name="nova-2-dataset-preparation"></a>

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


**数据集准备指南**  

| 指南 | 说明 | 
| --- | --- | 
| 尺寸和质量 |  [See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/nova-2-sft-data-prep.html)  | 
| 多样性 | 包括执行以下操作的不同示例：[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/nova-2-sft-data-prep.html) | 
| 输出格式 | 在助手响应中明确指定所需的输出格式。示例包括 JSON 结构、表格、CSV 格式或特定于您的应用程序的自定义格式。 | 
| Multi-turn 对话 |  [See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/nova-2-sft-data-prep.html)  | 
| 质量清单 |  [See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/nova-2-sft-data-prep.html)  | 