1日以内にドメイン固有の埋め込みモデルを構築する
Hugging Faceのブログ記事は、ラベル付きデータを必要とせず、1日以内に単一GPUでドメイン固有の埋め込みモデルを微調整する方法を紹介し、Atlassianの事例ではRecall@60が26%向上した実績を示している。
キーポイント
ドメイン固有埋め込みモデルの効率的な微調整手法
一般目的の埋め込みモデルがドメイン固有のニュアンスを捉えられない問題を解決するため、ラベルなしドキュメントから合成トレーニングデータを生成し、1日以内に単一GPUで微調整する手法を提案している。
合成データ生成とハードネガティブマイニングの活用
NVIDIAの公開ドキュメントから生成した合成データセットを提供し、効果的なコントラスティブ学習のためにハードネガティブマイニングとマルチホップクエリを活用することで、埋め込み品質を向上させる。
実証された性能向上効果
NVIDIAドキュメントでの評価ではRecall@10とNDCG@10が10%以上向上し、AtlassianのJIRAデータセットではRecall@60が0.751から0.951へ26%改善するなど、実用的な効果が確認されている。
オープンソースツールチェーンの統合レシピ
NeMo Data Designer、NeMo Automodel、BEIR、NeMo Export-Deploy、NVIDIA NIMなどのオープンソースプロジェクトを統合した完全なレシピを提供し、データ生成から本番推論までのパイプラインを構築できる。
実用的な実装ガイドと前提条件
テキストドキュメントのディレクトリ、NVIDIA APIキー、Ampere以降のGPU(80GBメモリ以上)などの前提条件を明確にし、具体的なステップバイステップのチュートリアルを提供している。
SDGパイプラインによる高品質な合成QAペアの自動生成
LLM(nemotron-3-nano-30b-a3b)を使用してドキュメントを読み取り、単純な事実検索から多段階・因果推論を要する複雑な質問まで、多様なタイプの高品質な合成QAペアを自動生成する。
QAペアの品質評価と選別
生成された各QAペアは関連性、正確性、文脈サポート、明確さのサブスコアと総合スコアで評価され、閾値を満たしたもののみがトレーニングに使用される。
影響分析・編集コメントを表示
影響分析
この記事は、RAGシステムの実用化における最大の課題であるドメイン適応問題を、低コスト・短期間で解決する実用的な方法論を提供している。企業が自社の専門領域に特化した高精度な検索システムを構築する障壁を大幅に下げ、AI応用の民主化を推進する重要な進展と言える。
編集コメント
理論ではなく実践に焦点を当てたチュートリアル記事で、企業が実際に直面するRAGの課題に対して、具体的なツールと数値結果を示しながら解決策を提供している点が評価できる。
Back to Articles Build a Domain-Specific Embedding Model in Under a Day
Upvote 2

RAG(Retrieval-Augmented Generation、検索拡張生成)システムを構築しているなら、この壁にぶつかったことがあるでしょう:すべてがうまくいく…はずが、そうならない瞬間が来ます。汎用埋め込みモデルはインターネットを理解するように訓練されていますが、あなたの契約書、製造ログ、独自の化学処方、社内分類体系を理解しているわけではありません。それらは広範な意味的類似性を捉えますが、あなたのドメインで重要な細かい区別を理解しません。既製モデルがドメイン固有のニュアンスを効果的に捉えられない場合、埋め込みモデルのファインチューニング(微調整)を行うことで、検索パイプラインの性能を向上させることができます。埋め込みがRAGの性能にとってどれほど重要であるにもかかわらず、そのプロセスは驚くほど断片的で、必要なスキルは専門的であり、時間投資は気が遠くなるものです。
単一のGPUと1日未満の訓練時間で、汎用埋め込みモデルを、あなたのドメインを真に理解するモデルに変えることができます。手動ラベリングは必要ありません。すぐに始められるように、この正確なパイプラインを使用してNVIDIAの公開ドキュメントから生成された、すぐに使用できる合成訓練データセットも公開します。このデータとレシピを使用して、Recall@10とNDCG@10の両方で10%以上の改善が見られました。Atlassianはこのレシピを彼らのJIRAデータセットに適用してファインチューニングを行い、Recall@60を0.751から0.951に、26%改善しました - 単一のGPUでです。
🔗データセットとコードへのクイックリンク:
Embedding Model
Synthetic dataset on NVIDIA’s public documents
🧑💻オープンソースプロジェクト レシピ統合:
合成データ生成のためのNeMo Data Designer
埋め込みモデル訓練のためのNeMo Automodel
情報検索評価のためのBEIR
ONNX/TensorRT変換のためのNeMo Export-Deploy
本番推論サービングのためのNVIDIA NIM
📋前提条件:
ドメイン文書のディレクトリ(テキストファイル - .txt、.md、または類似形式)
有効なNVIDIA APIキー(build.nvidia.comで無料)
少なくとも80GBメモリを搭載したNVIDIA Ampere GPU以降(Compute Capability >= 8.0) このチュートリアルは1xA100(80GB)および1xH100(80GB)でテストされています
この投稿の終わりまでに、以下の方法を知ることができます: 📄 ラベル付きデータなしでドメイン文書から訓練データを生成する 🎯 効果的な対照学習のためのハードネガティブマイニングを使用する 🔗 マルチホップクエリで埋め込み品質を改善する ⚙️ バイエンコーダ埋め込みモデルをファインチューニングする 📊 ファインチューニングが検索を改善するか評価する 🚀 ファインチューニングされたモデルをパイプラインにデプロイする
このチュートリアルでは、ベースモデルLlama-Nemotron-Embed-1B-v2 - 品質と推論コストのバランスをとる10億パラメータの埋め込みモデル - をファインチューニングします。始めるには、このセットアップガイドに従ってください。
📚 ステップ1:文書から訓練データを生成する
埋め込みモデルのファインチューニングには、数千の(クエリ、関連文書)ペアが必要です。ほとんどのユースケースでは、このデータはすぐには利用できません。手動で作成するのは高価で遅く、しばしばアノテーターの「関連性」に対する個人的解釈によって偏りが生じます。手作業でデータにラベルを付ける代わりに、LLM(nvidia/nemotron-3-nano-30b-a3b)を使用して文書を読み取り、高品質の合成質問-回答ペアを自動生成できます。
nemotron embed sdg -c default corpus_dir=./data/my_domain_docs
どのように機能するか?
舞台裏では、NeMo Data Designerによって駆動される4段階の合成データ生成(SDG)パイプラインが実行されます:

