AIニュース最前線
最新ニュースAI日報Hacker日報週報動画AIツールトレンド企業

AIニュース最前線

世界中のAI最新情報を日本語で毎時更新

最新ニュース日報トレンド企業プレミアムRSS
© 2026 ainew.jp特定商取引法に基づく表記
ニュース一覧元記事を開く
AWS Machine Learning Blog·2026年4月18日 02:27·約11分で読める

Nova Forge SDKシリーズ第2部:データ混合機能を使用したNovaモデルのファインチューニング実践ガイド

#ファインチューニング#データ混合#LLMカスタマイズ#Amazon Nova#SageMaker#エンタープライズAI
TL;DR

AWSの機械学習ブログは、Amazon NovaモデルをNova Forge SDKでデータ混合技術を用いてファインチューニングする実践的な手順を、環境構築から評価までの5段階で詳細に解説している。

AI深層分析2026年4月18日 03:41
4
重要/ 5段階
深度40%
5
関連度30%
5
実用性20%
5
革新性10%
3

キーポイント

1

データ混合による汎用性維持

ドメイン固有データでファインチューニングする際に、モデルの一般的な能力を維持するためのデータ混合技術を紹介している。

2

5段階の実践的ワークフロー

環境設定、データ準備、トレーニング設定、モデルトレーニング、モデル評価という具体的な手順を提供している。

3

実証済みの効果

顧客データとAmazon管理データセットを混合することで、MMLUスコアを維持しながら特定タスクで12ポイントのF1改善を実現した事例を示している。

4

オープンソースモデルとの比較優位性

顧客データのみでファインチューニングしたオープンソースモデルは一般的な能力をほぼ完全に失うのに対し、Novaモデルはデータ混合によりこれを回避できると主張している。

5

Nova Forge SDKのインストールと環境設定

Nova Forge SDKをインストールし、Jupyter notebook環境で使用するための仮想環境カーネルを設定する手順が説明されている。

6

AWSリソースの設定

トレーニングデータとモデル出力用のS3バケットを作成し、HyperPod実行ロールにアクセス権限を付与する方法が示されている。

7

データセットの準備とサニタイズ

Nova Forge SDKはJSONL、JSON、CSV形式をサポートし、MedReasonデータセットのような公開データセットを使用できる。データサニタイズでは、モデルのチャットテンプレートと競合する特殊トークン(System:、Assistant:、[EOS]など)を検出・修正する必要がある。

影響分析・編集コメントを表示

影響分析

この記事は、企業が独自データでLLMをカスタマイズする際の最大の課題である「汎用性の喪失」に対する実用的な解決策を提供している。AWSのNovaモデルとForge SDKの組み合わせが、オープンソースモデルに対する競争優位性を明確に示しており、企業AI導入の実用段階を後押しする可能性がある。

編集コメント

技術的な深さと実用性のバランスが良く、企業のAI導入担当者にとって即戦力となる内容。ただし、AWS製品のプロモーション色が強いため、客観的な技術比較の視点がやや弱い印象。

この実践的なガイドでは、Amazon Nova Forge SDKを使用してAmazon Novaモデルをファインチューニングする全手順を、データ準備からデータミキシング(data mixing)を用いたトレーニング、評価に至るまで詳しく解説します。これにより、独自のユースケースに適用可能な反復可能なプレイブックが提供されます。本稿はNova Forge SDKシリーズの第2部であり、SDK紹介および第1部で取り上げたカスタマイズ実験の開始を基盤としています。

本稿の焦点はデータミキシング(data mixing)です。これは、モデルの汎用能力を犠牲にすることなく、ドメイン固有のデータでファインチューニングできる技術です。前回の投稿では、その重要性について説明しました。顧客データをAmazonが厳選したデータセットと組み合わせることで、大規模マルチタスク言語理解(Massive Multitask Language Understanding, MMLU)スコアをベースラインに近い水準で維持しつつ、1,420のリーフカテゴリにわたる顧客の声(Voice of Customer)分類タスクにおいてF1スコア(F1 score)を12ポイント向上させることに成功しました。一方、オープンソースモデルを顧客データのみでファインチューニングすると、汎用能力がほぼ完全に失われるという結果になりました。ここでは、実際にそれを行う方法を解説します。

