本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
Nova 2.0 上的 SFT
Amazon Nova Lite 2.0 带来了增强的监督微调功能,包括高级推理模式、改进的多模态理解和扩展的上下文处理。Nova 2.0 上的 SFT 使您能够根据自己的特定用例调整这些强大功能,同时保持模型在复杂任务中的卓越性能。
Nova 2.0 上的 SFT 的主要功能包括:
-
推理模式支持:训练模型以在最终答案之前生成明确的推理轨迹,从而增强分析能力。
-
高级多模态训练:对文档理解 (PDF)、视频理解和基于图像的任务进行微调,提高准确性。
-
工具调用功能:训练模型以有效使用外部工具和函数调用来处理复杂的工作流程。
-
扩展的上下文支持:利用更长的上下文窗口,为文档密集型应用程序提供更好的稳定性和准确性。
推理模式选择(仅限 Nova 2.0)
Amazon Nova 2.0 支持推理模式以增强分析能力:
-
推理模式(已启用):
-
reasoning_enabled: true在训练配置中设置 -
模型训练可在最终答案之前生成推理轨迹
-
提高复杂推理任务的性能
-
-
非推理模式(已禁用):
-
设置
reasoning_enabled: false或省略参数(默认) -
没有明确推理的标准 SFT
-
适用于无法从 step-by-step推理中受益的任务
-
注意
-
启用推理后,它会以高推理力度运行。SFT 没有低推理选项。
-
SFT 不支持多模态推理内容。推理模式适用于纯文本输入。
允许使用reasoning_enabled:
true非推理数据集训练 Amazon Nova。但是,这样做可能会导致模型失去其推理能力,因为Amazon Nova主要学习在不应用推理的情况下生成数据中呈现的响应。
如果在非推理数据集上训练 Amazon Nova,但仍想在推理期间使用推理:
-
在训练期间禁用推理 (
reasoning_enabled: false) -
稍后在推理期间启用推理
虽然这种方法允许在推理时进行推理,但与不进行推理的推理相比,它并不能保证性能得到改善。
最佳实践:在使用推理数据集时,为训练和推理启用推理,在使用非推理数据集时为两者都禁用推理。
工具调用数据格式
SFT 支持训练模型以使用工具(函数调用)。以下是用于调用工具的示例输入格式:
示例输入:
{ "schemaVersion": "bedrock-conversation-2024", "system": [ { "text": "You are an expert in composing function calls." } ], "toolConfig": { "tools": [ { "toolSpec": { "name": "getItemCost", "description": "Retrieve the cost of an item from the catalog", "inputSchema": { "json": { "type": "object", "properties": { "item_name": { "type": "string", "description": "The name of the item to retrieve cost for" }, "item_id": { "type": "string", "description": "The ASIN of item to retrieve cost for" } }, "required": [ "item_id" ] } } } }, { "toolSpec": { "name": "getItemAvailability", "description": "Retrieve whether an item is available in a given location", "inputSchema": { "json": { "type": "object", "properties": { "zipcode": { "type": "string", "description": "The zipcode of the location to check in" }, "quantity": { "type": "integer", "description": "The number of items to check availability for" }, "item_id": { "type": "string", "description": "The ASIN of item to check availability for" } }, "required": [ "item_id", "zipcode" ] } } } } ] }, "messages": [ { "role": "user", "content": [ { "text": "I need to check whether there are twenty pieces of the following item available. Here is the item ASIN on Amazon: id-123. Please check for the zipcode 94086" } ] }, { "role": "assistant", "content": [ { "reasoningContent": { "reasoningText": { "text": "The user wants to check how many pieces of the item with ASIN id-123 are available in the zipcode 94086" } } }, { "toolUse": { "toolUseId": "getItemAvailability_0", "name": "getItemAvailability", "input": { "zipcode": "94086", "quantity": 20, "item_id": "id-123" } } } ] }, { "role": "user", "content": [ { "toolResult": { "toolUseId": "getItemAvailability_0", "content": [ { "text": "[{\"name\": \"getItemAvailability\", \"results\": {\"availability\": true}}]" } ] } } ] }, { "role": "assistant", "content": [ { "text": "Yes, there are twenty pieces of item id-123 available at 94086. Would you like to place an order or know the total cost?" } ] } ] }
工具调用数据的重要注意事项:
-
ToolUse 只能出现在助手回合中
-
ToolResult 只能出现在用户回合中
-
ToolResult 应仅为文本或 JSON;Amazon Nova 机型目前不支持其他模式
-
ToolSpec 中的 InputSchema 必须是有效的 JSON 架构对象
-
每个人都 ToolResult 必须引用前一位助手 toolUseId 的有效信息 ToolUse,每个助手每次对话只能 toolUseId 使用一次
了解数据格式的文档
SFT 支持文档理解任务的训练模型。以下是输入格式示例:
样本输入
{ "schemaVersion": "bedrock-conversation-2024", "messages": [ { "role": "user", "content": [ { "text": "What are the ways in which a customer can experience issues during checkout on Amazon?" }, { "document": { "format": "pdf", "source": { "s3Location": { "uri": "s3://my-bucket-name/path/to/documents/customer_service_debugging.pdf", "bucketOwner": "123456789012" } } } } ] }, { "role": "assistant", "content": [ { "text": "Customers can experience issues with 1. Data entry, 2. Payment methods, 3. Connectivity while placing the order. Which one would you like to dive into?" } ], "reasoning_content": [ { "text": "I need to find the relevant section in the document to answer the question.", "type": "text" } ] } ] }
理解文档的重要注意事项:
-
仅支持 PDF 文件
-
最大文档大小为 10 MB
-
样本可以包含文档和文本,但不能将文档与其他形式(例如图像或视频)混合使用
SFT 视频理解
SFT 支持视频理解任务的微调模型。以下是输入格式示例:
样本输入
{ "schemaVersion": "bedrock-conversation-2024", "messages": [ { "role": "user", "content": [ { "text": "What are the ways in which a customer can experience issues during checkout on Amazon?" }, { "video": { "format": "mp4", "source": { "s3Location": { "uri": "s3://my-bucket-name/path/to/videos/customer_service_debugging.mp4", "bucketOwner": "123456789012" } } } } ] }, { "role": "assistant", "content": [ { "text": "Customers can experience issues with 1. Data entry, 2. Payment methods, 3. Connectivity while placing the order. Which one would you like to dive into?" } ], "reasoning_content": [ { "text": "I need to find the relevant section in the video to answer the question.", "type": "text" } ] } ] }
理解视频的重要注意事项:
-
视频的最大容量为 50 MB
-
视频最长可达 15 分钟
-
每个样本只允许一个视频;不支持同一样本中的多个视频
-
样本可以包含视频和文本,但不能将视频与其他形式(例如图像或文档)混合使用
数据上传说明
将训练和验证数据集上传到 S3 存储桶。在食谱方run块中指定以下位置:
## Run config run: ... data_s3_path: "s3://<bucket-name>/<training-directory>/<training-file>.jsonl"
注意:将<bucket-name>、、<training-directory><validation-directory><training-file>、和<validation-file>替换为实际的 S3 路径。
注意:搭载 Amazon Nova 2.0 的 SFT 目前不支持验证数据集。如果提供了验证数据集,则该数据集将被忽略。
创建微调 Job
使用run模块中的model_type和model_name_or_path字段定义基础模型:
## Run config run: ... model_type: amazon.nova-2-lite-v1:0:256k model_name_or_path: nova-lite-2/prod ...
超参数指导
根据训练方法,使用以下推荐的超参数:
全等级训练
-
时代:1
-
学习率 (lr):1e-5
-
最低学习率 (min_lr):1e-6
LoRa(低等级适应)
-
时代:2
-
学习率 (lr):5e-5
-
最低学习率 (min_lr):1e-6
注意:根据数据集大小和验证性能调整这些值。监控训练指标以防止过度拟合。