Build a Domain-Specific Embedding Model in Under a Day
Foto: Hugging Face Blog
# NVIDIA Releases One-Day Guide for Building Domain-Specific Embedding Models NVIDIA's team has published a practical guide for building embedding models tailored to specific domains in just one day. The key innovation is automatic generation of training data from domain documents without manual labeling — instead, an LLM is used to create synthetic question-and-answer pairs. The recipe integrates open-source tools such as NeMo Data Designer, NeMo Automodel, and BEIR. It requires only an Ampere GPU or newer with 80GB of memory. NVIDIA has made available a ready-made dataset generated from documentation as well as source code. Tests showed over 10% improvement in Recall@10 and NDCG@10 metrics, while Atlassian achieved a 26% increase in Recall@60 on JIRA (from 0.751 to 0.951) on a single GPU. The solution addresses a fundamental problem in RAG systems — general-purpose embedding models do not understand specialized vocabulary, contracts, or internal taxonomies. The new pipeline eliminates the need for costly manual labeling, while NVIDIA's ready-to-use NIM tools enable production deployment. This changes access to advanced retrieval systems for enterprises without specialized machine learning expertise.
When we build a RAG (Retrieval-Augmented Generation) system, we always reach the same critical point: general embedding models, trained on billions of web pages, prove helpless against our data. They don't understand specialized terminology in contracts, production logs, or internal taxonomies. They can catch general semantic similarity, but they can't perceive the subtle differences that mean everything in a given domain. The problem is that fine-tuning an embedding model — a process that should be standard in every serious RAG implementation — remains surprisingly fragmented, requiring specialized skills and consuming an inordinate amount of time.
NVIDIA is changing that reality right now. A team of engineers at the company has developed a method that lets you transform a general-purpose embedding model into a tool that deeply understands your domain — all on a single GPU, in less than 24 hours, without needing manual data labeling. This isn't another startup promise. Atlassian tested this recipe on their JIRA dataset and achieved a Recall@60 increase from 0.751 to 0.951 — a 26 percent improvement. On a single GPU.
This changes the game for everyone seriously working with retrieval-augmented generation. This isn't about marginal optimization, but about a qualitative leap that makes your system stop returning random results and actually start understanding the context of your industry.
Read also
Why general embedding models fail in specialized domains
Before we get to the technique, we need to understand exactly where existing solutions fall short. Embedding models like OpenAI text-embedding-3 or Cohere embed are trained on enormous, diverse datasets from the internet. They're fantastic at what they do — they can find similarity between "car" and "vehicle" or between an article about politics and an article about elections. That's semantics of general English language.
But when you come with API documentation, technical reports from your company, or specialized medical literature, these models hit a wall. Take the question: "What is the maximum junction temperature for a GPU H100 in SXM configuration?". A general embedding model can find documents about temperature, about GPUs, about H100 — but it doesn't understand that "junction temperature" is something fundamentally different from "ambient temperature". In medicine, the same problem: a question about "metformin in type 2 diabetes" might return articles about "insulin in type 1 diabetes" — both talk about diabetes and drugs, but the answer would be catastrophic.
General embedding models understand broad categories, but they don't perceive the fine distinctions that in your domain make the difference between a good and bad answer. This is exactly the point where fine-tuning changes everything.
Synthetic training data: how to avoid the hell of manual labeling
The traditional approach to fine-tuning embeddings required something awful: thousands of manually labeled pairs (question, document). For each question, you had to indicate which documents were "relevant" and which weren't. This is a path to madness — time-consuming, prone to individual assessment errors.
NVIDIA solved this problem using synthetic data generation (SDG) powered by LLM. Instead of humans, a neural model reads your documents and automatically generates high-quality question-answer pairs. The process works in four stages:
- Document chunking — dividing your files into logical fragments (typically 200–500 words)
- Question generation — LLM reads each fragment and creates questions that this fragment answers
- Multi-hop question generation — the model synthesizes questions that require combining information from multiple fragments
- Quality assessment — each pair is evaluated for relevance, accuracy, clarity, and contextual support
The result? Take a fragment from H100 GPU documentation: "Thermal design power (TDP) is 700W in SXM form. The cooling solution must maintain junction temperature below 83°C under sustained loads. Liquid cooling is recommended for dense deployments exceeding 4 GPUs per node, because air cooling cannot dissipate sufficient heat in standard 2U enclosures." From this fragment, the pipeline generates both simple factual questions ("What is the TDP of H100 SXM?") and complex causal questions ("How does the 700W TDP of H100 SXM constrain the choice between air and liquid cooling in multi-GPU?"). Each question has assigned complexity (2–5), reasoning type, and overall quality score.
Only pairs that pass the quality threshold make it to the training data. This means that instead of thousands of hours of manual labeling, you get thousands of high-quality training pairs in minutes.
Hard negative mining: teaching the model subtle differences
This is where the real magic begins. If you trained an embedding model only on positive pairs (question + correct document), the model would learn to distinguish obvious cases but would fail on difficult ones. In a real retrieval system, the hardest are fragments that look relevant but aren't the right answer — "near-misses" that force the model to think.
Hard negative mining finds exactly those fragments. Here's how it works: the pipeline takes your baseline embedding model and computes similarity between each question and each fragment in your collection. It then masks known positive documents and looks for fragments that the model considers very relevant but that aren't the correct answer. Key element: a safety margin is applied — fragments too similar to positives are rejected because they may actually be correct answers that just weren't labeled during synthetic data generation.
Result: hard negatives are fragments that are really confusing for the model — similar enough to be challenging, but different enough to be genuinely negative. In a medical collection, a question about "metformin in type 2 diabetes" might have hard negatives about "metformin side effects" or "insulin in type 1 diabetes". Training on such examples forces the model to learn subtle distinctions that are critical for your domain.
By default, the pipeline selects 5 hard negatives per question. This number — according to NVIDIA research — represents the optimal balance between training strength and computational time.
Multi-hop questions: why single fragments aren't enough
Most retrieval systems are trained on simple pairs: one question, one document. This works for factual questions ("How much does it cost?", "When did this happen?"), but the real world is more complicated. Users ask questions that require synthesizing information from multiple documents.
Take an example: "Given H100 TDP, cooling constraints, and rack density limits, what is the maximum number of H100 GPUs that can be deployed in a standard data center row?" This question requires combining information from three different documents — about TDP, cooling systems, and infrastructure constraints.
NVIDIA's pipeline generates questions with 1 to 3 hops. Each hop is one reasoning step. 1-hop questions are simple. 2-hop questions require combining two fragments. 3-hop questions synthesize three fragments. Each question has assigned IDs of segments that support it, so the training data preserves the full reasoning chain. After unrolling, each pair (question, fragment) becomes an independent training signal — the model learns that all these fragments are relevant for the multi-hop question. This means the fine-tuned model will learn to retrieve documents that are contextually related, not just lexically similar.
The fine-tuning process: from data to trained model
NVIDIA chose Llama-Nemotron-Embed-1B-v2 as the baseline model for this recipe. It's a 1-billion parameter model — a size that represents a perfect compromise between quality and inference cost. Large enough to understand complex semantics, small enough to run on a single A100 or H100.
Fine-tuning uses contrastive learning with a biencoder architecture. Biencoder means the model has two identical encoders: one for questions, one for documents. Both encoders are identical — it's the same model with the same weights. During training, the model learns to encode questions and documents such that questions are close to their positive documents and far from hard negatives.
Key hyperparameter: temperature is 0.02 — deliberately aggressive. It creates a very sharp probability distribution, meaning the model receives strong gradients to learn the difference between hard negatives and positives. This works because the hard negatives from step 2 are high-quality — genuinely confusing fragments that the model must learn to distinguish.
Default hyperparameters are: 3 epochs, learning rate 1e-5, batch size 128 (1 positive + 4 hard negatives per question). For large datasets you can reduce epochs to 1–2. For small datasets (below 2000 examples), the pipeline automatically scales batch size down to 16–64 so gradients are meaningful. This means you can start with a small collection (50–100 documents) for proof-of-concept and scale later without changing code.
The entire fine-tuning — from synthetic data to trained model — takes less than 24 hours on a single A100 or H100. This is a turning point for everyone working with RAG at enterprise scale.
Evaluation: did fine-tuning really help?
After fine-tuning, you need to know if it worked. NVIDIA uses the BEIR framework — a standard benchmark for evaluating information retrieval. The pipeline computes four metrics on a test set (20% of data, set aside before fine-tuning):
- nDCG@k (Normalized Discounted Cumulative Gain) — ranking quality. Are the best documents ranked high?
- Recall@k — coverage. What percentage of relevant documents were retrieved in top-k results?
- Precision@k — accuracy. What percentage of retrieved documents are actually relevant?
- MRR (Mean Reciprocal Rank) — at what position does the first relevant document appear?
Metrics are computed for k = 1, 5, 10, and 100. This gives a complete picture: how the model performs in tight top-1, in reasonable top-10, and in broader top-100.
In NVIDIA's tests on public H100 documentation, the fine-tuned model showed over 10% improvement in both Recall@10 and NDCG@10 compared to the baseline model. Atlassian, testing this recipe on their JIRA dataset, achieved a Recall@60 increase from 0.751 to 0.951 — that's a 26% jump on a single GPU. This is not a marginal increase. This is a leap that changes the usefulness of the system.
Production deployment: from model to service
After fine-tuning and evaluation, you have a trained model. Now you need to deploy it. NVIDIA provides NeMo Export-Deploy to convert the model to ONNX and TensorRT formats — optimized for production. ONNX (Open Neural Network Exchange) is an open format that allows models to run on different platforms. TensorRT is NVIDIA's inference engine, offering dramatic speedup on GPUs.
For serving in production, NVIDIA recommends NVIDIA NIM (NVIDIA Inference Microservices) — a containerized inference service that automatically handles batching, caching, and scaling. NIM lets you serve the model as a REST API without writing infrastructure code — just run the container and send queries.
The entire workflow is integrated. You don't need to stitch together tools from five different companies. This is a cohesive pipeline from raw documents to production retrieval service.
Practical implications: who should do this now
This recipe is not a theoretical exercise. It's a practical tool for specific use cases. If you're building a RAG system for companies that have: — Large repositories of internal documents (procedures, policies, specialized reports) — Specialized terminology that isn't well represented in general models — High requirements for retrieval accuracy (wrong answers are costly) …then fine-tuning embeddings using this recipe is essential.
The cost is minimal: one GPU, less than 24 hours, no manual labeling. The gain is significant: 20–30% improvement in recall, which means your RAG system returns better documents, which means the LLM generates better answers.
This is the point where RAG transitions from "interesting experiment" to "production system we can rely on".
More from Models
The First Healthcare Robotics Dataset and Foundational Physical AI Models for Healthcare Robotics