出力はどのようなものか?
ソース文書チャンク:
H100 GPUの熱設計電力(TDP)は、SXMフォームファクタで700Wです。冷却ソリューションは、持続ワークロード下で接合部温度を83°C未満に維持する必要があります。液体冷却は、ノードあたり4GPUを超える高密度デプロイメントに推奨されます。なぜなら、空冷では標準2Uシャーシ構成で十分な熱を放散できないからです。
生成されたQAペア:
{ "question": "サーバーノードあたり4台を超えるH100 GPUをデプロイする場合、どの冷却アプローチが推奨されますか?", "answer": "ノードあたり4GPUを超える高密度デプロイメントには液体冷却が推奨されます。なぜなら、空冷では標準2Uシャーシ構成で十分な熱を放散できないからです。", "query_type": "contextual", "reasoning_type": "factual", "question_complexity": 3, "segment_ids": [1], "quality_score": 8.5 }
{ "question": "H100 SXMの700W TDPは、マルチGPU構成における空冷と液体冷却の選択をどのように制約しますか?", "answer": "700W TDPは、接合部温度を83°C未満に保つために放散しなければならない大量の熱を発生させます。ノードあたり4GPUを超える高密度構成では、標準2Uシャーシでの空冷はこの熱負荷を処理できず、液体冷却が必要になります。", "query_type": "multi_hop", "reasoning_type": "causal", "question_complexity": 4, "segment_ids": [1, 2], "hop_count": 2, "quality_score": 9.0 }
違いに注意してください:最初の質問は単純な事実検索です。2番目はマルチホップ、因果推論を必要とします。パイプラインは両方のタイプを生成し、構成可能な複雑度レベル(2–5)とホップ数(1–3)を持ちます。各QAペアは品質評価を受け、関連性、正確性、文脈サポート、明瞭さのサブスコアと全体スコアを受け取ります。閾値を満たすペアのみが訓練に含まれます。
⛏️ ステップ2:ハードネガティブをマイニングする(そしてなぜそれが重要か)
ポジティブペア(クエリ+正解文書)のみで埋め込みモデルを訓練すると、明らかに異なる文書を区別することを学びますが、難しいケース - 関連しているように見えるが正しい答えではない文章 - では失敗します。実際の検索システムでは、これらのニアミスこそが悪い答えを引き起こす文書です。ハードネガティブマイニングは、これらの紛らわしい文章を見つけ出し、モデルがそれらを区別することを学べるようにします。
nemotron embed prep -c default
上記のコマンドは自動的に3つのサブステップを実行します:
2a. 訓練/検証/テスト分割
生成されたQAペアは、訓練セット(80%)とテストセット(20%)に分割されます。テストセットは、ステップ5での標準化評価のためのBEIR互換ベンチマークとしてフォーマットされます。
2b. ハードネガティブマイニング
ベース埋め込みモデルを使用して、パイプラインは:
コーパス内のすべてのクエリとすべての文章を埋め込みます。
各クエリとすべての文章の間の類似性を計算します。
各クエリのラベル付きポジティブ文書をマスクアウトします。
マージンフィルターを適用:最小ポジティブスコアの95%を超えるスコアを持つ非ポジティブ文書は除外されます。この除外ゾーンは、偽ネガティブ - ポジティブに非常に近く、実際に関連している可能性のあるラベルなし文章 - を防ぎます。
残った候補から、トップkの最高スコア文書をハードネガティブとして選択します(デフォルトでクエリあたり5つ)。
結果:ハードネガティブは、ポジティブスコア上限を安全に下回る、最も類似した非ポジティブ文章です。それらは現在のモデルが非常に関連性が高いと考えるが、ラベル付けされた答えではない文章です。
なぜこれが機能するか:簡単なネガティブ(完全に関連のない文章)で訓練しても、モデルは何も新しいことを学びません。ハードネガティブで訓練することで、あなたのドメインで重要な微妙な区別を学ぶことを強制します。例えば、医療コーパスでは、「2型糖尿病のメトホルミン投与量」に関する質問は、「メトホルミンの副作用」や「1型糖尿病のインスリン投与量」に関するハードネガティブを持つかもしれません - 近いが決定的に異なります。95%マージン上限は、マイナーがポジティブに近すぎる文章を選択するのを防ぎます。それらは実際には正解であり、単にSDG中にラベル付けされなかった可能性があります。
2c. マルチホップアンローリング
マルチホップ質問は複数のポジティブ文書を参照します。例えば、「セクション3.2の熱管理システムは、セクション5.1で説明されている電力制約とどのように関連しますか?」という質問には2つのポジティブ文章があります。
アンローリングは(クエリ、ポジティブ文書)ペアごとに1つの訓練例を作成し、対照損失が各ポジティブを独立して見るようにします。2つのポジティブ文書を持つ質問は2つの訓練例になり、それぞれ同じハードネガティブを持ちますが、異なるポジティブを持ちます。
最終出力は訓練準備済みJSONファイルです:
{ "question_id": "q42_0", "question": "H100 SXMの700W TDPは、マルチGPUノードにおける冷却選択をどのように制約しますか?", "pos_doc": [{"id": "d_a1b2c3"}], "neg_doc": [{"id": "d_x7y8z9"}, {"id": "d_m4n5o6"}, {"id": "d_p1q2r3"}, {"id": "d_s4t5u6"}, {"id": "d_v7w8x9"}] }
🔍 ステップ3:マルチホップ質問を理解し、なぜそれが検索を改善するか
標準的な埋め込みファインチューニングは、文章ごとに1つの質問を生成し、モデルがそれらを一致させるように訓練します。これは単純な事実検索には機能しますが、実際のユーザーは複数の文書やセクションにまたがる複雑な質問をします。モデルがシングルホップ訓練データしか見ていない場合、これらの複雑なクエリに対してすべての関連文章を検索するのに苦労します。
SDGパイプラインはデフォルトで1から3ホップの質問を生成します:
1ホップ:「H100 SXMのTDPは何ですか?」 - 単一の文章で回答。
2ホップ:「H100のTDPは、高密度デプロイメントにおける冷却要件とどのように関連しますか?」 - 2つの文章からの情報を接続する必要があります。
3ホップ:「TDP、冷却制約、ラック密度制限を考慮して、標準データセンター列にデプロイ可能なH100 GPUの最大数は何ですか?」 - 3つの文章を統合します。
各ホップは独自の文脈要約とセグメントIDで追跡されるため、訓練データは完全な推論チェーンを保持します。アンローリング(ステップ2c)後、各(質問、関連文章)ペアは独立した訓練信号となり、モデルにこれらの文章すべてがマルチホップクエリに関連していることを教えます。
ファインチューニングされたモデルは、語彙的に類似したものだけでなく、文脈的に関連する文書を検索することを学びます。
🧠 ステップ4:埋め込みモデルをファインチューニングする
nemotron embed finetune -c default
対照学習の仕組み
トレーニングは、コントラスティブ損失(contrastive loss)を用いたバイエンコーダー(biencoder)アーキテクチャを使用します。

