Seeding with External Datasets

View as Markdown

This tutorial demonstrates how to use external datasets as seed data for synthetic data generation in Data Designer.

For more detail about seed dataset behavior, see the open-source library’s version of this tutorial.

Seed Sources by Execution Mode

Seed source support depends on where the workload executes:

Seed sourceCLI runCLI submit / SDK todayUse case
Local files or DataFramesSupportedNot supportedFast local iteration with files available to the CLI process.
HuggingFaceSupportedSupportedPublicly available datasets or private HuggingFace datasets.
Files API FilesetsSupported when NeMo Services access is configuredSupportedShared seed data stored through the Files API.

run versus submit controls where the workload executes. A local run can still read Files API Filesets if the configuration references them and NeMo Services access is configured.

HuggingFace Datasets

Use HuggingFaceSeedSource to load data from HuggingFace:

1import data_designer.config as dd
2
3# Public dataset
4dd.HuggingFaceSeedSource(path="datasets/username/dataset/data/*.parquet")
5
6# Private dataset (requires token)
7dd.HuggingFaceSeedSource(
8 path="datasets/username/dataset/data/*.parquet",
9 token="default/hf-token", # Reference to a Secrets API secret
10)

Files API Filesets

Use FilesetFileSeedSource to load data through the Files API. This works in CLI run, CLI submit, and SDK execution when NeMo Services access is configured:

1from data_designer_nemo.fileset_file_seed_source import FilesetFileSeedSource
2
3FilesetFileSeedSource(
4 path="default/my-fileset#data.parquet" # Format: workspace/fileset#file-path
5)

Path format:

  • Fully qualified: workspace/fileset-name#file-path (recommended)
  • Implicit workspace: fileset-name#file-path (uses client’s workspace)

Prerequisites

Ensure you have completed the tutorials prerequisites. This tutorial uses an Inference Gateway provider, so local CLI run and NeMo Services execution both need access to the Inference Gateway API in a running NeMo Services cluster.

Example: Medical Notes from Symptom Data

This example generates realistic patient medical notes by seeding with publicly available symptom-to-diagnosis data. It uploads the seed data to a Files API Fileset so the same configuration can run locally through CLI run or through NeMo Services execution.

Step 1: Upload Seed Data

Upload the symptom-to-diagnosis dataset to a Files API Fileset:

1import os
2import tempfile
3import urllib.request
4from nemo_platform import NeMoPlatform
5
6WORKSPACE = "default"
7FILESET_NAME = "seed-data"
8FILE_PATH = "symptom_to_diagnosis.csv"
9
10base_url = os.environ.get("NMP_BASE_URL", "http://localhost:8080")
11client = NeMoPlatform(base_url=base_url, workspace=WORKSPACE)
12
13# Create fileset
14client.files.filesets.create(name=FILESET_NAME)
15
16# Download and upload seed data
17with tempfile.NamedTemporaryFile(suffix=".csv") as tmpfile:
18 url = "https://raw.githubusercontent.com/NVIDIA/GenerativeAIExamples/refs/heads/main/nemo/NeMo-Data-Designer/data/gretelai_symptom_to_diagnosis.csv"
19 urllib.request.urlretrieve(url, tmpfile.name)
20
21 client.files.upload(
22 fileset=FILESET_NAME,
23 local_path=tmpfile.name,
24 remote_path=FILE_PATH,
25 )

Step 2: Build Configuration

Define your models and create a config builder:

1import data_designer.config as dd
2
3MODEL_ALIAS = "text"
4
5model_configs = [
6 dd.ModelConfig(
7 provider="default/nvidia-build",
8 model="nvidia/nemotron-3-nano-30b-a3b", # Use the `served_model_name` from the provider
9 alias=MODEL_ALIAS,
10 inference_parameters=dd.ChatCompletionInferenceParams(
11 temperature=1.0,
12 top_p=1.0,
13 ),
14 )
15]
16
17config_builder = dd.DataDesignerConfigBuilder(model_configs)

Step 3: Configure Seed Dataset

Add the seed data to your configuration:

1from data_designer_nemo.fileset_file_seed_source import FilesetFileSeedSource
2
3config_builder.with_seed_dataset(
4 FilesetFileSeedSource(path=f"{WORKSPACE}/{FILESET_NAME}#{FILE_PATH}")
5)

What this does: The seed dataset’s columns (diagnosis, patient_summary, etc.) are automatically added to your dataset and available for use in other columns.

Step 4: Add Synthetic Columns

Add columns that reference and extend the seed data:

