Skip to main content
Synthetic datasets are a powerful way to test and refine your LLM applications, especially when real-world data is limited, sensitive, or hard to collect. By guiding the model to generate structured examples, you can quickly create datasets that cover common scenarios, complex multi-step cases, and edge cases like typos or out-of-scope queries. In this tutorial, you will learn different strategies for dataset generation and show how they can be used to run experiments and test evaluators. You will:
  • Generate synthetic benchmark datasets to test evaluator accuracy and coverage
  • Use few-shot examples to guide LLM generation for more consistent outputs
  • Create agent-specific datasets that cover happy paths, edge cases, and adversarial scenarios
  • Upload datasets to Phoenix and run experiments to validate your evaluators
This tutorial requires an OpenAI API key and a Phoenix Cloud account.

Notebook Walkthrough

We will go through key code snippets on this page. To follow the full tutorial, check out the notebook or video above.

Google Colab

colab.research.google.com

Strategy 1: Creating Synthetic Benchmark Datasets

Goal: Create a synthetic dataset that allows you to test the accuracy and coverage of your evaluator. Use Case: Feed the generated dataset into an LLM-as-a-Judge or other evaluator to ensure it correctly labels intent, identifies errors, and handles a variety of query types including edge cases and noisy inputs. Synthetic data is especially useful when you want to stress-test evaluators such as an LLM-as-a-Judge across a wide range of scenarios. By generating examples systematically, you can cover straightforward cases, tricky edge cases, ambiguous queries, and noisy inputs, ensuring your evaluator captures different angles of behavior.

Generate Customer Support Queries

Upload Dataset to Phoenix

Synthetic Dataset 1

Test LLM Judge Effectiveness

Now let’s test how well an LLM-as-a-Judge performs on our synthetic dataset:
Synthetic Dataset 2

Strategy 2: Using Few-Shot Examples for Dataset Generation

Goal: Guide the LLM to generate synthetic examples that reflect different types of queries and scenarios while maintaining consistent labeling and structure. Few-shot prompting allows you to guide an LLM by showing a handful of examples, which helps produce more consistent and realistic outputs. This approach is particularly useful for testing evaluators because it ensures the synthetic dataset reflects patterns, labels, and structures the evaluator is expected to handle.

Generate Examples with Few-Shot Prompting

Upload Few-Shot Dataset

Synthetic Dataset 3

Test LLM Judge Effectiveness

Synthetic Dataset 4

Strategy 3: Creating Synthetic Datasets for Agents

Goal: Build synthetic test data that captures a wide range of queries to evaluate an agent’s reliability and safety. Use Case: Test how an agent handles in-scope requests, refuses out-of-scope queries, and manages edge cases, adversarial inputs, and noisy data. When creating synthetic datasets for agents, first define the agent’s capabilities and boundaries (tools, in-scope vs. out-of-scope). Then organize queries into categories to ensure balanced coverage:
  1. Happy-path: simple, common requests
  2. Complex: multi-step or reasoning-heavy
  3. Adversarial / refusal: out-of-scope or unsafe
  4. Edge cases: ambiguous or incomplete inputs
  5. Noise: typos, slang, multilingual

Generate Agent Test Dataset

Upload Agent Dataset

Synthetic Dataset 5

Best Practices for Synthetic Dataset Generation

  • Set Clear Goals – Define scenarios, edge cases, and failure modes to test.
  • Structure Prompts – Use JSON schemas, validation rules, and explicit output formats.
  • Ensure Coverage – Mix positive/negative cases, edge conditions, and diverse inputs.
  • Validate Data – Check schema compliance, logical consistency, and realism.
  • Refine Iteratively – Test, find gaps, and improve prompts and datasets.