新版本 2.0 上的 SFT - Amazon SageMaker AI

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

新版本 2.0 上的 SFT

Amazon Nova Lite 2.0 為監督式微調提供了增強功能,包括進階推理模式、改善多模態理解和延伸內容處理。在 Nova 2.0 上的 SFT 可讓您將這些強大的功能適應您的特定使用案例,同時在複雜的任務上維持模型的卓越效能。

SFT on Nova 2.0 的主要功能包括:

  • 推理模式支援:訓練模型在增強型分析功能的最終答案之前產生明確的推理追蹤。

  • 進階多模式訓練:微調文件理解 (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,但仍想要在推論期間使用推理:

  1. 在訓練期間停用推理 (reasoning_enabled: false)

  2. 稍後在推論期間啟用推理

雖然此方法允許在推論時間進行推理,但與推論相比,它不保證改善效能,無需推理。

最佳實務:使用推理資料集時啟用訓練和推論的推理,並在使用非合理的資料集時停用兩者的推理。

工具呼叫資料格式

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 必須參考先前助理 ToolUse 中的有效 ToolUse toolUseId,每個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><training-file><validation-directory>和 取代<validation-file>為實際的 S3 路徑。

注意:搭配 Amazon Nova 2.0 的 SFT 目前不支援驗證資料集。如果提供了驗證資料集,則會予以忽略。

建立微調任務

使用 run 區塊中的 model_typemodel_name_or_path 欄位來定義基本模型:

## Run config run: ... model_type: amazon.nova-2-lite-v1:0:256k model_name_or_path: nova-lite-2/prod ...

超參數指引

根據訓練方法,使用以下建議的超參數:

完整排名訓練

  • Epochs:1

  • 學習率 (lr):1e-5

  • 最低學習率 (min_lr):1e-6

LoRA (低排名調整)

  • Epochs:2

  • 學習率 (lr):5e-5

  • 最低學習率 (min_lr):1e-6

注意:根據資料集大小和驗證效能調整這些值。監控訓練指標,以防止過度擬合。