

# Nova 2.0 をファインチューニングする
<a name="nova-fine-tune-2"></a>

## 前提条件
<a name="nova-model-training-jobs-prerequisites2"></a>

トレーニングジョブを始める前に、以下の要件を確認してください。
+ トレーニングジョブの入力データと出力を格納する Amazon S3 バケット。両方に 1 つのバケットを使用することも、データタイプごとに個別のバケットを使用することもできます。トレーニング用の他のすべてのリソースを作成する AWS リージョンと同じ場所にバケットがあることを確認します。詳細については、「[汎用バケットの作成](https://docs.aws.amazon.com//AmazonS3/latest/userguide/create-bucket-overview.html)」を参照してください。
+ トレーニングジョブを実行するアクセス許可がある IAM ロール。必ず IAM ポリシーを `AmazonSageMakerFullAccess` にアタッチしてください。詳細については、「[SageMaker AI 実行ロールの使用方法](https://docs.aws.amazon.com//sagemaker/latest/dg/sagemaker-roles.html)」を参照してください。
+ Amazon Nova の基本レシピについては、「[Amazon Nova レシピの取得](nova-model-recipes.md#nova-model-get-recipes)」を参照してください。

## SFT とは?
<a name="nova-2-what-is-sft"></a>

教師ありファインチューニング (SFT) は、ラベル付き入出力ペアを使用して言語モデルをトレーニングします。このモデルは、プロンプトとレスポンスで構成されるデモンストレーションの例から学習し、特定のタスク、指示、または望ましい動作に合わせて機能を改善します。

## データ準備
<a name="nova-2-data-preparation"></a>

### 概要
<a name="nova-2-data-overview"></a>

Nova 2.0 SFT データは、Nova 1.0 と同じ Converse API 形式を使用し、オプションの推論コンテンツフィールドが追加されています。完全な形式の仕様については、以下を参照してください。
+ 推論コンテンツ: [ReasoningContentBlock](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ReasoningContentBlock.html)
+ Converse API スキーマ: [Converse API](https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference-call.html)
+ データセット制約: [データセット制約](https://docs.aws.amazon.com/nova/latest/userguide/fine-tune-prepare-data-understanding.html)

### サポートされている機能
<a name="nova-2-supported-features"></a>
+ **入力タイプ** – ユーザーコンテンツブロック内のテキスト、画像、または動画
+ **アシスタントコンテンツ** – テキストのみのレスポンスと推論コンテンツ
+ **データセット構成** – 同種である必要があります。次のいずれかを選択します。
  + テキストのみのターン
  + テキストと画像のターン
  + テキストと動画のターン (ドキュメントの理解をサポート)

**重要**  
同じデータセット内または異なるターン間で画像と動画を混在させることはできません。

### 現在の制限事項
<a name="nova-2-current-limitations"></a>
+ **マルチモーダル推論コンテンツ** – Converse 形式は画像ベースの推論コンテンツをサポートしていますが、Nova 2.0 SFT は reasoningText フィールドのテキストベースの推論コンテンツのみをサポートしています。
+ **検証セット** – Nova 2.0 で SFT の検証データセットを指定することはできません。検証データセットを指定すると、トレーニング中は無視されます。この制限は、UI ベースのジョブ送信とプログラムによるジョブ送信の両方に適用されます。

### サポートされているメディア形式
<a name="nova-2-supported-media"></a>
+ **画像** – PNG、JPEG、GIF
+ **動画** – MOV、MKV、MP4

### データ形式の例
<a name="nova-2-data-examples"></a>

------
#### [ Text-only (Nova 1.0 compatible) ]

```
{  
  "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 (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."  
        }  
      ]  
    }  
  ]  
}
```

------
#### [ Image \$1 text input ]

```
{  
  "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 \$1 text input ]

```
{  
  "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-tool-calling"></a>

Nova 2.0 SFT は、ツール呼び出しパターンに関するモデルのトレーニングをサポートしているため、モデルは外部ツールまたは関数を呼び出すタイミングと方法を学習できます。

### ツール呼び出しのデータ形式
<a name="nova-2-tool-calling-format"></a>

ツール呼び出しのトレーニングデータには、使用可能なツールを定義する `toolConfig` セクションと、ツールの使用パターンを示す会話ターンが含まれます。

**入力例**

```
{  
  "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?"  
        }  
      ]  
    }  
  ]  
}
```

### ツール呼び出しの要件
<a name="nova-2-tool-calling-requirements"></a>

ツール呼び出しのトレーニングデータを作成するときは、次の要件に従ってください。


| 要件 | 説明 | 
| --- | --- | 
| ToolUse 配置 | ToolUse はアシスタントターンにのみ表示する必要があります | 
| ToolResult の配置 | ToolResult はユーザーターンにのみ表示する必要があります | 
| ToolResult 形式 | ToolResult はテキストまたは JSON のみである必要があります。Nova モデルでは他のモダリティはサポートされていません | 
| inputSchema 形式 | toolSpec 内の inputSchema は有効な JSON Schema オブジェクトである必要があります | 
| toolUseId マッチング | 各 ToolResult は、前述のアシスタント ToolUse の有効な toolUseId を参照し、各 toolUseId は会話ごとに 1 回だけ使用する必要があります | 

### 重要な注意事項
<a name="nova-2-tool-calling-notes"></a>
+ ツール定義がすべてのトレーニングサンプルで一貫しているようにしてください
+ このモデルは、提供するデモンストレーションからツール呼び出しパターンを学習します
+ 各ツールを使用するタイミングと使用しないタイミングのさまざまな例を含めます

## ドキュメント理解
<a name="nova-2-document-understanding"></a>

Nova 2.0 SFT はドキュメントベースのタスクのトレーニングをサポートしているため、モデルは PDF ドキュメントに関する質問を分析して回答する方法を学習できます。

### ドキュメントを理解するためのデータ形式
<a name="nova-2-document-format"></a>

ドキュメント理解のトレーニングデータには、ユーザーコンテンツブロック内のドキュメント参照が含まれ、モデルがドキュメントコンテンツを抽出して内容について推論することを学習するためのものです。

**入力例**

```
{  
{  
  "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": [  
        {
          "reasoningContent": {  
            "reasoningText": {  
              "text": "I need to find the relevant section in the document to answer the question."  
            }  
          }
        },
        {  
          "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?"  
        }   
      ]
    }  
  ]  
}
}
```

### ドキュメント理解の制限事項
<a name="nova-2-document-limitations"></a>


| 制限 | 詳細 | 
| --- | --- | 
| サポートされる形式 | PDF ファイルのみ | 
| 最大ドキュメントサイズ | 10 MB | 
| モダリティミキシング | サンプルにはドキュメントとテキストを含めることができますが、ドキュメントを他のモダリティ (画像、動画) と混ぜ合わせることはできません | 

### ドキュメント理解のためのベストプラクティス
<a name="nova-2-document-best-practices"></a>
+ ドキュメントが明確にフォーマットされ、テキストが抽出可能であることを確認します
+ さまざまなドキュメントタイプと質問形式をカバーするさまざまな例を提供します
+ モデルがドキュメント分析パターンを学習するのに役立つ推論コンテンツを含めます

## 動画理解
<a name="nova-2-video-understanding"></a>

Nova 2.0 SFT は動画ベースのタスクのトレーニングをサポートし、モデルが動画コンテンツに関する質問を分析して応答する方法を学習できるようにします。

### 動画を理解するためのデータ形式
<a name="nova-2-video-format"></a>

動画理解のトレーニングデータには、ユーザーコンテンツブロック内の動画参照が含まれ、モデルが動画コンテンツから情報を抽出して内容について推論することを学習するためのものです。

**入力例**

```
  
{  
  "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": [  
        {
          "reasoningContent": {  
            "reasoningText": {  
              "text": "I need to find the relevant section in the video to answer the question."  
            }  
          }
        },
        {  
          "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?"  
        }   
      ]  
    }  
  ]  
}
```

### 動画理解の制限事項
<a name="nova-2-video-limitations"></a>


| 制限 | 詳細 | 
| --- | --- | 
| 動画の最大サイズ | 50 MB | 
| 最大動画再生時間 | 15 分 | 
| サンプルあたりの動画数 | サンプルごとに許可される動画は 1 つだけです。同じサンプル内で複数の動画はサポートされていません | 
| モダリティミキシング | サンプルには動画とテキストを含めることができますが、動画を他のモダリティ (画像、ドキュメント) と組み合わせることはできません | 

### サポートされている動画形式
<a name="nova-2-video-formats"></a>
+ MOV
+ MKV
+ MP4

### 動画理解のベストプラクティス
<a name="nova-2-video-best-practices"></a>
+ 動画を簡潔に保ち、タスクに関連するコンテンツに集中させる
+ モデルが意味のある情報を抽出するのに動画の品質が十分であることを確認します
+ 動画コンテンツの特定の側面を参照する明確な質問を提供します
+ さまざまな動画タイプと質問形式をカバーするさまざまな例を含めます

## 推論モードと非推論モード
<a name="nova-2-reasoning-modes"></a>

### 推論コンテンツについて
<a name="nova-2-understanding-reasoning"></a>

推論コンテンツ (思考の連鎖とも呼ばれます) は、最終的な回答を生成する前に、モデルの中間思考ステップをキャプチャします。`assistant` ターンでは、`reasoningContent` フィールドを使用して推論トレースを含めます。

**損失の計算方法**
+ **推論コンテンツあり** – トレーニング損失には、推論トークンと最終出力トークンの両方が含まれます
+ **推論コンテンツなし** – トレーニング損失は最終的な出力トークンでのみ計算されます

マルチターン会話では、複数のアシスタントターンにまたがって `reasoningContent` を含めることができます。

**形式ガイドライン**
+ 推論コンテンツにプレーンテキストを使用します
+ タスクで特に必要な場合を除いて、`<thinking>` や `</thinking>` などのマークアップタグは避けてください
+ 推論の内容が明確で、問題解決プロセスに関連していることを確認します

### 推論モードを有効にする場合
<a name="nova-2-when-enable-reasoning"></a>

次の場合にトレーニング設定で `reasoning_enabled: true` を設定します。
+ トレーニングデータに推論トークンがある場合
+ 最終的な出力を生成する前に、モデルで思考トークンを生成したい場合
+ 複雑な推論タスクのパフォーマンスを向上させる必要がある場合

`reasoning_enabled = true` を使用して推論なしのデータセットで Nova をトレーニングすることは許可されています。ただし、Nova は主に推論を適用せずにデータに表示されるレスポンスを生成することを学習するため、モデルが推論機能を失う可能性があります。非推論データセットで Nova をトレーニングしたいが、推論時にも推論機能を使用したい場合は、トレーニング中は推論を無効にし (`reasoning_enabled = false`)、推論時には有効にすることができます。このアプローチでは推論時に推論機能を使用できますが、推論なしの推論と比較してパフォーマンスが向上することは保証されません。一般的に、推論データセットを使用する場合はトレーニングと推論の両方で推論を有効にし、非推論データセットを使用する場合は両方で推論を無効にします。

次の場合に `reasoning_enabled: false` を設定します。
+ トレーニングデータに推論トークンがない場合
+ 明示的な推論ステップの恩恵を受けない単純なタスクをトレーニングしている場合
+ 速度を最適化し、トークン使用量を削減したい場合

### 推論データの生成
<a name="nova-2-generating-reasoning"></a>

データセットに推論トレースがない場合は、Nova Premier のような推論可能なモデルを使用して作成できます。入力と出力のペアをモデルに提供し、推論プロセスを取得して推論拡張データセットを構築します。

### トレーニングに推論トークンを使用する
<a name="nova-2-using-reasoning-training"></a>

推論モードを有効にしてトレーニングすると、モデルは内部推論を最終回答から分離することを学習します。トレーニングプロセス:
+ データを入力、推論、回答のセットで整理します
+ 推論トークンと回答トークンの両方からの標準 next-token 予測損失を使用して最適化します
+ レスポンスを生成する前に、モデルに内部的に推論するよう促します

### 効果的な推論コンテンツ
<a name="nova-2-effective-reasoning"></a>

高品質の推論コンテンツには、以下を含める必要があります。
+ 中間的な思考と分析
+ 論理的な演繹と推論ステップ
+ 段階的な問題解決アプローチ
+ ステップと結論の明示的な関係

これは、モデルが「回答する前に考える」能力を開発するのに役立ちます。

## データセット準備ガイドライン
<a name="nova-2-dataset-preparation"></a>

### サイズと品質
<a name="nova-2-size-quality"></a>
+ **推奨サイズ** – 2,000～10,000 サンプル
+ **最小サンプル** – 200
+ **優先** – 数量よりも品質。例が正確で適切に注釈が付けられているようにします
+ **アプリケーションの連携** – データセットは本番環境のユースケースを厳密に反映する必要があります

### 多様性
<a name="nova-2-diversity"></a>

次のようなさまざまな例を含めます。
+ 予想される入力の全範囲をカバーする
+ さまざまな難易度を表す
+ エッジケースとバリエーションを含む
+ 狭いパターンへのオーバーフィットを防止する

### 出力フォーマット
<a name="nova-2-output-formatting"></a>

アシスタントレスポンスで目的の出力形式を明確に指定します。
+ JSON の構造
+ テーブル
+ CSV 形式
+ アプリケーションに固有のカスタム形式

### マルチターンの会話
<a name="nova-2-multi-turn"></a>

マルチターンデータセットの場合、次の点に注意してください。
+ 損失は、ユーザーのターンではなく、アシスタントのターンでのみ計算されます
+ 各アシスタントレスポンスは適切にフォーマットする必要があります
+ 会話のターン全体で一貫性を維持します

### 品質チェックリスト
<a name="nova-2-quality-checklist"></a>
+ 十分なデータセットサイズ (2K～10K サンプル)
+ すべてのユースケースをカバーするさまざまな例
+ 明確で一貫した出力フォーマット
+ 正確なラベルと注釈
+ 本番シナリオを代表する内容であること
+ 矛盾やあいまいさがない

### データのアップロード
<a name="nova-2-uploading-data"></a>

データセットは、SageMaker トレーニングジョブがアクセスできるバケットにアップロードする必要があります。必要な許可の設定の詳細については、「[前提条件](https://docs.aws.amazon.com/sagemaker/latest/dg/nova-model-general-prerequisites.html)」を参照してください。

## トレーニングジョブを開始する
<a name="nova-2-starting-training"></a>

### ハイパーパラメータの選択とレシピの更新
<a name="nova-2-selecting-hyperparameters"></a>

Nova 2.0 のセットアップは、Nova 1.0 のセットアップとほぼ同じです。入力データが S3 にアップロードされたら、ファインチューニングフォルダの [SageMaker HyperPod レシピ](https://github.com/aws/sagemaker-hyperpod-recipes/tree/main/recipes_collection/recipes/fine-tuning/nova)のレシピを使用します。Nova 2.0 では、ユースケースに基づいて更新できる主要なハイパーパラメータの一部を以下に示します。以下は、Nova 2.0 SFT PEFT レシピの例です。コンテナ画像 URI の場合、`708977205387.dkr.ecr.us-east-1.amazonaws.com/nova-fine-tune-repo:SM-TJ-SFT-V2-latest` を使用して SFT ファインチューニングジョブを実行します。

Nova トレーニングとの厳密な互換性のために、SageMaker AI PySDK の v2.254.1 を使用してください。SDK を v3.0 バージョンにアップグレードすると、重大な変更が発生します。SageMaker AI PySDK の v3 のサポートが間もなく開始されます。

**入力例**

```
!pip install sagemaker==2.254.1
```

```
run:  
  name: {peft_recipe_job_name}  
  model_type: amazon.nova-2-lite-v1:0:256k  
  model_name_or_path: {peft_model_name_or_path}  
  data_s3_path: {train_dataset_s3_path} # SageMaker HyperPod (SMHP) only and not compatible with SageMaker Training jobs. Note replace my-bucket-name with your real bucket name for SMHP job  
  replicas: 4                      # Number of compute instances for training, allowed values are 4, 8, 16, 32  
  output_s3_path: ""               # Output artifact path (Hyperpod job-specific; not compatible with standard SageMaker Training jobs). Note replace my-bucket-name with your real bucket name for SMHP job  
  
training_config:  
  max_steps: 10                   # Maximum training steps. Minimal is 4.  
  save_steps: 10                      # How many training steps the checkpoint will be saved. Should be less than or equal to max_steps  
  save_top_k: 1                    # Keep top K best checkpoints. Note supported only for SageMaker HyperPod jobs. Minimal is 1.  
  max_length: 32768                # Sequence length (options: 8192, 16384, 32768 [default], 65536)  
  global_batch_size: 32            # Global batch size (options: 32, 64, 128)  
  reasoning_enabled: true          # If data has reasoningContent, set to true; otherwise False  
  
  lr_scheduler:  
    warmup_steps: 15               # Learning rate warmup steps. Recommend 15% of max_steps  
    min_lr: 1e-6                   # Minimum learning rate, must be between 0.0 and 1.0  
  
  optim_config:                    # Optimizer settings  
    lr: 1e-5                       # Learning rate, must be between 0.0 and 1.0  
    weight_decay: 0.0              # L2 regularization strength, must be between 0.0 and 1.0  
    adam_beta1: 0.9                # Exponential decay rate for first-moment estimates, must be between 0.0 and 1.0  
    adam_beta2: 0.95               # Exponential decay rate for second-moment estimates, must be between 0.0 and 1.0  
  
  peft:                            # Parameter-efficient fine-tuning (LoRA)  
    peft_scheme: "lora"            # Enable LoRA for PEFT  
    lora_tuning:  
      alpha: 64                    # Scaling factor for LoRA weights ( options: 32, 64, 96, 128, 160, 192),  
      lora_plus_lr_ratio: 64.0
```

レシピには、Nova 1.0 とほぼ同じハイパーパラメータも含まれています。注目すべきハイパーパラメータは次のとおりです。
+ `max_steps` – ジョブを実行するステップの数。通常、1 つのエポック (データセット全体で 1 回実行) の場合、ステップ数 = データサンプル数/グローバルバッチサイズ。ステップ数が多く、グローバルバッチサイズが小さいほど、ジョブの実行に時間がかかります。
+ `reasoning_enabled` – データセットの推論モードを制御します。オプション:
  + `true`: 推論モードを有効にします (高推論に相当)
  + `false`: 推論モードを無効にします

  注: SFT の場合、推論の労力レベルをきめ細かく制御することはできません。`reasoning_enabled: true` を設定すると、完全な推論機能が有効になります。
+ `peft.peft_scheme` – これを「lora」に設定すると、PEFT ベースのファインチューニングが有効になります。null (引用符なし) に設定すると、フルランクのファインチューニングが有効になります。

### トレーニングジョブの開始
<a name="nova-2-start-job"></a>

```
from sagemaker.pytorch import PyTorch  
  
# define OutputDataConfig path  
if default_prefix:  
    output_path = f"s3://{bucket_name}/{default_prefix}/{sm_training_job_name}"  
else:  
    output_path = f"s3://{bucket_name}/{sm_training_job_name}"  

output_kms_key = "<KMS key arn to encrypt trained model in Amazon-owned S3 bucket>" # optional, leave blank for Amazon managed encryption
  
recipe_overrides = {  
    "run": {  
        "replicas": instance_count,  # Required  
        "output_s3_path": output_path  
    },  
}  
  
estimator = PyTorch(  
    output_path=output_path,  
    base_job_name=sm_training_job_name,  
    role=role,  
    disable_profiler=True,  
    debugger_hook_config=False,  
    instance_count=instance_count,  
    instance_type=instance_type,  
    training_recipe=training_recipe,  
    recipe_overrides=recipe_overrides,  
    max_run=432000,  
    sagemaker_session=sagemaker_session,  
    image_uri=image_uri,
    output_kms_key=output_kms_key,
    tags=[  
        {'Key': 'model_name_or_path', 'Value': model_name_or_path},  
    ]  
)  
  
print(f"\nsm_training_job_name:\n{sm_training_job_name}\n")  
print(f"output_path:\n{output_path}")
```

```
from sagemaker.inputs import TrainingInput  
  
train_input = TrainingInput(  
    s3_data=train_dataset_s3_path,  
    distribution="FullyReplicated",  
    s3_data_type="Converse",  
)  
  
estimator.fit(inputs={"validation": val_input}, wait=False)
```

**注記**  
検証データセットの受け渡しは、Nova 2.0 の教師ありファインチューニングではサポートされていません。

ジョブを開始するには:
+ データセットパスとハイパーパラメータを使用してレシピを更新します
+ ノートブックで指定されたセルを実行してトレーニングジョブを送信します

ノートブックがジョブの送信を処理し、ステータスの追跡を行います。