1# Patient details
2config_builder.add_column(
3 dd.SamplerColumnConfig(
4 name="patient_sampler",
5 sampler_type=dd.SamplerType.PERSON_FROM_FAKER,
6 params=dd.PersonFromFakerSamplerParams(),
7 )
8)
9
10# Doctor details
11config_builder.add_column(
12 dd.SamplerColumnConfig(
13 name="doctor_sampler",
14 sampler_type=dd.SamplerType.PERSON_FROM_FAKER,
15 params=dd.PersonFromFakerSamplerParams(),
16 )
17)
18
19# Patient ID
20config_builder.add_column(
21 dd.SamplerColumnConfig(
22 name="patient_id",
23 sampler_type=dd.SamplerType.UUID,
24 params=dd.UUIDSamplerParams(
25 prefix="PT-",
26 short_form=True,
27 uppercase=True,
28 ),
29 )
30)
31
32# Extract patient name from sampler
33config_builder.add_column(
34 dd.ExpressionColumnConfig(
35 name="first_name",
36 expr="{{ patient_sampler.first_name }}",
37 )
38)
39
40config_builder.add_column(
41 dd.ExpressionColumnConfig(
42 name="last_name",
43 expr="{{ patient_sampler.last_name }}",
44 )
45)
46
47config_builder.add_column(
48 dd.ExpressionColumnConfig(
49 name="dob",
50 expr="{{ patient_sampler.birth_date }}",
51 )
52)
53
54# Symptom onset date
55config_builder.add_column(
56 dd.SamplerColumnConfig(
57 name="symptom_onset_date",
58 sampler_type=dd.SamplerType.DATETIME,
59 params=dd.DatetimeSamplerParams(start="2024-01-01", end="2024-12-31"),
60 )
61)
62
63# Visit date (1-30 days after symptom onset)
64config_builder.add_column(
65 dd.SamplerColumnConfig(
66 name="date_of_visit",
67 sampler_type=dd.SamplerType.TIMEDELTA,
68 params=dd.TimeDeltaSamplerParams(
69 dt_min=1,
70 dt_max=30,
71 reference_column_name="symptom_onset_date",
72 ),
73 )
74)
75
76# Physician name
77config_builder.add_column(
78 dd.ExpressionColumnConfig(
79 name="physician",
80 expr="Dr. {{ doctor_sampler.last_name }}",
81 )
82)
83
84# LLM-generated physician notes
85config_builder.add_column(
86 dd.LLMTextColumnConfig(
87 name="physician_notes",
88 prompt="""\
89You are a primary-care physician who just had an appointment with {{ first_name }} {{ last_name }},
90who has been struggling with symptoms from {{ diagnosis }} since {{ symptom_onset_date }}.
91The date of today's visit is {{ date_of_visit }}.
92
93{{ patient_summary }}
94
95Write careful notes about your visit with {{ first_name }},
96as Dr. {{ doctor_sampler.first_name }} {{ doctor_sampler.last_name }}.
97
98Format the notes as a busy doctor might.
99Respond with only the notes, no other text.
100""",
101 model_alias=MODEL_ALIAS,
102 )
103)

Note: The diagnosis and patient_summary variables come from the seed dataset columns.

Step 5: Execute

Because this example uses a Files API Fileset and an Inference Gateway provider, even local CLI execution communicates with NeMo Services APIs.

For CLI execution, save the configuration in medical_notes.py and expose a load_config_builder() function that returns the config_builder.

1def load_config_builder() -> dd.DataDesignerConfigBuilder:
2 return config_builder

Preview locally:

$nemo data-designer preview run medical_notes.py --num-records 5

Generate a larger dataset locally:

$nemo data-designer create run medical_notes.py --num-records 30

Submit to NeMo Services:

$nemo data-designer preview submit medical_notes.py --workspace default --num-records 5
$nemo data-designer create submit medical_notes.py --workspace default --profile default --num-records 30

You can also execute through the SDK service path.

Create a client:

1# Using the client instance from Step 1
2data_designer = client.data_designer

Previewing the Dataset

Use the preview method for rapid iteration:

1preview = data_designer.preview(config_builder)
2
3# Display a random sample record
4preview.display_sample_record()
5
6# Access the full preview dataset as a pandas DataFrame
7df = preview.dataset
8print(df.head())
9
10# View statistical analysis
11preview.analysis.to_report()

The PreviewResults object returned by client.data_designer.preview stores all its fields in memory; nothing is persisted to disk by default. Use standard Python methods to save any preview data you want to keep around longer term. For example, the dataset is a regular Pandas DataFrame and can be saved to disk via methods like to_csv or to_parquet.

Generating the Full Dataset

When you’re satisfied with the preview, submit a larger generation job:

1# Defaulting to 30 for demo speed purposes. Happy with the output? Scale it up!
2job = data_designer.create(config_builder, num_records=30)
3
4# Block until the job completes
5job.wait_until_done()
6
7# Download the generated artifacts
8results = job.download_artifacts()
9
10# Load the dataset as a pandas DataFrame
11dataset = results.load_dataset()
12print(dataset.head())
13
14# Load the full analysis report
15analysis = results.load_analysis()
16analysis.to_report()

The Data Designer library writes several artifacts to disk when running a full generation job, including the final dataset as parquet. When a Data Designer job runs through NeMo Services, the entire working directory of artifacts produced by the library is saved as a job result. The download_artifacts method downloads this artifacts directory (stored as a .tar.gz archive), unarchives it, and returns a DataDesignerJobResults object that can be used to load results into memory as DataFrames or other objects for programmatic inspection.

By default, download_artifacts saves the artifacts to a relative local directory named after the job. An alternative path can be passed to download_artifacts.

How Seeding Works

When you configure a seed dataset:

  1. Automatic Column Addition: All columns from the seed data are automatically added to your dataset schema
  2. Dependency Resolution: Data Designer resolves dependencies between seed columns and synthetic columns
  3. Execution Order: Seed data is loaded first, then synthetic columns are generated row-by-row
  4. Row Alignment: Each generated row corresponds to one row from the seed dataset

Example: If your seed data has 100 rows with columns diagnosis and patient_summary, and you request 100 records, each generated record will include the seed columns plus any synthetic columns you defined.

Next Steps