3 Seeding With A Dataset
๐จ NeMo Data Designer 101: Seeding Synthetic Data Generation with an External Dataset
๐ What you'll learn
In this notebook, we will demonstrate how to seed synthetic data generation in Data Designer with an external dataset.
If this is your first time using Data Designer, we recommend starting with the first notebook in this 101 series.
๐ IMPORTANT โย Environment Setup
If you haven't already, follow the instructions in the README to install the necessary dependencies.
You may need to restart your notebook's kernel after setting up the environment.
In this notebook, we assume you have a self-hosted instance of Data Designer up and running.
For deployment instructions, see the Installation Options section of the NeMo Data Designer documentation.
๐ฆ Import the essentials
-
The
data_designermodule ofnemo_microservicesexposes Data Designer's high-level SDK. -
The
essentialsmodule provides quick access to the most commonly used objects.
โ๏ธ Initialize the NeMo Data Designer Client
NeMoDataDesignerClientis responsible for submitting generation requests to the microservice.
๐๏ธ Define model configurations
-
Each
ModelConfigdefines a model that can be used during the generation process. -
The "model alias" is used to reference the model in the Data Designer config (as we will see below).
-
The "model provider" is the external service that hosts the model (see the model config docs for more details).
-
By default, the microservice uses build.nvidia.com as the model provider.
๐๏ธ Initialize the Data Designer Config Builder
-
The Data Designer config defines the dataset schema and generation process.
-
The config builder provides an intuitive interface for building this configuration.
-
The list of model configs is provided to the builder at initialization.
๐ฅ Prepare a seed dataset
-
For this notebook, we'll create a synthetic dataset of patient notes.
-
We will seed the generation process with a symptom-to-diagnosis dataset.
-
We already have the dataset downloaded in the data directory of this repository.
๐ฑ Why use a seed dataset?
Seed datasets let you steer the generation process by providing context that is specific to your use case.
Seed datasets are also an excellent way to inject real-world diversity into your synthetic data.
During generation, prompt templates can reference any of the seed dataset fields.
๐ก About datastores
You can use seed datasets from either the Hugging Face Hub or a locally deployed datastore.
By default, we use the local datastore deployed with the Data Designer microservice.
The datastore endpoint is specified in the deployment configuration.
๐ก Tip
If the dataset already exists in the datastore, you can create the seed dataset reference directly.
See the seed dataset docs for more info.
For example:
from nemo_microservices.data_designer.essentials import SeedDatasetReference # Create reference to existing dataset in the datastore. seed_dataset_reference = SeedDatasetReference( dataset="data-designer/demo/gretelai_symptom_to_diagnosis.csv", datastore_settings={"endpoint": "http://localhost:3000/v1/hf"}, )
๐จ Designing our synthetic patient notes dataset
-
Here we use
add_columnwith keyword arguments (rather than imported config objects). -
Generally, we recommend using concrete objects, but this is a convenient shorthand.
-
Note: The prompt template can reference fields from our seed dataset:
{{ diagnosis }}- the medical diagnosis from the seed data{{ patient_summary }}- the symptom description from the seed data
๐ Iteration is key โย preview the dataset!
-
Use the
previewmethod to generate a sample of records quickly. -
Inspect the results for quality and format issues.
-
Adjust column configurations, prompts, or parameters as needed.
-
Re-run the preview until satisfied.
๐ Analyze the generated data
-
Data Designer automatically generates a basic statistical analysis of the generated data.
-
This analysis is available via the
analysisproperty of generation result objects.
๐ Scale up!
-
Happy with your preview data?
-
Use the
createmethod to submit larger Data Designer generation jobs.
โญ๏ธ Next Steps
Use Data Designer to generate synthetic data for your specific use case!