Physician Notes With Realistic Personal Details
π§ββοΈ NeMo Data Designer: Realistic Patient Data & Physician Notes
π What you'll learn
This notebook demonstrates how to use NeMo Data Designer to generate realistic patient data including physician notes.
We'll leverage both structured data generation and LLM capabilities to create a comprehensive medical dataset.
The dataset includes:
- Policy and claim details
- Policyholder and claimant information (PII)
- Claim descriptions and adjuster notes with embedded PII
- Medical information for relevant claims
π 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.
π± Loading Seed Data
-
We'll use the symptom-to-diagnosis dataset as our seed data.
-
This dataset contains patient symptoms and corresponding diagnoses which will help generate realistic medical scenarios.
π± 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.
π Note: At this time, we only support using a single file as the seed. If you have multiple files you would like to use as
seeds, it is recommended you consolidated these into a single file.
π‘ 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"}, )
π² Creating Person Samplers
-
We create persona samplers to simulate details about the patient and the doctor
-
The persona samplers allow you to sample realistic details of individuals using a model trained on the US Census.
If the locale of the persona you are generating is anything other thanen_US, then the personas will be generated using Faker
ποΈ Defining Data Structure
Now we'll define the structure of our dataset by adding columns for patient information, dates, and medical details. We'll use:
uuidfor patient identification- Patient personal information (
first_name,last_name,dob,patient_email) - Medical timeline information (
symptom_onset_date,date_of_visit) - Physician information (
physician)
π¦ LLM-Generated Physician Notes
The final and most complex column uses an LLM to generate realistic physician notes. We provide:
- Context about the patient and their condition
- Patient summary from our seed data
- Clear formatting instructions
This will create detailed medical notes that reflect the patient's diagnosis and visit information.
π 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.