温度(temperature)0.02は意図的に攻撃的に設定されており、非常に鋭い確率分布を生成します。これは、ステップ2からのハードネガティブ(hard negatives)が高品質であるため、うまく機能します。それらは真に紛らわしい文章であり、モデルが区別を学ぶために強い勾配を必要とします。
主要なハイパーパラメータ
大規模データセットの場合、2または1に下げてもよい
チューニング: デフォルト値の2倍と半分を試す
学習率ウォームアップステップ数
微調整の総ステップ数の5〜10%に設定して、初期トレーニングの安定性を向上させる
グローバルバッチサイズ
小規模データセットでは自動的に縮小される
クエリあたりの文章数
1ポジティブ(positive)+ 4ハードネガティブ(hard negatives)
小規模データセットの自動スケーリング
データセットのトレーニング例が2,000未満の場合、パイプラインは自動的に以下を行います:
バッチサイズを縮小(16〜64)して勾配が意味を持つようにする。
チェックポイント頻度を調整して、実行ごとに少なくとも3つのチェックポイントを確実に生成する。
検証頻度を比例的にスケーリングする。
これは、迅速な概念実証のために小さなコーパス(50〜100ドキュメント)から始め、後で拡張できることを意味します。
📈 ステップ5: 改善を測定する
微調整は実際に役立ったでしょうか?ベースモデルと微調整済みチェックポイントをホールドアウトテストセットで比較する標準化された評価を実行して確認しましょう:
nemotron embed eval -c default
評価はBEIR(BEIR)フレームワークを使用し、k = 1、5、10、100で4つの標準情報検索(information retrieval)メトリクスを計算します:
nDCG@k: ランキング品質 — 最良のドキュメントが最高位にランクされているか?
Recall@k: カバレッジ — 関連ドキュメントのうち、上位k件に現れる割合は?
Precision@k: 精度 — 上位k件の結果のうち、実際に関連している割合は?
MAP@k: 全クエリにわたる平均適合率(average precision)
成功した微調整では、通常、1日以内にnDCG@10とRecall@10が15%改善します。
Retrieval Synthetic NVDocsを使用した結果:
📊 比較(ベース -> 微調整後) ============================================================ NDCG: NDCG@1: 0.55178 → 0.60796 (+0.05618, +10.2%) NDCG@5: 0.51894 → 0.57689 (+0.05795, +11.2%) NDCG@10: 0.55506 → 0.61559 (+0.06053, +10.9%) NDCG@100: 0.60617 → 0.66567 (+0.05950, +9.8%) Recall: Recall@1: 0.28478 → 0.31547 (+0.03069, +10.8%) Recall@5: 0.54486 → 0.60288 (+0.05802, +10.6%) Recall@10: 0.62979 → 0.69296 (+0.06317, +10.0%) Recall@100: 0.81421 → 0.87020 (+0.05599, +6.9%)
数値が改善しない場合は?
パイプラインにより、反復が容易になります:
SDGの品質スコアが低い?ドキュメント品質を確認してください — クリーンで適切にフォーマットされたテキストは、より優れた合成データ(synthetic data)を生成します。より大規模で強力なLLM(Large Language Model)を試してください。
トレーニングデータが不足している?コーパスにドキュメントを追加して、ステージ0を再実行してください。
過学習(overfitting)?エポック数を減らすか、品質閾値を上げて最良のトレーニング例のみを保持してください。
学習率が不適切?大規模データセットには5e-6、非常に小規模なデータセットには2e-5を試してください。
🏆 実世界の結果: Atlassian
このレシピは、Atlassianによって実際の企業データで検証されています。彼らはこのパイプラインを適用し、上記と同じステージに従って、単一のNVIDIA A100 80GB GPUを使用して公開JiraデータセットでLlama-Nemotron-Embed-1B-v2を微調整しました。
Recall@60は0.751から0.951に跳ね上がり、26.7%の向上を示しました。微調整済みモデルは、クエリの95.1%に対して上位60件の結果内で正しいドキュメントを検索します。これは、ベースモデルの75.1%から向上しています。Jira検索を支える検索システムにとって、これは数百万のユーザーにより関連性の高い結果をもたらすことになります。詳細は彼らのブログ記事「Advancing semantic search for millions of Rovo users」をご覧ください。