解決策の概要

ワークフローは以下の5つのステージで構成されます:

  • 環境設定 – Nova Forge SDKのインストールとAWSリソースの設定
  • データ準備 – トレーニングデータの読み込み、クリーニング、変換、検証、分割
  • トレーニング設定 – Amazon SageMaker HyperPodランタイム、MLflow追跡、データミキシング(data mixing)比率の設定
  • モデルトレーニング – 低ランク適応(Low-Rank Adaptation, LoRA)を用いた教師ありファインチューニング(supervised fine-tuning)ジョブの起動と監視
  • モデル評価 – ファインチューニング済みチェックポイント(checkpoint)に対する公開ベンチマークおよびドメイン固有の評価の実行

前提条件

開始する前に、以下の準備が整っていることを確認してください:

S3バケットの作成

if REGION == "us-east-1":

s3.create_bucket(Bucket=S3_BUCKET)

else:

s3.create_bucket(

Bucket=S3_BUCKET,

CreateBucketConfiguration={"LocationConstraint": REGION}

)

HyperPod実行ロールへのアクセス権限付与

HYPERPOD_ROLE_ARN = f"arn:aws:iam::{ACCOUNT_ID}:role/

"bucket_policy = {

"Version": "2012-10-17",

"Statement": [{

"Sid": "AllowHyperPodAccess",

"Effect": "Allow",

"Principal": {"AWS": HYPERPOD_ROLE_ARN},

"Action": ["s3:GetObject", "s3:PutObject", "s3:DeleteObject", "s3:ListBucket"],

"Resource": [

f"arn:aws:s3:::{S3_BUCKET}",

f"arn:aws:s3:::{S3_BUCKET}/*"

]

}]

}

s3.put_bucket_policy(Bucket=S3_BUCKET, Policy=json.dumps(bucket_policy))

ステップ3:トレーニングデータセットの準備

Nova Forge SDKはJSONL、JSON、CSVの入力形式に対応しています。このチュートリアルでは、Hugging Faceから公開されているMedReasonデータセットを使用します。このデータセットには約3万2,700件の質問と回答のペアが含まれる医療推論データが含まれており、ドメイン固有の使用ケースに対するファインチューニングのデモンストレーションに使用されます。

データのダウンロードとサニタイズ

Nova Forge SDKはトレーニングデータに対してトークンレベルの検証(token-level validation)を適用します。特定のトークンはモデル内部のチャットテンプレート(chat template)と競合し、特にトレーニング中にシステム、ユーザー、アシスタントのターンを区別するためにNovaが使用する特殊なデリミタ(delimiters)と衝突します。データにSystem:やAssistant:のようなリテラル文字列が含まれている場合、モデルはそれらをターンの境界(turn boundaries)として誤解釈し、トレーニング信号(training signal)を破損させる可能性があります。以下のサニタイズ処理では、可読性を保ちつつパターンマッチを無効化するためにコロンの前にスペースを挿入し(例:System: → System :))、モデルの語彙で予約された意味を持つ[EOS]や*のような特殊トークンを削除します。

from huggingface_hub import hf_hub_download** import pandas as pd

import json

import re

データセットのダウンロード

jsonl_path = hf_hub_download(

repo_id=”UCSC-VLAA/MedReason”,

filename=”ours_quality_33000.jsonl”,

repo_type=”dataset”,

local_dir=”.”

)

df = pd.read_json(jsonl_path, lines=True)

モデルのチャットテンプレートと競合するトークン

INVALID_TOKENS = [

“System:”, “SYSTEM:”, “User:”, “USER:”, “Bot:”, “BOT:”,

“Assistant:”, “ASSISTANT:”, “Thought:”, “[EOS]”,

“”, “”, “”,

]

def sanitize_text(text):

for token in INVALID_TOKENS:

if “:” in token:

word = token[:-1]

