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.
🧩 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.
🔁 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.
🔎 Visual Inspection
Let's compare the original image with the generated description to validate quality:
🆙 Scale up!
-
Happy with your preview data?
-
Use the
createmethod to submit larger Data Designer generation jobs.
⏭️ 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