🚀 ステップ6: エクスポートとデプロイ
PyTorchチェックポイントは評価には優れていますが、本番環境では遅すぎます。最後の2つのステージでは、モデルを変換してAPIの背後で提供します。
ONNX / TensorRTへのエクスポート
nemotron embed export -c default
これにより、微調整済みチェックポイントがONNX(opset 17)にエクスポートされます。オプションで、最大推論スループットのためにTensorRTエンジンをコンパイルし、バッチサイズ(1〜64)とシーケンス長(3〜256)に対して設定可能な最適化プロファイルを提供します:
ONNXのみ(どこでも実行可能) nemotron embed export -c default export_to_trt=false # FP8量子化(quantization)によるさらなる高速化 nemotron embed export -c default quant_cfg=fp8
NVIDIA NIMでのデプロイ
エクスポートされたモデルは、NVIDIA NIMコンテナ内にデプロイされます — これは、OpenAI互換の/v1/embeddingsエンドポイントを公開する、本番環境対応の推論マイクロサービスです:
nemotron embed deploy -c default
実行中であれば、どのクライアントも呼び出すことができます:
curl -X POST http://localhost:8000/v1/embeddings \ -H "Content-Type: application/json" \ -d '{"input": ["What cooling is needed for 8 H100 GPUs in a 2U chassis?"], "model": "custom", "input_type": "query"}'
NIMはOpenAI互換APIを提供するため、埋め込みAPI形式を使用する既存のRAG(Retrieval-Augmented Generation)パイプラインにコード変更なしで組み込むことができます。
デプロイ精度の検証
パイプラインには、デプロイされたエンドポイントに対して同じBEIR評価を実行するNIM精度検証ステップが含まれています:
nemotron embed eval -c default eval_nim=true eval_base=false
これにより、ONNX/TensorRT変換による精度損失を捕捉します。許容範囲内(@1では0.03、@5以上では0.01)で一致するメトリクスはチェックマークで示され、変換ノイズを超える偏差はフラグが立てられます。
全体をまとめる
完全な埋め込み微調整パイプラインは、生ドキュメントからデプロイ済みモデルまで、6つのコマンドで実行できます。
1. ドキュメントから合成トレーニングデータを生成 nemotron embed sdg -c default corpus_dir=./data/my_docs # 2. トレーニングデータを準備(データ分割、ハードネガティブマイニング、アンロール) nemotron embed prep -c default # 3. 埋め込みモデルを微調整 nemotron embed finetune -c default # 4. ベースモデルと微調整済みモデルを評価 nemotron embed eval -c default # 5. 最適化モデルをエクスポート nemotron embed export -c default # 6. モデルをデプロイ nemotron embed deploy -c default
予想時間とリソース
コーパスサイズとAPIレート制限によって異なる
必要(40 GB VRAM)
GPUでのハードネガティブマイニング
必要(80 GB VRAM)
データセットサイズとエポック数によって異なる
必要(40 GB VRAM)
必要(40 GB VRAM)
TensorRTにはNGCコンテナが必要
必要(40 GB VRAM)
NIMコンテナ起動
合計: 1日以内、ほとんどの時間は人手を介さないトレーニングです。小さなコーパス(約500ドキュメント)の場合、パイプライン全体は約2〜3時間で完了します。
パイプラインはエンドツーエンドで実行できますが、各ステージは開始点に応じて独立して実行することもできます。例えば、生ドキュメントがある場合は合成データ生成(SDG)から始めることができ、ハードネガティブが既に含まれているデータセットは初期ステップをスキップして直接微調整に進むことができます。各ステージはJSON、BEIR、ONNXなどの標準フォーマットを使用するため、カスタムコンポーネントを統合したり、中間出力を他のワークフローで再利用したりするのが容易です。このレシピは、ローカルマシン、Dockerコンテナ内、またはSlurmベースのクラスタでの実行など、実行方法にも柔軟性があります。
自分で試す
ドメインのドキュメントと少しの時間があれば、今日中に最初のバッチの合成トレーニングデータを生成できます!ドキュメントからドメイン適応済みの埋め込みモデルがデプロイされるまでの完全なパイプラインは、単一GPUで1日以内に実行できます。すぐにパイプラインを試すには、既製のnvidia/Retrieval-Synthetic-NVDocs-v1データセットから始めることができます。何を構築したか教えてください。Nemotron、NeMo Data Designer、NeMo Automodelのリポジトリが役立つと思ったら、スターを付けてください。




