Files
wehub-resource-sync 0d3cb498a3
CI / Shell Format Check (push) Has been cancelled
CI / Check Ruby (3.4) (push) Has been cancelled
CI / CI Config (push) Has been cancelled
CI / Test on Node ${{ matrix.node }} and ${{ matrix.os }}${{ matrix.shard && format(' (shard {0}/3)', matrix.shard) || '' }} (push) Has been cancelled
CI / Build on Node ${{ matrix.node }} (push) Has been cancelled
CI / Style Check (push) Has been cancelled
CI / Generate Assets (push) Has been cancelled
CI / Check Python (3.14) (push) Has been cancelled
CI / Check Python (3.9) (push) Has been cancelled
CI / Build Docs (push) Has been cancelled
CI / Code Scan Action (push) Has been cancelled
CI / Site tests (push) Has been cancelled
CI / webui tests (push) Has been cancelled
CI / Run Integration Tests (push) Has been cancelled
CI / Run Smoke Tests (push) Has been cancelled
CI / Go Tests (push) Has been cancelled
CI / Share Test (push) Has been cancelled
CI / Redteam (Production API) (push) Has been cancelled
CI / Redteam (Staging API) (push) Has been cancelled
CI / GitHub Actions Lint (push) Has been cancelled
CI / Check Ruby (3.0) (push) Has been cancelled
release-please / release-please (push) Has been cancelled
release-please / build (push) Has been cancelled
release-please / publish-npm (push) Has been cancelled
release-please / publish-npm-backfill (push) Has been cancelled
release-please / docker (push) Has been cancelled
release-please / publish-code-scan-action (push) Has been cancelled
release-please / attest-code-scan-action (push) Has been cancelled
Deploy local.promptfoo.app / Deploy to Cloudflare Pages (push) Has been cancelled
Test and Publish Multi-arch Docker Image / test (push) Has been cancelled
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-amd64 platform:linux/amd64 runner:ubuntu-latest]) (push) Has been cancelled
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-arm64 platform:linux/arm64 runner:ubuntu-24.04-arm]) (push) Has been cancelled
Test and Publish Multi-arch Docker Image / merge-docker-digests (push) Has been cancelled
Test and Publish Multi-arch Docker Image / Attest Multi-arch Image (push) Has been cancelled
Validate Renovate Config / Validate Renovate Configuration (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:24:08 +08:00

5.8 KiB

sidebar_position, sidebar_label, title, description, keywords, pagination_prev, pagination_next
sidebar_position sidebar_label title description keywords pagination_prev pagination_next
21 Dataset generation Dataset Generation - Automated Test Data Creation Generate comprehensive test datasets automatically using promptfoo. Create diverse test cases, personas, and edge cases for thorough LLM evaluation.
dataset generation
automated testing
test data creation
LLM datasets
evaluation data
test automation
synthetic data
configuration/scenarios configuration/huggingface-datasets

Dataset generation

Your dataset is the heart of your LLM eval. To the extent possible, it should closely represent true inputs into your LLM app.

promptfoo can extend existing datasets and help make them more comprehensive and diverse using the promptfoo generate dataset command. This guide will walk you through the process of generating datasets using promptfoo.

Prepare your prompts

Before generating a dataset, you need to have your prompts ready, and optionally tests:

prompts:
  - 'Act as a travel guide for {{location}}'
  - 'I want you to act as a travel guide. I will write you my location and you will suggest a place to visit near my location. In some cases, I will also give you the type of places I will visit. You will also suggest me places of similar type that are close to my first location. My current location is {{location}}'

tests:
  - vars:
      location: 'San Francisco'
  - vars:
      location: 'Wyoming'
  - vars:
      location: 'Kyoto'
  - vars:
      location: 'Great Barrier Reef'

Alternatively, you can specify your prompts as CSV:

prompts: file://travel-guide-prompts.csv

where the CSV looks like:

prompt
"Act as a travel guide for {{location}}"
"I want you to act as a travel guide. I will write you my location and you will suggest a place to visit near my location. In some cases, I will also give you the type of places I will visit. You will also suggest me places of similar type that are close to my first location. My current location is {{location}}"

Run promptfoo generate dataset

Dataset generation uses your prompts and any existing test cases to generate new, unique test cases that can be used for evaluation.

Run the command in the same directory as your config:

promptfoo generate dataset

This will output the tests YAML to your terminal.

If you want to write the new dataset to a YAML:

promptfoo generate dataset -o tests.yaml

a CSV:

promptfoo generate dataset -o tests.csv

Or if you want to edit the existing config in-place:

promptfoo generate dataset -w

Loading from output files

When using the -o flag, you will need to include the generated dataset within the tests block of your configuration file.

For example:

prompts:
  - 'Act as a travel guide for {{location}}'
  - 'I want you to act as a travel guide. I will write you my location and you will suggest a place to visit near my location. In some cases, I will also give you the type of places I will visit. You will also suggest me places of similar type that are close to my first location. My current location is {{location}}'

tests:
  - file://tests.csv
  - vars:
      location: 'San Francisco'
  - vars:
      location: 'Wyoming'
  - vars:
      location: 'Kyoto'
  - vars:
      location: 'Great Barrier Reef'

Customize the generation process

You can customize the dataset generation process by providing additional options to the promptfoo generate dataset command. Below is a table of supported parameters:

Parameter Description
-c, --config Path to the configuration file.
-i, --instructions Specific instructions for the LLM to follow when generating test cases.
-o, --output [path] Path to output file. Supports CSV and YAML.
-w, --write Write the generated test cases directly to the configuration file.
--numPersonas Number of personas to generate for the dataset.
--numTestCasesPerPersona Number of test cases to generate per persona.
--provider Provider to use for the dataset generation. Eg: openai:chat:gpt-5

For example:

promptfoo generate dataset --config path_to_config.yaml --output path_to_output.yaml --instructions "Consider edge cases related to international travel"

Using a custom provider

The --provider flag specifies the LLM used to generate test cases. This is separate from the providers in your config file (which are the targets being tested).

By default, dataset generation uses OpenAI (OPENAI_API_KEY). To use a different provider, set the appropriate environment variables:

# Azure OpenAI
export AZURE_OPENAI_API_KEY=your-key
export AZURE_API_HOST=your-host.openai.azure.com
export AZURE_OPENAI_DEPLOYMENT_NAME=your-deployment

promptfoo generate dataset

Alternatively, use the --provider flag with any supported provider:

promptfoo generate dataset --provider openai:chat:gpt-5-mini

For more control, create a provider config file:

id: openai:responses:gpt-5.2
config:
  reasoning:
    effort: medium
  max_output_tokens: 4096
promptfoo generate dataset --provider file://synthesis-provider.yaml

You can also use a Python provider:

promptfoo generate dataset --provider file://synthesis-provider.py