Providing Images as Context
🎨 Data Designer Tutorial: Providing Images as Context for Vision-Based Data Generation
📚 What you'll learn
This notebook demonstrates how to provide images as context to generate text descriptions using vision-language models.
The same multi_modal_context field can also carry audio or video context when the selected model supports those modalities.
- ✨ Visual Document Processing: Converting images to chat-ready format for model consumption
- 🔍 Vision-Language Generation: Using vision models to generate detailed summaries from images
- 🧩 Media Context Pattern: Understanding how
ImageContext,AudioContext, andVideoContextfit into the same configuration field
If this is your first time using Data Designer, we recommend starting with the first notebook in this tutorial series.
📦 Import Data Designer
-
data_designer.configprovides access to the configuration API. -
DataDesigneris the main interface for data generation.
⚙️ Initialize the Data Designer interface
-
DataDesigneris the main object responsible for managing the data generation process. -
When initialized without arguments, the default model providers are used.
🏗️ 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.
-
When initialized without arguments, the default model configurations are used.
🌱 Seed Dataset Creation
In this section, we'll prepare our visual documents as a seed dataset for summarization:
- Loading Visual Documents: We use a small pets image dataset containing labeled images
- Image Processing: Convert images to base64 format for vision model consumption
- Metadata Extraction: Preserve relevant image information (label, etc.)
The seed dataset will be used to generate detailed text descriptions of each image.
📥 Loading and processing images...
Warning: You are sending unauthenticated requests to the HF Hub. Please set a HF_TOKEN to enable higher rate limits and faster downloads.
[20:13:03] [WARNING] Warning: You are sending unauthenticated requests to the HF Hub. Please set a HF_TOKEN to enable higher rate limits and faster downloads.
README.md: 0.00B [00:00, ?B/s]
dataset_infos.json: 0.00B [00:00, ?B/s]
data/train.zip: 0%| | 0.00/20.4M [00:00<?, ?B/s]
data/test.zip: 0%| | 0.00/3.29M [00:00<?, ?B/s]
Generating train split: 0%| | 0/900 [00:00<?, ? examples/s]
Generating test split: 0%| | 0/150 [00:00<?, ? examples/s]
Map: 0%| | 0/900 [00:00<?, ? examples/s]
✅ Loaded 512 images with columns: ['image', 'label', 'base64_image', 'uuid']
| image | label | base64_image | uuid | |
|---|---|---|---|---|
| 0 | <PIL.JpegImagePlugin.JpegImageFile image mode=... | 0 | iVBORw0KGgoAAAANSUhEUgAAAeQAAAIACAIAAADc8YinAA... | a3d8610e-41ad-4df8-845e-a431c9e702ed |
| 1 | <PIL.JpegImagePlugin.JpegImageFile image mode=... | 0 | iVBORw0KGgoAAAANSUhEUgAAAiQAAAIACAIAAAA9rOAHAA... | fcf0dde5-75a8-4e82-92d4-7265179c8617 |
| 2 | <PIL.JpegImagePlugin.JpegImageFile image mode=... | 0 | iVBORw0KGgoAAAANSUhEUgAAAqoAAAIACAIAAADFYNm1AA... | 54ebe843-05e8-4fc7-87a1-3130b8d7f266 |
| 3 | <PIL.JpegImagePlugin.JpegImageFile image mode=... | 0 | iVBORw0KGgoAAAANSUhEUgAAAwAAAAIACAIAAAC6lJxtAA... | 9e9b7b60-9aa2-40a7-bd8d-5d493c505654 |
| 4 | <PIL.PngImagePlugin.PngImageFile image mode=RG... | 0 | iVBORw0KGgoAAAANSUhEUgAAAqoAAAIACAIAAADFYNm1AA... | 2c61cc25-9662-4327-a7f2-221116a3c97c |
DataDesignerConfigBuilder( seed_dataset: df seed )
🧩 Media context and model capabilities
multi_modal_context accepts media context descriptors such as ImageContext, AudioContext, and VideoContext. Data Designer reads the referenced seed columns and serializes them for the model request, but the selected model still determines which modalities are valid.
This notebook uses image context only because image-capable VLMs are broadly available. Before combining image, audio, and video in one column, choose a model alias backed by an omni or otherwise modality-compatible model, and check that the provider accepts every context type you send.
For base64 seed columns, store the raw base64 payload without a data:<media-type>;base64, prefix and specify the media format on the context object:
media_context = [
dd.ImageContext(
column_name="image_base64",
data_type=dd.ModalityDataType.BASE64,
image_format=dd.ImageFormat.PNG,
),
dd.AudioContext(
column_name="audio_base64",
data_type=dd.ModalityDataType.BASE64,
audio_format=dd.AudioFormat.MP3,
),
dd.VideoContext(
column_name="video_base64",
data_type=dd.ModalityDataType.BASE64,
video_format=dd.VideoFormat.MP4,
),
]
URL-backed media can use data_type=dd.ModalityDataType.URL, subject to the provider's URL support and file-size limits. Local audio/video paths require explicit URL mode and require the model endpoint to have filesystem access to the same paths, typically a colocated vLLM server configured for local media access.
[20:14:24] [INFO] ✅ Validation passed
🔁 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.
[20:14:24] [INFO] 📺 Preview generation in progress
[20:14:24] [INFO] |-- 🔒 Jinja rendering engine: secure
[20:14:24] [INFO] ✅ Validation passed
[20:14:24] [INFO] ⛓️ Sorting column configs into a Directed Acyclic Graph
[20:14:24] [INFO] 🩺 Running health checks for models...
[20:14:24] [INFO] |-- 👀 Checking 'nvidia/nemotron-3-nano-omni-30b-a3b-reasoning' in provider named 'nvidia' for model alias 'nvidia-vision'...
[20:14:25] [INFO] |-- ✅ Passed!
[20:14:25] [INFO] ⚡ Using async task-queue preview
[20:14:25] [INFO] 📝 llm-text model config for column 'description'
[20:14:25] [INFO] |-- model: 'nvidia/nemotron-3-nano-omni-30b-a3b-reasoning'
[20:14:25] [INFO] |-- model alias: 'nvidia-vision'
[20:14:25] [INFO] |-- model provider: 'nvidia'
[20:14:25] [INFO] |-- inference parameters:
[20:14:25] [INFO] | |-- generation_type=chat-completion
[20:14:25] [INFO] | |-- max_parallel_requests=4
[20:14:25] [INFO] | |-- temperature=0.60
[20:14:25] [INFO] | |-- top_p=0.95
[20:14:25] [INFO] ⚡️ Async generation: 1 column(s) (column 'description'), 2 tasks across 1 row group(s)
[20:14:25] [INFO] 🚀 (1/1) Dispatching with 2 records
[20:14:25] [INFO] 🌱 (1/1) Sampling 2 records from seed dataset
[20:14:25] [INFO] |-- seed dataset size: 512 records
[20:14:25] [INFO] |-- sampling strategy: ordered
[20:14:31] [INFO] 📊 Progress [6.1s]:
[20:14:31] [INFO] |-- 😸 column 'description': 1/2 (50%) 0.2 rec/s
[20:14:34] [INFO] 📊 Progress [9.1s]:
[20:14:34] [INFO] |-- 🦁 column 'description': 2/2 (100%) 0.2 rec/s
[20:14:34] [INFO] ✅ Async generation complete [9.1s]: 2 ok, 0 failed across 1 column(s)
[20:14:34] [INFO] 📊 Model usage summary:
[20:14:34] [INFO] |-- model: nvidia/nemotron-3-nano-omni-30b-a3b-reasoning
[20:14:34] [INFO] |-- tokens: input=658, output=1691, reasoning=981 (estimated), total=2349, tps=258
[20:14:34] [INFO] |-- reasoning token count estimated with tiktoken
[20:14:34] [INFO] |-- requests: success=2, failed=0, total=2, rpm=13
[20:14:34] [INFO] 📐 Measuring dataset column statistics:
[20:14:34] [INFO] |-- 📝 column: 'description'
[20:14:34] [INFO] 🎆 Preview complete!
Seed Columns ┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Name ┃ Value ┃ ┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ uuid │ a3d8610e-41ad-4df8-845e-a431c9e702ed │ ├──────────────┼─────────────────────────────────────────────────────────────────────────────────────────────┤ │ label │ 0 │ ├──────────────┼─────────────────────────────────────────────────────────────────────────────────────────────┤ │ base64_image │ iVBORw0KGgoAAAANSUhEUgAAAeQAAAIACAIAAADc8YinAAEAAElEQVR4nOy9V5ckuZEmamZwEREpSna1YAv28JLDHT… │ └──────────────┴─────────────────────────────────────────────────────────────────────────────────────────────┘ Generated Columns ┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Name ┃ Value ┃ ┡━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ description │ # Close-up of a Black and White Cat │ │ │ │ │ │ The image is a close-up portrait of a domestic cat, likely a tuxedo cat, characterized by │ │ │ its distinct black and white fur pattern. │ │ │ │ │ │ - **Main Subject**: The primary focus is the cat's face, filling most of the frame. It has a │ │ │ predominantly white muzzle and a white blaze running up the center of its forehead between │ │ │ its eyes. The rest of its head, including the ears and the areas surrounding the eyes, is │ │ │ black. │ │ │ - **Eyes**: The cat has large, round eyes with a striking yellow-green or chartreuse hue. │ │ │ Its pupils are dark and vertical, typical of felines. │ │ │ - **Facial Features**: It has a small, pinkish-black nose. Notably, there is a small patch │ │ │ of black fur directly beneath its nose, resembling a tiny mustache or goatee. │ │ │ - **Whiskers**: Long, white whiskers extend outward from the sides of its nose and above its │ │ │ eyes, standing out against the darker fur. │ │ │ - **Background**: The background is out of focus (bokeh effect). To the left, there is a │ │ │ plain, light-colored wall (likely white or off-white). To the right, a vertical strip of │ │ │ what appears to be a wooden door frame or panel is visible in a light tan color. │ │ │ - **Expression**: The cat is looking slightly upward and forward with an alert, perhaps │ │ │ curious, expression. │ └─────────────┴──────────────────────────────────────────────────────────────────────────────────────────────┘
| uuid | label | base64_image | description | |
|---|---|---|---|---|
| 0 | a3d8610e-41ad-4df8-845e-a431c9e702ed | 0 | iVBORw0KGgoAAAANSUhEUgAAAeQAAAIACAIAAADc8YinAA... | # Close-up of a Black and White Cat\n\nThe ima... |
| 1 | fcf0dde5-75a8-4e82-92d4-7265179c8617 | 0 | iVBORw0KGgoAAAANSUhEUgAAAiQAAAIACAIAAAA9rOAHAA... | # Detailed Description\n\n## Main Subject\nThe... |
📊 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.
──────────────────────────────────────── 🎨 Data Designer Dataset Profile ───────────────────────────────────────── Dataset Overview ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ number of records ┃ number of columns ┃ percent complete records ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ 2 │ 1 │ 100.0% │ └─────────────────────────────────┴─────────────────────────────────┴─────────────────────────────────────────────┘ 📝 LLM-Text Columns ┏━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ ┃ ┃ ┃ prompt tokens ┃ completion tokens ┃ ┃ column name ┃ data type ┃ number unique values ┃ per record ┃ per record ┃ ┡━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ description │ string │ 2 (100.0%) │ 29.0 +/- 0.0 │ 332.0 +/- 65.0 │ └──────────────────┴───────────────┴──────────────────────────────┴─────────────────────┴─────────────────────────┘ ╭────────────────────────────────────────────────── Table Notes ──────────────────────────────────────────────────╮ │ │ │ 1. All token statistics are based on a sample of max(1000, len(dataset)) records. │ │ 2. Tokens are calculated using tiktoken's cl100k_base tokenizer. │ │ │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
🔎 Visual Inspection
Let's compare the original image with the generated description to validate quality:
📄 Original Image:
📝 Generated Description:
╭─ Image Description ─────────────────────────────────────────────────────────────────────────────────────────────╮ │ # Close-up of a Black and White Cat │ │ │ │ The image is a close-up portrait of a domestic cat, likely a tuxedo cat, characterized by its distinct black │ │ and white fur pattern. │ │ │ │ - **Main Subject**: The primary focus is the cat's face, filling most of the frame. It has a predominantly │ │ white muzzle and a white blaze running up the center of its forehead between its eyes. The rest of its head, │ │ including the ears and the areas surrounding the eyes, is black. │ │ - **Eyes**: The cat has large, round eyes with a striking yellow-green or chartreuse hue. Its pupils are dark │ │ and vertical, typical of felines. │ │ - **Facial Features**: It has a small, pinkish-black nose. Notably, there is a small patch of black fur │ │ directly beneath its nose, resembling a tiny mustache or goatee. │ │ - **Whiskers**: Long, white whiskers extend outward from the sides of its nose and above its eyes, standing out │ │ against the darker fur. │ │ - **Background**: The background is out of focus (bokeh effect). To the left, there is a plain, light-colored │ │ wall (likely white or off-white). To the right, a vertical strip of what appears to be a wooden door frame or │ │ panel is visible in a light tan color. │ │ - **Expression**: The cat is looking slightly upward and forward with an alert, perhaps curious, expression. │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
🆙 Scale up!
-
Happy with your preview data?
-
Use the
createmethod to submit larger Data Designer generation jobs.
[20:14:35] [INFO] OpenTelemetry metrics available at http://127.0.0.1:9464/metrics
[20:14:35] [INFO] 🎨 Creating Data Designer dataset
[20:14:35] [INFO] |-- 🔒 Jinja rendering engine: secure
[20:14:35] [INFO] ✅ Validation passed
[20:14:35] [INFO] ⛓️ Sorting column configs into a Directed Acyclic Graph
[20:14:35] [INFO] 🩺 Running health checks for models...
[20:14:35] [INFO] |-- 👀 Checking 'nvidia/nemotron-3-nano-omni-30b-a3b-reasoning' in provider named 'nvidia' for model alias 'nvidia-vision'...
[20:14:35] [INFO] |-- ✅ Passed!
[20:14:35] [INFO] ⚡ Using async task-queue builder
[20:14:35] [INFO] 📝 llm-text model config for column 'description'
[20:14:35] [INFO] |-- model: 'nvidia/nemotron-3-nano-omni-30b-a3b-reasoning'
[20:14:35] [INFO] |-- model alias: 'nvidia-vision'
[20:14:35] [INFO] |-- model provider: 'nvidia'
[20:14:35] [INFO] |-- inference parameters:
[20:14:35] [INFO] | |-- generation_type=chat-completion
[20:14:35] [INFO] | |-- max_parallel_requests=4
[20:14:35] [INFO] | |-- temperature=0.60
[20:14:35] [INFO] | |-- top_p=0.95
[20:14:35] [INFO] ⚡️ Async generation: 1 column(s) (column 'description'), 10 tasks across 1 row group(s)
[20:14:35] [INFO] 🚀 (1/1) Dispatching with 10 records
[20:14:35] [INFO] 🌱 (1/1) Sampling 10 records from seed dataset
[20:14:35] [INFO] |-- seed dataset size: 512 records
[20:14:35] [INFO] |-- sampling strategy: ordered
[20:14:41] [INFO] 📊 Progress [6.0s]:
[20:14:41] [INFO] |-- 🌑 column 'description': 1/10 (10%) 0.2 rec/s
[20:14:50] [INFO] 📊 Progress [14.3s]:
[20:14:50] [INFO] |-- 🌘 column 'description': 3/10 (30%) 0.2 rec/s
[20:15:01] [INFO] 📊 Progress [26.2s]:
[20:15:01] [INFO] |-- 🌗 column 'description': 5/10 (50%) 0.2 rec/s
[20:15:07] [INFO] 📊 Progress [31.5s]:
[20:15:07] [INFO] |-- 🌗 column 'description': 7/10 (70%) 0.2 rec/s
[20:15:21] [INFO] 📊 Progress [45.6s]:
[20:15:21] [INFO] |-- 🌖 column 'description': 9/10 (90%) 0.2 rec/s
[20:15:49] [INFO] 📊 Progress [73.6s]:
[20:15:49] [INFO] |-- 🌕 column 'description': 10/10 (100%) 0.1 rec/s
[20:15:49] [INFO] ✅ Async generation complete [73.6s]: 10 ok, 0 failed across 1 column(s)
[20:15:49] [INFO] 📊 Model usage summary:
[20:15:49] [INFO] |-- model: nvidia/nemotron-3-nano-omni-30b-a3b-reasoning
[20:15:49] [INFO] |-- tokens: input=3720, output=9756, reasoning=6577 (estimated), total=13476, tps=182
[20:15:49] [INFO] |-- reasoning token count estimated with tiktoken
[20:15:49] [INFO] |-- requests: success=10, failed=0, total=10, rpm=8
[20:15:49] [INFO] 📐 Measuring dataset column statistics:
[20:15:49] [INFO] |-- 📝 column: 'description'
| uuid | label | base64_image | description | |
|---|---|---|---|---|
| 0 | a3d8610e-41ad-4df8-845e-a431c9e702ed | 0 | iVBORw0KGgoAAAANSUhEUgAAAeQAAAIACAIAAADc8YinAA... | # Detailed Description **Main Subject:** The ... |
| 1 | fcf0dde5-75a8-4e82-92d4-7265179c8617 | 0 | iVBORw0KGgoAAAANSUhEUgAAAiQAAAIACAIAAAA9rOAHAA... | # Detailed Description ## Main Subject The pr... |
| 2 | 54ebe843-05e8-4fc7-87a1-3130b8d7f266 | 0 | iVBORw0KGgoAAAANSUhEUgAAAqoAAAIACAIAAADFYNm1AA... | ```markdown # Image Description **Main Subjec... |
| 3 | 9e9b7b60-9aa2-40a7-bd8d-5d493c505654 | 0 | iVBORw0KGgoAAAANSUhEUgAAAwAAAAIACAIAAAC6lJxtAA... | # Description of the Image ## Main Subject Th... |
| 4 | 2c61cc25-9662-4327-a7f2-221116a3c97c | 0 | iVBORw0KGgoAAAANSUhEUgAAAqoAAAIACAIAAADFYNm1AA... | # Image Description ## Main Subject The centr... |
──────────────────────────────────────── 🎨 Data Designer Dataset Profile ───────────────────────────────────────── Dataset Overview ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ number of records ┃ number of columns ┃ percent complete records ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ 10 │ 1 │ 100.0% │ └─────────────────────────────────┴─────────────────────────────────┴─────────────────────────────────────────────┘ 📝 LLM-Text Columns ┏━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ ┃ ┃ ┃ prompt tokens ┃ completion tokens ┃ ┃ column name ┃ data type ┃ number unique values ┃ per record ┃ per record ┃ ┡━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ description │ string │ 10 (100.0%) │ 29.0 +/- 0.0 │ 299.0 +/- 70.1 │ └──────────────────┴───────────────┴──────────────────────────────┴─────────────────────┴─────────────────────────┘ ╭────────────────────────────────────────────────── Table Notes ──────────────────────────────────────────────────╮ │ │ │ 1. All token statistics are based on a sample of max(1000, len(dataset)) records. │ │ 2. Tokens are calculated using tiktoken's cl100k_base tokenizer. │ │ │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
⏭️ Next Steps
Now that you've learned how to use visual context for image summarization in Data Designer, explore more:
-
Experiment with different vision models for specific image types
-
Try different prompt variations to generate specialized descriptions (e.g., technical details, key findings)
-
Combine image, audio, or video context with other column types after confirming your selected model supports those modalities
-
Apply this pattern to other vision tasks like image captioning, OCR validation, or visual question answering
-
Generating images with Data Designer