原文を表示
Back to Articles Build a Domain-Specific Embedding Model in Under a Day
Upvote 2

If you are building a RAG (Retrieval-Augmented Generation) system, you have likely hit this wall: Everything works… until it doesn’t. General-purpose embedding models are trained to understand the internet; not your contracts, manufacturing logs, proprietary chemical formulations or internal taxonomy. They capture broad semantic similarity, but they do not understand the fine-grained distinctions that matter in your domain. Fine-tuning an embedding model can improve the performance of your retrieval pipeline when off-the-shelf models fail to effectively capture domain-specific nuances. Despite how critical embeddings are to RAG performance, the process remains surprisingly fragmented, the skills required are specialized, and the time investment is daunting.
With a single GPU and less than a day of training time, you can transform a general-purpose embedding model into one that truly understands your domain, no manual labeling required. To help you hit the ground running, we are also releasing a ready-to-use synthetic training dataset generated from NVIDIA's public documentation using this exact pipeline. Using this data and the recipe, we saw over 10% improvement in both Recall@10 and NDCG@10. Atlassian applied this recipe to fine-tune on their JIRA dataset, increasing Recall@60 from 0.751 to 0.951, a 26% improvement - on a single GPU.
🔗Quick Links to Dataset and Codes:
Embedding Model
Synthetic dataset on NVIDIA’s public documents
🧑💻Open Source Projects Recipe Integrates:
NeMo Data Designer for synthetic data generation
NeMo Automodel for embedding model training
BEIR for Information retrieval evaluation
NeMo Export-Deploy for ONNX/TensorRT conversion
NVIDIA NIM for production inference serving
📋Prerequisites:
A directory of domain documents (text files - .txt, .md, or similar)
A valid NVIDIA API key (free at build.nvidia.com)
NVIDIA Ampere GPU or newer with at least 80GB memory (with Compute Capability >= 8.0) This tutorial has been tested on 1xA100 (80GB), and 1xH100 (80GB)
By the end of this post, you’ll know how to answer: 📄 Generate training data from domain documents without labeled data 🎯 Use hard negative mining for effective contrastive training 🔗 Improve embedding quality with multi-hop queries ⚙️ Fine-tune a bi-encoder embedding model 📊 Evaluate whether fine-tuning improves retrieval 🚀 Deploy the fine-tuned model in your pipeline
In this tutorial, we will finetune the base model Llama-Nemotron-Embed-1B-v2 - a 1-billion-parameter embedding model that balances quality and inference cost. To get started, follow this setup guide.
📚 Step 1: Generate Training Data from Documents
Fine-tuning an embedding model requires thousands of (query, relevant document) pairs. Most use cases don’t have this data readily available. Creating it manually is expensive, slow, and often biased by the annotator’s personal interpretation of what’s “relevant.” Instead of labeling data by hand, you can use an LLM (nvidia/nemotron-3-nano-30b-a3b) to read your documents and automatically generate high-quality synthetic question–answer pairs.
nemotron embed sdg -c default corpus_dir=./data/my_domain_docs
How does it work?
Behind the scenes, this runs a four-stage synthetic data generation (SDG) pipeline powered by NeMo Data Designer:

