Notebooks
N
NVIDIA
3 Seeding With A Dataset

3 Seeding With A Dataset

gpu-accelerationretrieval-augmented-generationllm-inferencetensorrtnvidia-generative-ai-examplesself-hosted-tutorialslarge-language-modelsmicroservicetriton-inference-serverLLMragnemoNeMo-Data-Designergetting-started

๐ŸŽจ 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_designer module of nemo_microservices exposes Data Designer's high-level SDK.

  • The essentials module provides quick access to the most commonly used objects.

[ ]

โš™๏ธ Initialize the NeMo Data Designer Client

  • NeMoDataDesignerClient is responsible for submitting generation requests to the microservice.
[ ]

๐ŸŽ›๏ธ Define model configurations

  • Each ModelConfig defines 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_column with 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!

  1. Use the preview method to generate a sample of records quickly.

  2. Inspect the results for quality and format issues.

  3. Adjust column configurations, prompts, or parameters as needed.

  4. 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 analysis property of generation result objects.

[ ]

๐Ÿ†™ Scale up!

  • Happy with your preview data?

  • Use the create method to submit larger Data Designer generation jobs.

[ ]
[ ]
[ ]
[ ]

โญ๏ธ Next Steps

Use Data Designer to generate synthetic data for your specific use case!