SageMaker HyperPod での Nova 2.0 の強化ファインチューニング (RFT)
このセクションでは、SageMaker HyperPod での Nova 2.0 Lite の RFT に関するサンプルレシピ、ファインチューニングジョブの開始、ハイパーパラメータガイダンス、トレーニングモニタリングについて説明します。RFT トレーニングデータを準備するためのデータ形式、サポートされている機能、制約、およびベストプラクティスについては、Amazon Nova 2 での RFT のデータの準備 を参照してください。
RFT がユースケースに適しているかどうかを判断するには、 強化ファインチューニング (RFT) を参照してください。
# Note: # This recipe can run on p5.48xlarge, p5e.48xlarge, and p5en.48xlarge instance types. run: name: "my-rft-run" # Unique run name (appears in logs and artifacts). model_type: amazon.nova-2-lite-v1:0:256k model_name_or_path: nova-lite-2/prod data_s3_path: s3://<bucket>/<data-file> # Training dataset in JSONL format. replicas: 4 # Number of total training instances. generation_replicas: 2 # Number of total instances dedicated to response generation. reward_lambda_arn: arn:aws:lambda:<region>:<account-id>:function:<function-name> ## MLFlow configs mlflow_tracking_uri: "" # Required for MLFlow mlflow_experiment_name: "my-rft-experiment" # Optional for MLFlow. Note: leave this field non-empty mlflow_run_name: "my-rft-run" # Optional for MLFlow. Note: leave this field non-empty ## SMHP RFT training configs training_config: max_length: 8192 # Context window (tokens) for inputs and prompt. global_batch_size: 32 # Total samples per optimizer step across all replicas (16/32/64/128/256). reasoning_effort: high # Reasoning mode: high, low, or null for non-reasoning. data: shuffle: true # Shuffle training data each epoch. rollout: # Controls how responses are generated for advantage calculation. rollout_strategy: type: off_policy_async # Asynchronous rollout for higher throughput. age_tolerance: 2 # Maximum policy age before regeneration. advantage_strategy: number_generation: 4 # Samples per prompt to estimate advantages (higher = lower variance but higher cost). generator: max_new_tokens: 6000 # Cap on tokens generated per sample. set_random_seed: true # Seed generation for reproducibility across runs. temperature: 1 # Softmax temperature for sampling. top_k: 1 # Sample only from top-K logits. rewards: preset_reward_function: null # Preset reward functions: exact_match or null for custom. api_endpoint: lambda_arn: arn:aws:lambda:<region>:<account-id>:function:<function-name> lambda_concurrency_limit: 12 # Max concurrent Lambda invocations (throughput vs. throttling). lambda_batch_size: 128 # Number of samples per Lambda invocation. trainer: max_steps: 2 # Steps to train for. One step = global_batch_size samples. save_steps: 5 # Save a checkpoint every N steps. test_steps: 1 # Run validation every N reference model updates. refit_freq: 4 # Frequency of reference model updates. clip_ratio_high: 0.2 # PPO clip ratio for policy updates. loss_scale: 1.0 # Scaling factor for the policy loss. # RL parameters ent_coeff: 0.0 # Entropy bonus added to the policy loss (higher = more exploration). kl_loss_coef: 0.0 # Weight on the KL penalty between the current and reference policy. optim_config: # Optimizer settings. lr: 1e-6 # Learning rate. weight_decay: 0.0 # L2 regularization strength (0.0 to 1.0). adam_beta1: 0.9 adam_beta2: 0.95 peft: # Parameter-efficient fine-tuning (LoRA). peft_scheme: "lora" # Enable LoRA for PEFT. lora_tuning: alpha: 64 # LoRA scaling factor. lora_plus_lr_ratio: 64.0 # LoRA+ learning rate scaling factor (0.0 to 100.0).
SageMaker HyperPod でファインチューニングジョブを開始する
データの準備
RFT トレーニングデータを準備するためのデータ形式、サポートされている機能、制約、およびベストプラクティスについては、Amazon Nova 2 での RFT のデータの準備 を参照してください。
データのアップロード
トレーニングデータセットを S3 バケットにアップロードします。レシピの run ブロックでその場所を指定します。
## Run config run: ... data_s3_path: "s3://<bucket-name>/<training-directory>/<training-file>.jsonl"
注記
<bucket-name>、<training-directory>、<training-file> を実際の S3 パスに置き換えます。
設定の定義
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-7
-
世代数: 8
-
新しいトークンの最大数: 8192
-
バッチサイズ: 256
LoRA (低ランク適応):
-
LoRA ランク: 32
注記
データセットのサイズと検証パフォーマンスに基づいてこれらの値を調整します。トレーニングメトリクスをモニタリングして、オーバーフィットを防止します。