What does the output look like?
Source document chunk:
The thermal design power (TDP) of the H100 GPU is 700W in SXM form factor. The cooling solution must maintain junction temperature below 83°C under sustained workloads. Liquid cooling is recommended for dense deployments exceeding 4 GPUs per node, as air cooling cannot dissipate sufficient heat in standard 2U chassis configurations.
Generated QA pairs:
{ "question": "What cooling approach is recommended when deploying more than 4 H100 GPUs per server node?", "answer": "Liquid cooling is recommended for dense deployments exceeding 4 GPUs per node, as air cooling cannot dissipate sufficient heat in standard 2U chassis configurations.", "query_type": "contextual", "reasoning_type": "factual", "question_complexity": 3, "segment_ids": [1], "quality_score": 8.5 }
{ "question": "How does the 700W TDP of the H100 SXM constrain the choice between air and liquid cooling in multi-GPU configurations?", "answer": "The 700W TDP generates substantial heat that must be dissipated to keep junction temperatures below 83°C. In dense configurations exceeding 4 GPUs per node, air cooling in standard 2U chassis cannot handle this thermal load, making liquid cooling necessary.", "query_type": "multi_hop", "reasoning_type": "causal", "question_complexity": 4, "segment_ids": [1, 2], "hop_count": 2, "quality_score": 9.0 }
Notice the difference: the first question is a simple factual lookup. The second requires multi-hop, causal reasoning. The pipeline generates both types, with configurable complexity levels (2–5) and hop counts (1–3). Each QA pair then undergoes quality evaluation, receiving sub-scores for relevance, accuracy, context support, and clarity, along with an overall score. Only pairs that meet the threshold are included in training.
⛏️ Step 2: Mine Hard Negatives (and Why They Matter)
If you train an embedding model with only positive pairs (query + correct document), it learns to distinguish obviously different documents but fails on the hard cases — passages that look relevant but are not the right answer. In a real retrieval system, these near-misses are exactly the documents that cause bad answers. Hard negative mining finds these confusing passages so the model can learn to tell them apart.
nemotron embed prep -c default
The above command runs three sub-steps automatically:
2a. Train / Validation / Test Split
The generated QA pairs are split into training (80%) and test (20%) sets. The test set is formatted as a BEIR-compatible benchmark for standardized evaluation in Step 5.
2b. Hard Negative Mining
Using the base embedding model, the pipeline:
Embeds every query and every passage in the corpus.
Computes similarity between each query and all passages.
Masks out each query's labeled positive documents.
Applies a margin filter: any non-positive document scoring above 95% of the minimum positive score is eliminated. This exclusion zone guards against false negatives — unlabeled passages that are so close to the positive they may actually be relevant.
From the surviving candidates, selects the top-k highest-scoring documents as hard negatives (5 per query by default).
The result: hard negatives are the most similar non-positive passages that still fall safely below the positive-score ceiling. They are passages the current model considers highly relevant but that are not the labeled answer.
Why this works: Training on easy negatives (completely unrelated passages) teaches the model nothing new. Training on hard negatives forces it to learn the subtle distinctions that matter in your domain. For example, in a medical corpus, a question about "metformin dosage for Type 2 diabetes" might have hard negatives about "metformin side effects" or "insulin dosage for Type 1 diabetes" — close but critically different. The 95% margin ceiling prevents the miner from selecting passages that are too close to the positive, which could actually be correct answers that simply weren't labeled during SDG.
2c. Multi-Hop Unrolling
Multi-hop questions reference multiple positive documents. For example, a question like "How does the thermal management system in Section 3.2 relate to the power constraints described in Section 5.1?" has two positive passages.
Unrolling creates one training example per (query, positive document) pair, so the contrastive loss sees each positive independently. A question with 2 positive documents becomes 2 training examples, each with the same hard negatives but a different positive.
The final output is a training-ready JSON file:
{ "question_id": "q42_0", "question": "How does the 700W TDP of the H100 SXM constrain cooling choices in multi-GPU nodes?", "pos_doc": [{"id": "d_a1b2c3"}], "neg_doc": [{"id": "d_x7y8z9"}, {"id": "d_m4n5o6"}, {"id": "d_p1q2r3"}, {"id": "d_s4t5u6"}, {"id": "d_v7w8x9"}] }
🔍 Step 3: Understand Multi-Hop Questions and Why They Improve Retrieval
Standard embedding fine-tuning generates one question per passage and trains the model to match them. This works for simple factual lookups, but real users ask complex questions that span multiple documents or sections. If the model has only seen single-hop training data, it will struggle to retrieve all the relevant passages for these complex queries.
The SDG pipeline generates questions at 1 to 3 hops by default:
1-hop: "What is the TDP of the H100 SXM?" — answered by a single passage.
2-hop: "How does the H100's TDP relate to cooling requirements in dense deployments?" — requires connecting information from two passages.
3-hop: "Given the TDP, cooling constraints, and rack density limits, what is the maximum number of H100 GPUs deployable in a standard data center row?" — synthesizes three passages.
Each hop is tracked with its own context summary and segment IDs, so the training data preserves the full reasoning chain. After unrolling (Step 2c), each (question, relevant passage) pair becomes an independent training signal, teaching the model that all of these passages are relevant to the multi-hop query.
The fine-tuned model learns to retrieve contextually related documents, not just lexically similar ones.
🧠 Step 4: Fine-Tune the Embedding Model
nemotron embed finetune -c default
How contrastive learning works
The training uses a biencoder architecture with contrastive loss.