text = re.sub(rf’{word}:’, f'{word} :’, text, flags=re.IGNORECASE)

else:

text = text.replace(token, “”)

return text.strip()

サニタイズ済みJSONLの出力

with open(“training_data.jsonl”, “w”) as f:

for _, row in df.iterrows():

f.write(json.dumps({

“question”: sanitize_text(row[“question”]),

“answer”: sanitize_text(row[“answer”]),

}) + “

”)

print(f”データセット保存完了: training_data.jsonl ({len(df)}件)")

予約済みキーワードがデータに含まれていないか検証するには、以下のスクリプトを実行してください。

SDKを使用したデータ読み込み、変換、および検証

SDKにはJSONLDatasetLoaderが用意されており、生データの形式をNovaモデルが期待する構造に変換します。transform()メソッドを呼び出すと、SDKは各質問応答ペアをNovaチャットテンプレート形式(Nova chat template format)にラップします。これは、トレーニング中にNovaモデルが期待する構造化されたターンベースの形式です。生データは単純なQ&Aペアから、適切なロールタグ(role tags)と区切り文字を備えた完全なマルチターン会話形式へと変換されます。

変換前(生JSONL):

{

"question": "What are the causes of chest pain in a 45-year-old patient?",

"answer": "Chest pain in a 45-year-old can result from cardiac causes such as..."

}

変換後(Novaチャットテンプレート形式):

{

"messages": [

{"role": "user", "content": "What are the causes of chest pain in a 45-year-old patient?"},

{"role": "assistant", "content": "Chest pain in a 45-year-old can result from cardiac causes such as..."}

]

}

The validate()メソッドはその後、変換済みデータに問題がないか検証します。チャットテンプレート構造が正しいこと、無効なトークンが残っていないこと、そしてデータが選択したモデルとトレーニング手法の要件に準拠していることを確認します。

ローダーの初期化とカラム名のマッピング

loader = JSONLDatasetLoader(

question="question",

answer="answer",

)

loader.load("training_data.jsonl")

生データのプレビュー

loader.show(n=3)

Novaが期待するチャットテンプレート形式への変換

loader.transform(method=TrainingMethod.SFT_LORA, model=Model.NOVA_LITE_2)

構造を確認するための変換済みデータのプレビュー

loader.show(n=3)

検証 — 成功時は「Validation completed」を出力

loader.validate(method=TrainingMethod.SFT_LORA, model=Model.NOVA_LITE_2)

train_path = loader.save(f"{S3_DATA_PATH}/train.jsonl")

print(f"Training data: {train_path}")

ステップ4:データミキシングを有効にしてトレーニングの設定と開始

data mixing(データミキシング)を有効にすると、Nova Forgeはファインチューニング中にドメイン固有のトレーニングデータをAmazonが厳選したデータセットと自動的に混合します。これにより、モデルは専門領域を学習しながらも、一般的な能力を忘れることを防ぎます。

トレーニング手法に関する注記:LoRAとフルランクSFTの比較

Nova Forgeは複数のファインチューニング手法をサポートしています。本チュートリアルでは、Low-Rank Adaptation(LoRA)を併用した教師ありファインチューニング(SFT)(TrainingMethod.SFT_LORA)を使用します。これはパラメータ効率的な手法であり、すべてのモデルパラメータを更新するのではなく、低ランクアダプター重み(low-rank adapter weights)の小さなセットのみを更新します。LoRAはトレーニングが高速で計算コストが低く、ほとんどのユースケースにおける推奨される開始点です。

Nova ForgeはフルランクSFT(Full-rank SFT)にも対応しており、すべてのモデルパラメータを更新してより多くのドメイン知識を組み込むことができます。ただし、計算リソースをより多く必要とし、カタストロフィックフォアゲティング(Catastrophic Forgetting)のリスクが高まるため、データミキシングの重要性がさらに高まります。本シリーズの前回の投稿では、フルランクSFTを使用した結果を紹介しています。LoRAで十分なドメインパフォーマンスが得られない場合や、より深いモデル適応が必要な場合にフルランクを選択してください。

ランタイムとMLflowの設定

from amzn_nova_customization_sdk.model.model_enums import Platform

class_name = "nova-forge-hyperpod"

instance_type = "ml.p5.48xlarge"

instance_count = 4

namespace = "kubeflow"

runtime = SMHPRuntimeManager(

instance_type=instance_type,

instance_count=instance_count,

cluster_name=cluster_name,

namespace=namespace,

)

MLFLOW_APP_ID = "" # e.g., "app-XXXXXXXXXXXX"

mlflow_app_arn = f"arn:aws:sagemaker:{REGION}:{ACCOUNT_ID}:mlflow-app/{MLFLOW_APP_ID}"

mlflow_monitor = MLflowMonitor(

tracking_uri=mlflow_app_arn,

experiment_name="nova-sft-datamix",

)

データミキシングを有効化したカスタマイザーの作成

NovaModelCustomizerを構築する際に、data_mixing_enabled=Trueを渡します:

customizer = NovaModelCustomizer(

model=Model.NOVA_LITE_2,

method=TrainingMethod.SFT_LORA,

infra=runtime,

data_s3_path=f"{S3_DATA_PATH}/train.jsonl",

output_s3_path=f"{S3_OUTPUT_PATH}/",

mlflow_monitor=mlflow_monitor,

data_mixing_enabled=True,

)

データミキシング設定の理解と調整

データミキシングは、トレーニングバッチがどのように構成されるかを制御します。customer_data_percentパラメータは、各バッチのうちドメインデータから取得される割合を決定します。残りの割合はNovaが選別したデータセットで埋められ、各nova_*_percentパラメータはNova部分内におけるその機能カテゴリの相対的な重みを制御します*。

For example, with the configuration below:

  • 50% of each training batch consists of your domain data
  • 50% consists of Nova-curated data, distributed across capability categories according to their relative weights

The Nova-side percentages must sum to 100. Each value represents that category’s share of the Nova-curated portion of the batch.

View the default mixing ratios

customizer.get_data_mixing_config()

You can override these ratios based on your priorities:

customizer.set_data_mixing_config({

"customer_data_percent": 50,

"nova_agents_percent": 1,

"nova_baseline_percent": 10,

"nova_chat_percent": 0.5,

"nova_factuality_percent": 0.1,

"nova_identity_percent": 1,

"nova_long-context_percent": 1,

"nova_math_percent": 2,

"nova_rai_percent": 1,

"nova_instruction-following_percent": 13,

"nova_stem_percent": 10.5,

"nova_planning_percent": 10,

"nova_reasoning-chat_percent": 0.5,

"nova_reasoning-code_percent": 0.5,

"nova_reasoning-factuality_percent": 0.5,

"nova_reasoning-instruction-following_percent": 45,

"nova_reasoning-math_percent": 0.5,

"nova_reasoning-planning_percent": 0.5,

"nova_reasoning-rag_percent": 0.4,

"nova_reasoning-rai_percent": 0.5,

"nova_reasoning-stem_percent": 0.4,

"nova_rag_percent": 1,

"nova_translation_percent": 0.1,

})

ミキシングの調整を考える方法

パラメータ

制御内容

ガイダンス

customer_data_percent

各トレーニングバッチ(training batch)におけるドメインデータの割合。

値を高くするとドメイン特化性が強まるが、忘却リスク(forgetting risk)も高まります。50%はバランスの取れた開始点です。

nova_instruction-following_percent

Nova部分におけるインストラクションフォロー(instruction-following)例の重み。

本番環境で構造化されたプロンプトや出力形式に従う必要がある場合、この値を高く保ってください。

nova_reasoning-*_percent

各種推論能力(数学、コード、計画など)の重み。

下流タスクで多段階推論(multi-step reasoning)が必要な場合、これらの値を上げてみてください。

nova_rai_percent

責任あるAI(Responsible AI)アライメントデータ。

セーフティ行動を維持するため、常にゼロ以外の値にしてください。

nova_baseline_percent

コアな事実知識。

広範な世界知識の保持に役立ちます。

ヒント: デフォルト値から始めてトレーニングジョブを実行し、ドメインタスクとMMLU(大規模マルチタスク言語理解ベンチマーク)の両方で評価した後に反復してください。知能を犠牲にせずに専門的なAIを構築するの投稿では、75/25のカスタマー対Nova比率でもMMLUスコアはほぼベースライン(0.74 vs ベースライン0.75)を維持しつつ、複雑な分類タスクでF1スコア(F1 score)が12ポイント向上することが示されています。

トレーニングジョブの開始

オーバーライドパラメータにより、主要なトレーニングハイパーパラメータ(hyperparameters)を制御できます:

パラメータ

説明

<

原文を表示

This hands-on guide walks through every step of fine-tuning an Amazon Nova model with the Amazon Nova Forge SDK, from data preparation to training with data mixing to evaluation, giving you a repeatable playbook you can adapt to your own use case. This is the second part in our Nova Forge SDK series, building on the SDK introduction and first part, which covered kicking off customization experiments.

The focus of this post is data mixing: the technique that lets you fine-tune on domain-specific data without sacrificing a model’s general capabilities. In the previous post, we made the case for why this matters, blending customer data with Amazon-curated datasets preserved near-baseline Massive Multitask Language Understanding (MMLU) scores while delivering a 12-point F1 improvement on a Voice of Customer classification task spanning 1,420 leaf categories. By contrast, fine-tuning an open-source model on customer data alone caused a near-total loss of general capabilities. Now we show you how to do it yourself.

Solution overview

The workflow consists of five stages:

  • Environment setup – Install the Nova Forge SDK and configure AWS resources
  • Data preparation – Load, sanitize, transform, validate, and split your training data
  • Training configuration – Configure the Amazon SageMaker HyperPod runtime, MLflow tracking, and data mixing ratios
  • Model training – Launch and monitor a supervised fine-tuning job with Low-Rank Adaptation (LoRA)
  • Model evaluation – Run public benchmarks and domain-specific evaluations against the fine-tuned checkpoint

Prerequisites

Before you begin, make sure you have the following:

  • An AWS account with access to Amazon Nova Forge
  • A SageMaker HyperPod cluster provisioned with GPU instances. This walkthrough uses ml.p5.48xlarge instances. Setting up a HyperPod cluster involves configuring an Amazon Elastic Kubernetes Service (Amazon EKS) cluster, provisioning compute nodes, and creating execution roles. For detailed instructions, see Getting started with SageMaker HyperPod.
  • An Amazon SageMaker MLflow application for experiment tracking
  • An IAM role with permissions for SageMaker, Amazon Simple Storage Service (Amazon S3), and Amazon CloudWatch
  • A SageMaker Studio notebook or similar Jupyter environment

Cost consideration: This walkthrough uses 4 ml.p5.48xlarge instances for training and for evaluation. These are high-end GPU instances. We recommend starting with a short test run (max_steps=5) to validate your configuration before committing to a full training run. For current rates, see the Amazon SageMaker pricing page.

Step 1: Install the Nova Forge SDK and dependencies

The SDK requires the SageMaker HyperPod CLI tooling. Download and install it from the Nova Forge S3 distribution bucket (provided during your Nova Forge onboarding) or use the following easy-to-use installer script that installs the dependencies from the private S3 bucket and sets up a virtual environment.

code
# Download the HyperPod CLI Installer from Github (Only applicable for Forge)

curl –O https://github.com/aws-samples/amazon-nova-samples/blob/main/customization/nova-forge-hyperpod-cli-installation/install_hp_cli.sh

# Run the Installer

bash install_hp_cli.sh

Next, within the same virtual environment, also install the Nova Forge SDK (nova-forge-sdk) which provides the high-level APIs for data preparation, training, and evaluation.

code
pip install --upgrade botocore awscli
pip install amzn-nova-forge
pip install datasets huggingface_hub pandas pyarrow

After all dependencies are installed, activate the virtual environment and set it as a kernel for use within a Jupyter notebook environment.

code
source ~/hyperpod-cli-venv/bin/activate
pip install ipykernel
python -m ipykernel install --user --name=hyperpod-cli-venv --
display-name="Forge (hyperpod-cli-venv)"
jupyter kernelspec list

Verify the installation:

code
from amzn_nova_forge import *
print("SDK imported successfully")

Step 2: Configure AWS resources

Create an S3 bucket for your training data and model outputs. Then, grant your HyperPod execution role access to it.

code
import boto3
import time
import json

TIMESTAMP = int(time.time())
S3_BUCKET = f"nova-forge-customisation-{TIMESTAMP}"
S3_DATA_PATH = f"s3://{S3_BUCKET}/demo/input"
S3_OUTPUT_PATH = f"s3://{S3_BUCKET}/demo/output"

sts = boto3.client("sts")
s3 = boto3.client("s3")
ACCOUNT_ID = sts.get_caller_identity()["Account"]
REGION = boto3.session.Session().region_name

# Create the S3 bucket
if REGION == "us-east-1": 
    s3.create_bucket(Bucket=S3_BUCKET)
else: 
    s3.create_bucket( 
        Bucket=S3_BUCKET, 
        CreateBucketConfiguration={"LocationConstraint": REGION}
    )

# Grant HyperPod execution role access
HYPERPOD_ROLE_ARN = f"arn:aws:iam::{ACCOUNT_ID}:role/

"bucket_policy = { 
    "Version": "2012-10-17", 
    "Statement": [{ 
        "Sid": "AllowHyperPodAccess", 
        "Effect": "Allow", 
        "Principal": {"AWS": HYPERPOD_ROLE_ARN}, 
        "Action": ["s3:GetObject", "s3:PutObject", "s3:DeleteObject", "s3:ListBucket"], 
        "Resource": [ 
                f"arn:aws:s3:::{S3_BUCKET}", 
                f"arn:aws:s3:::{S3_BUCKET}/*" 
            ] 
        }]
}

s3.put_bucket_policy(Bucket=S3_BUCKET, Policy=json.dumps(bucket_policy))

Step 3: Prepare your training dataset

The Nova Forge SDK supports JSONL, JSON, and CSV input formats. In this walkthrough, we use the publicly available MedReason dataset from Hugging Face. The dataset contains medical reasoning with approximately 32,700 question-answer pairs to demonstrate fine-tuning for a domain-specific use case.

Download and sanitize the data

The Nova Forge SDK enforces token-level validation on training data. Certain tokens conflict with the model’s internal chat template, specifically the special delimiters Nova uses to separate system, user, and assistant turns during training. If your data contains literal strings like `System: or Assistant:, the model may misinterpret them as turn boundaries, corrupting the training signal. The sanitization step below inserts a space before the colon (e.g., System: → System :) to break the pattern match while preserving readability, and strips special tokens like [EOS] and *` that have reserved meaning in the model’s vocabulary.

`from huggingface_hub import hf_hub_download** import pandas as pd

import json

import re`

Download the dataset

jsonl_path = hf_hub_download(

repo_id=”UCSC-VLAA/MedReason”,

filename=”ours_quality_33000.jsonl”,

repo_type=”dataset”,

local_dir=”.”

)

df = pd.read_json(jsonl_path, lines=True)

Tokens that conflict with the model’s chat template

INVALID_TOKENS = [

“System:”, “SYSTEM:”, “User:”, “USER:”, “Bot:”, “BOT:”,

“Assistant:”, “ASSISTANT:”, “Thought:”, “[EOS]”,

“”, “”, “”,

]

def sanitize_text(text):

for token in INVALID_TOKENS:

if “:” in token:

word = token[:-1]

text = re.sub(rf’\b{word}:’, f'{word} :’, text, flags=re.IGNORECASE)

else:

text = text.replace(token, “”)

return text.strip()

Write sanitized JSONL

with open(“training_data.jsonl”, “w”) as f:

for _, row in df.iterrows():

f.write(json.dumps({

“question”: sanitize_text(row[“question”]),

“answer”: sanitize_text(row[“answer”]),

}) + “\n”)

print(f”Dataset saved: training_data.jsonl ({len(df)} examples)”)

To validate if your data has any of reserved keyword run this script.

Load, transform, and validate with the SDK

The SDK provides a JSONLDatasetLoader that handles the conversion from your raw data format into the structure expected by Nova models.When you call transform(), the SDK wraps each question-answer pair into the Nova chat template format, which is the structured turn-based format that Nova models expect during training. Your raw data goes from simple Q&A pairs to fully formatted multi-turn conversations with the appropriate role tags and delimiters.

Before transform** (your raw JSONL):

code
{ 
    "question": "What are the causes of chest pain in a 45-year-old patient?", 
    "answer": "Chest pain in a 45-year-old can result from cardiac causes such as..."
}

After transform (Nova chat template format):

code
{ 
    "messages": [ 
        {"role": "user", "content": "What are the causes of chest pain in a 45-year-old patient?"}, 
        {"role": "assistant", "content": "Chest pain in a 45-year-old can result from cardiac causes such as..."} 
    ]
} 

The validate() method then checks the transformed data for issues, verifying that the chat template structure is correct, that no invalid tokens remain, and that the data conforms to the requirements for your chosen model and training method.

code
# Initialize the loader, mapping your column names
loader = JSONLDatasetLoader( 
    question="question", 
    answer="answer",
)

loader.load("training_data.jsonl")

# Preview raw data
loader.show(n=3)

# Transform into Nova's expected chat template format
loader.transform(method=TrainingMethod.SFT_LORA, model=Model.NOVA_LITE_2)

# Preview transformed data to verify the structure
loader.show(n=3)

# Validate — prints "Validation completed" if successful
loader.validate(method=TrainingMethod.SFT_LORA, model=Model.NOVA_LITE_2)

train_path = loader.save(f"{S3_DATA_PATH}/train.jsonl")
print(f"Training data: {train_path}")

Step 4: Configure and launch training with data mixing

When you enable data mixing, Nova Forge automatically blends your domain-specific training data with Amazon-curated datasets during fine-tuning. This prevents the model from forgetting its general capabilities while it learns your domain.

A note on training methods: LoRA vs. full-rank SFT

Nova Forge supports multiple fine-tuning approaches. In this walkthrough, we use supervised fine-tuning (SFT) with LoRA (TrainingMethod.SFT_LORA), which is a parameter-efficient method that updates only a small set of low-rank adapter weights rather than all model parameters. LoRA offers faster training, lower compute costs, and is the recommended starting point for most use cases.

Nova Forge also supports full-rank SFT, which updates all model parameters and can incorporate more domain knowledge. However, it requires more compute and is more susceptible to catastrophic forgetting (making data mixing even more important). The previous post in this series demonstrates results using full-rank SFT. Choose full-rank when LoRA doesn’t achieve sufficient domain performance, or when you need deeper model adaptation.

Configure the runtime and MLflow

code
from amzn_nova_customization_sdk.model.model_enums import Platform

cluster_name = "nova-forge-hyperpod"
instance_type = "ml.p5.48xlarge"
instance_count = 4
namespace = "kubeflow"

runtime = SMHPRuntimeManager( 
    instance_type=instance_type, 
    instance_count=instance_count, 
    cluster_name=cluster_name, 
    namespace=namespace,
)

MLFLOW_APP_ID = "" # e.g., "app-XXXXXXXXXXXX"
mlflow_app_arn = f"arn:aws:sagemaker:{REGION}:{ACCOUNT_ID}:mlflow-app/{MLFLOW_APP_ID}"

mlflow_monitor = MLflowMonitor( 
    tracking_uri=mlflow_app_arn, 
    experiment_name="nova-sft-datamix",
)

Create the customizer with data mixing enabled

Pass data_mixing_enabled=True when constructing the NovaModelCustomizer:

code
customizer = NovaModelCustomizer( 
    model=Model.NOVA_LITE_2, 
    method=TrainingMethod.SFT_LORA, 
    infra=runtime, 
    data_s3_path=f"{S3_DATA_PATH}/train.jsonl", 
    output_s3_path=f"{S3_OUTPUT_PATH}/", 
    mlflow_monitor=mlflow_monitor, 
    data_mixing_enabled=True,
)

Understand and tune the data mixing configuration

Data mixing controls how training batches are composed. The customer_data_percent parameter determines what fraction of each batch comes from your domain data. The remaining fraction is filled by Nova-curated datasets, with each nova_*_percent parameter controlling the relative weight of that capability category within the Nova portion*.

For example, with the configuration below:

  • 50% of each training batch consists of your domain data
  • 50% consists of Nova-curated data, distributed across capability categories according to their relative weights

The Nova-side percentages must sum to 100. Each value represents that category’s share of the Nova-curated portion of the batch.

code
# View the default mixing ratios
customizer.get_data_mixing_config() 

You can override these ratios based on your priorities:

code
customizer.set_data_mixing_config({ 
    "customer_data_percent": 50, 
    "nova_agents_percent": 1, 
    "nova_baseline_percent": 10, 
    "nova_chat_percent": 0.5, 
    "nova_factuality_percent": 0.1, 
    "nova_identity_percent": 1, 
    "nova_long-context_percent": 1, 
    "nova_math_percent": 2, 
    "nova_rai_percent": 1, 
    "nova_instruction-following_percent": 13, 
    "nova_stem_percent": 10.5, 
    "nova_planning_percent": 10, 
    "nova_reasoning-chat_percent": 0.5, 
    "nova_reasoning-code_percent": 0.5, 
    "nova_reasoning-factuality_percent": 0.5, 
    "nova_reasoning-instruction-following_percent": 45, 
    "nova_reasoning-math_percent": 0.5, 
    "nova_reasoning-planning_percent": 0.5, 
    "nova_reasoning-rag_percent": 0.4, 
    "nova_reasoning-rai_percent": 0.5, 
    "nova_reasoning-stem_percent": 0.4, 
    "nova_rag_percent": 1, 
    "nova_translation_percent": 0.1,
})

How to think about tuning the mix

Parameter

What it controls

Guidance

customer_data_percent

Share of your domain data in each training batch.

Higher values drive stronger domain specialization but increase forgetting risk. 50% is a balanced starting point.

nova_instruction-following_percent

Weight of instruction-following examples in the Nova portion.

Keep this high if your model needs to follow structured prompts or output formats in production.

nova_reasoning-*_percent

Weights for various reasoning capabilities (math, code, planning, etc.).

Increase these if your downstream tasks require multi-step reasoning.

nova_rai_percent

Responsible AI alignment data.

Always keep this non-zero to preserve safety behaviors.

nova_baseline_percent

Core factual knowledge.

Helps retain broad world knowledge.

Tip: Start with the defaults, run a training job, evaluate on both your domain task and MMLU, then iterate. The Building specialized AI without sacrificing intelligence post shows that even a 75/25 customer-to-Nova split preserves near-baseline MMLU (0.74 vs. 0.75 baseline) while delivering a 12-point F1 improvement on a complex classification task.

Launch the training job

The overrides parameter lets you control key training hyperparameters:

Parameter

Description

<

この記事をシェア

関連記事

InfoQ★32026年4月17日 03:08

AWSがS3 Filesを導入、S3バケットへのファイルシステムアクセスを実現

AWSはS3 Filesを発表し、ユーザーがAmazon S3バケットをマウントして標準ファイルシステムインターフェースでデータにアクセスできるようにした。アプリケーションは標準ファイル操作で読み書きでき、システムが自動的にS3リクエストに変換するため、コンピュートサービスがS3に保存されたデータを直接扱える。

InfoQ★32026年4月18日 20:31

AWSが自動インシデント調査のためのDevOpsエージェントを一般提供開始

AWSは、開発者と運用者がAWS環境での問題のトラブルシューティング、デプロイメントの分析、運用タスクの自動化を支援する生成AI搭載アシスタント「DevOps Agent」の一般提供を開始した。

AWS Machine Learning Blog★32026年4月18日 07:04

Amazon Bedrockの詳細なコスト帰属機能の導入

AWSがAmazon Bedrockの推論コストをIAMプリンシパルごとに自動的に帰属する機能を発表した。これにより、コストの内訳把握、コスト最適化、財務計画が容易になる。

ニュース一覧に戻る元記事を読む