The temperature of 0.02 is deliberately aggressive, it produces a very sharp probability distribution. This works well because the hard negatives from Step 2 are high-quality: they are genuinely confusing passages that the model needs strong gradients to learn to distinguish.
Key hyperparameters
For large dataset, you may lower it to 2 or 1
Tuning: try double and half of the default value
Learning rate warmup steps
Set to 5-10% of total steps of finetune to have better early training stability
Global batch size
Auto-scaled down for small datasets
Passages per query
1 positive + 4 hard negatives
Auto-scaling for small datasets
If your dataset has fewer than 2,000 training examples, the pipeline automatically:
Reduces the batch size (to 16–64) so gradients are meaningful.
Adjusts checkpoint frequency to ensure at least three checkpoints per run.
Scales validation frequency proportionally.
This means you can start with a small corpus (50–100 documents) for a quick proof-of-concept and scale up later.
📈 Step 5: Measure the Improvement
Did fine-tuning actually help? Let’s find out by running a standardized evaluation comparing the base model against the fine-tuned checkpoint on the held-out test set:
nemotron embed eval -c default
The evaluation uses the BEIR framework and computes four standard information retrieval metrics at k = 1, 5, 10, and 100:
nDCG@k: Ranking quality — are the best documents ranked highest?
Recall@k: Coverage — what fraction of relevant documents appear in the top k?
Precision@k: Accuracy — what fraction of the top k results are actually relevant?
MAP@k: Average precision across all queries
A successful fine-tune typically results in a 15% improvement in nDCG@10 and Recall@10 within <1 day.
Results using Retrieval Synthetic NVDocs:
📊 Comparison (Base -> Fine-tuned) ============================================================ NDCG: NDCG@1: 0.55178 → 0.60796 (+0.05618, +10.2%) NDCG@5: 0.51894 → 0.57689 (+0.05795, +11.2%) NDCG@10: 0.55506 → 0.61559 (+0.06053, +10.9%) NDCG@100: 0.60617 → 0.66567 (+0.05950, +9.8%) Recall: Recall@1: 0.28478 → 0.31547 (+0.03069, +10.8%) Recall@5: 0.54486 → 0.60288 (+0.05802, +10.6%) Recall@10: 0.62979 → 0.69296 (+0.06317, +10.0%) Recall@100: 0.81421 → 0.87020 (+0.05599, +6.9%)
What if the numbers don't improve?
The pipeline makes it easy to iterate:
Low quality scores in SDG? Check your document quality — clean, well-formatted text produces better synthetic data. Try a larger and more powerful LLM.
Not enough training data? Add more documents to your corpus and re-run Stage 0.
Overfitting? Reduce epochs or increase the quality threshold to keep only the best training examples.
Wrong learning rate? Try 5e-6 for larger datasets or 2e-5 for very small ones.
🏆 Real-World Results: Atlassian
This recipe has been validated on real enterprise data by Atlassian. They applied this pipeline to fine-tune Llama-Nemotron-Embed-1B-v2 on a public Jira dataset using a single NVIDIA A100 80GB GPU, following the same stages described above
Recall@60 jumped from 0.751 to 0.951 — a 26.7% gain. The fine-tuned model retrieves the correct document within the top 60 results for 95.1% of queries, up from 75.1% with the base model. For a retrieval system underpinning Jira search, this directly translates into more relevant results for millions of users. Find more details in their blog post Advancing semantic search for millions of Rovo users.

🚀 Step 6: Export and Deploy
A PyTorch checkpoint is great for evaluation but too slow for production. The final two stages convert the model and serve it behind an API.
Export to ONNX / TensorRT
nemotron embed export -c default
This exports the fine-tuned checkpoint to ONNX (opset 17). Optionally, it compiles a TensorRT engine for maximum inference throughput, with configurable optimization profiles for batch size (1–64) and sequence length (3–256):
ONNX only (runs anywhere) nemotron embed export -c default export_to_trt=false # FP8 quantization for further speedup nemotron embed export -c default quant_cfg=fp8
Deploy with NVIDIA NIM
The exported model is deployed inside an NVIDIA NIM container — a production-ready inference microservice exposing an OpenAI-compatible /v1/embeddings endpoint:
nemotron embed deploy -c default
Once running, any client can call it:
curl -X POST http://localhost:8000/v1/embeddings \ -H "Content-Type: application/json" \ -d '{"input": ["What cooling is needed for 8 H100 GPUs in a 2U chassis?"], "model": "custom", "input_type": "query"}'
Because NIM serves an OpenAI-compatible API, you can drop it into any existing RAG pipeline that uses the embeddings API format — no code changes needed.
Verify deployment accuracy
The pipeline includes a NIM accuracy verification step that runs the same BEIR evaluation against the deployed endpoint:
nemotron embed eval -c default eval_nim=true eval_base=false
This catches any accuracy loss from the ONNX/TensorRT conversion. Metrics that match within tolerance (0.03 for @1, 0.01 for @5+) are marked with a check; deviations beyond conversion noise are flagged.
Putting It All Together
The full embedding fine-tuning pipeline can be run in six commands, from raw documents to a deployed model.
1. Generate synthetic training data from your documents nemotron embed sdg -c default corpus_dir=./data/my_docs # 2. Prepare the training data (split data, mine hard negatives, unroll) nemotron embed prep -c default # 3. Fine-tune the embedding model nemotron embed finetune -c default # 4. Evaluate the base vs. fine-tuned model nemotron embed eval -c default # 5. Export the optimized model nemotron embed export -c default # 6. Deploy the model nemotron embed deploy -c default
Expected time and resources
Varies by corpus size and API rate limit
Yes (40 GB VRAM)
Hard negative mining on GPU
Yes (80 GB VRAM)
Varies by dataset size and epochs
Yes (40 GB VRAM)
Yes (40 GB VRAM)
TensorRT requires NGC container
Yes (40 GB VRAM)
NIM container startup
Total: under a day, with most time being hands-off training. For a small corpus (~500 documents), the entire pipeline completes in about 2–3 hours.
The pipeline can run end-to-end, but each stage can also be executed independently depending on your starting point. For example, if you have raw documents, you can begin with synthetic data generation (SDG), while datasets that already include hard negatives can skip earlier steps and go directly to fine-tuning. Since every stage uses standard formats such as JSON, BEIR, and ONNX, it’s easy to integrate custom components or reuse intermediate outputs in other workflows. The recipe is also flexible in how it runs, supporting execution on a local machine, inside Docker containers, or on Slurm-based clusters.
Try It Yourself
If you have domain documents and some time in your hand, you can generate your first batch of synthetic training data today! The full pipeline - from documents to a deployed, domain-adapted embedding model - runs in under a day on a single GPU. You can start with our ready-made nvidia/Retrieval-Synthetic-NVDocs-v1 dataset to try the pipeline right away. Let us know what you build. Star the repos for Nemotron, NeMo Data Designer and NeMo Automodel if you find them useful.




関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み