A tool that creates multi-prompt datasets from single-prompt datasets using templates
Project description
PromptSuite
A tool that creates multi-prompt datasets from single-prompt datasets using templates with variation specifications.
Overview
PromptSuite transforms your single-prompt datasets into rich multi-prompt datasets by applying various types of variations specified in your templates. It supports HuggingFace-compatible datasets and provides both a command-line interface and a modern web UI.
📚 Documentation
- 📖 Complete API Guide - Python API reference and examples
- 🏗️ Developer Documentation - For contributors and developers
Installation
From PyPI (Recommended)
pip install promptsuite
From GitHub (Latest)
pip install git+https://github.com/ehabba/PromptSuite.git
From Source
git clone https://github.com/ehabba/PromptSuite.git
cd PromptSuite
pip install -e .
Quick Start
Command Line Interface
promptsuite --template '{"instruction": "{instruction}: {text}", "text": ["paraphrase_with_llm"], "gold": "label"}' \
--data data.csv --max-variations-per-row 50
Streamlit Interface
Launch the modern Streamlit interface for an intuitive experience:
# If installed via pip
promptsuite-ui
# From project root (development)
python src/promptsuite/ui/main.py
# Alternative: using the runner script
python scripts/run_ui.py
The web UI provides:
- 📁 Step 1: Upload data or use sample datasets
- 🔧 Step 2: Build templates with smart suggestions
- ⚡ Step 3: Generate variations with real-time progress and export results
Python API
from promptsuite import PromptSuite
import pandas as pd
# Initialize
mp = PromptSuite()
# Load data
data = [{"question": "What is 2+2?", "answer": "4"}]
mp.load_dataframe(pd.DataFrame(data))
# Configure template
template = {
'instruction': 'Please answer the following questions.',
'prompt format': 'Q: {question}\nA: {answer}',
'question': ['typos and noise'],
}
mp.set_template(template)
# Generate variations
mp.configure(max_rows=2, variations_per_field=3)
variations = mp.generate(verbose=True)
# Export results
mp.export("output.json", format="json")
📚 Core Concepts
Templates
Templates control how prompts are structured and varied:
| Key | Description | Example |
|---|---|---|
instruction |
System prompt (optional) {placeholders} | 'You are a helpful assistant. Answer the following questions about {subject}.'' |
prompt format |
Main template with {placeholders} | 'Q: {question}\nA: {answer}' |
gold |
Correct answer field | 'answer' or {'field': 'answer', 'type': 'index'} |
few_shot |
Few-shot configuration | {'count': 2, 'format': 'shared_ordered_random_n', 'split': 'train'} |
Variation Types
| Type | Description | Requires API Key |
|---|---|---|
paraphrase_with_llm |
AI-powered rephrasing | ✅ |
context |
Adds background context | ✅ |
format_structure |
Changes separators, casing, field connectors | ❌ |
typos and noise |
Injects typos, capitalization changes, spacing, character swaps, and punctuation noise | ❌ |
shuffle |
Reorders list items | ❌ |
enumerate |
Adds numbering (1. 2. 3.) | ❌ |
This template demonstrates how to use all the main keys for maximum flexibility and clarity. You can import these keys from promptsuite.core.template_keys to avoid typos and ensure consistency.
Template Format
Templates use Python f-string syntax with custom variation annotations:
"{instruction:semantic}: {few_shot}\n Question: {question:paraphrase_with_llm}\n Options: {options:non-semantic}"
System Prompt
instruction: (optional) A general instruction that appears at the top of every prompt, before any few-shot or main question. You can use placeholders (e.g.,{subject}) that will be filled from the data for each row.prompt format: The per-example template, usually containing the main question and placeholders for fields.
Supported Variation Types
paraphrase_with_llm- Paraphrasing variations (LLM-based)format_structure- Semantic-preserving format changes (e.g., separators, casing, field connectors)typos and noise- Injects typos, capitalization changes, spacing, character swaps, and punctuation noisecontext- Context-based variationsshuffle- Shuffle options/elements (for multiple choice)enumerate- Enumerate list fields (e.g., 1. 2. 3. 4., A. B. C. D., roman numerals, etc.) You can combine these augmenters in your template for richer prompt variations.
Template Format
Templates use a dictionary format with specific keys for different components:
template = {
"instruction": "You are a helpful assistant. Please answer the following questions.",
"instruction variations": ["paraphrase_with_llm"],
"prompt format": "Q: {question}\nOptions: {options}\nA: {answer}",
"prompt format variations": ["format structure"],
"question": ["shuffle", "typos and noise"],
"options": ["enumerate"],
"gold": {
'field': 'answer',
'type': 'index',
'options_field': 'options'
},
"few_shot": {
'count': 2,
'format': 'shared_ordered_random_n',
'split': 'train'
}
}
API Reference
PromptSuite Class
class PromptSuite:
def __init__(self):
"""Initialize PromptSuite."""
def load_dataframe(self, df: pd.DataFrame) -> None:
"""Load data from pandas DataFrame."""
def load_csv(self, filepath: str, **kwargs) -> None:
"""Load data from CSV file."""
def load_dataset(self, dataset_name: str, split: str = "train", **kwargs) -> None:
"""Load data from HuggingFace datasets."""
def set_template(self, template_dict: Dict[str, Any]) -> None:
"""Set template configuration."""
def configure(self, **kwargs) -> None:
"""Configure generation parameters."""
def generate(self, verbose: bool = False) -> List[Dict[str, Any]]:
"""Generate prompt variations."""
def export(self, filepath: str, format: str = "json") -> None:
"""Export variations to file."""
Examples
Sentiment Analysis
import pandas as pd
from promptsuite import PromptSuite
data = pd.DataFrame({
'text': ['I love this movie!', 'This book is terrible.'],
'label': ['positive', 'negative']
})
template = {
'instruction': 'Classify the sentiment',
'instruction_variations': ['paraphrase_with_llm'],
'prompt format': f"Text: {text}\nSentiment: {label}",
'text': ['typos and noise'],
}
mp = PromptSuite()
mp.load_dataframe(data)
mp.set_template(template)
mp.configure(
variations_per_field=3,
max_variations_per_row=2,
random_seed=42,
api_platform="TogetherAI",
model_name="meta-llama/Llama-3.3-70B-Instruct-Turbo-Free"
)
variations = mp.generate(verbose=True)
Question Answering with Few-shot
template = {
'instruction': 'Answer the question:\nQuestion: {question}\nAnswer: {answer}',
'instruction_variations': ['paraphrase_with_llm'],
'question': ['semantic'],
'gold': 'answer',
'few_shot': {
'count': 2,
'format': 'shared_ordered_random_n',
'split': 'train'
}
}
mp = PromptSuite()
mp.load_dataframe(qa_data)
mp.set_template(template)
mp.configure(
variations_per_field=2,
api_platform="TogetherAI",
model_name="meta-llama/Llama-3.3-70B-Instruct-Turbo-Free"
)
variations = mp.generate(verbose=True)
Multiple Choice with Few-shot
import pandas as pd
from promptsuite import PromptSuite
data = pd.DataFrame({
'question': [
'What is the largest planet in our solar system?',
'Which chemical element has the symbol O?',
'What is the fastest land animal?',
'What is the smallest prime number?',
'Which continent is known as the "Dark Continent"?'
],
'options': [
'Earth, Jupiter, Mars, Venus',
'Oxygen, Gold, Silver, Iron',
'Lion, Cheetah, Horse, Leopard',
'1, 2, 3, 0',
'Asia, Africa, Europe, Australia'
],
'answer': [1, 0, 1, 1, 1],
'subject': ['Astronomy', 'Chemistry', 'Biology', 'Mathematics', 'Geography']
})
template = {
'prompt format': 'Question: {question}\nOptions: {options}\nAnswer:',
'prompt format variations': ['format structure'],
'options': ['shuffle', 'enumerate'],
'gold': {
'field': 'answer',
'type': 'index',
'options_field': 'options'
},
'few_shot': {
'count': 2,
'format': 'shared_ordered_random_n',
'split': 'train'
}
}
mp = PromptSuite()
mp.load_dataframe(data)
mp.set_template(template)
mp.configure(max_rows=5, variations_per_field=1)
variations = mp.generate(verbose=True)
for v in variations:
print(v['prompt'])
Example Output Format
A typical output from mp.generate() or the exported JSON file looks like this (for a multiple choice template):
[
{
"prompt": "Answer the following multiple choice question:\nQuestion: What is 2+2?\nOptions: 3, 4, 5, 6\nAnswer:",
"original_row_index": 1,
"variation_count": 1,
"template_config": {
"instruction": "Answer the following multiple choice question:\nQuestion: {question}\nOptions: {options}\nAnswer: {answer}",
"options": ["shuffle"],
"gold": {
"field": "answer",
"type": "index",
"options_field": "options"
},
"few_shot": {
"count": 1,
"format": "shared_ordered_random_n",
"split": "train"
}
},
"field_values": {
"options": "3, 4, 5, 6"
},
"gold_updates": {
"answer": "1"
},
"conversation": [
{
"role": "user",
"content": "Answer the following multiple choice question:\nQuestion: What is 2+2?\nOptions: 3, 4, 5, 6\nAnswer:"
},
{
"role": "assistant",
"content": "1"
},
{
"role": "user",
"content": "Answer the following multiple choice question:\nQuestion: What is the capital of France?\nOptions: London, Berlin, Paris, Madrid\nAnswer:"
}
]
}
]
📖 Detailed Guide
Data Loading
# CSV
mp.load_csv('data.csv')
# JSON
mp.load_json('data.json')
# HuggingFace
mp.load_dataset('squad', split='train[:100]')
# DataFrame
mp.load_dataframe(df)
Generation Options
mp.configure(
max_rows=10, # How many data rows to use
variations_per_field=3, # Variations per field (default: 3)
max_variations_per_row=50, # Cap on total variations per row
random_seed=42, # For reproducibility
api_platform="TogetherAI", # or "OpenAI"
model_name="meta-llama/Llama-3.3-70B-Instruct-Turbo-Free"
)
Export Formats
# JSON - Full data with metadata
mp.export("output.json", format="json")
# CSV - Flattened for spreadsheets
mp.export("output.csv", format="csv")
# TXT - Plain prompts only
mp.export("output.txt", format="txt")
Web UI Interface
PromptSuite 2.0 includes a modern, interactive web interface built with Streamlit.
The UI guides you through a simple 3-step workflow:
- Upload Data: Load your dataset (CSV/JSON) or use built-in samples. Preview and validate your data before continuing.
- Build Template: Create or select a prompt template, with smart suggestions based on your data. See a live preview of your template.
- Generate & Export: Configure generation settings, run the variation process, and export your results in various formats.
The Streamlit UI is the easiest way to explore, test, and generate prompt variations visually.
🔧 Advanced Features
Performance Optimization
PromptSuite automatically optimizes performance by pre-generating variations for shared fields:
- Instruction variations (
instruction variations) are generated once and reused across all data rows - Prompt format variations (
prompt format variations) are generated once and reused across all data rows
This optimization is especially important for LLM-based augmenters like paraphrase_with_llm that would otherwise run the same API calls repeatedly for identical text.
Gold Field Configuration
Simple format (for text answers):
'gold': 'answer' # Just the column name
Advanced format (for index-based answers):
'gold': {
'field': 'answer',
'type': 'index', # Answer is an index
'options_field': 'options' # Column with the options
}
Few-Shot Configuration
Few-shot examples can be configured with different sampling strategies:
| Format | Description | Use Case |
|---|---|---|
shared_ordered_first_n |
Always uses the first N examples from available data (deterministic, shared for all rows) | When you want consistent, predictable examples |
shared_ordered_random_n |
Always uses the same N random examples (with fixed seed, shared for all rows) | When you want random but consistent examples across all rows |
shared_unordered_random_n |
Always uses the same N random examples but shuffles their order for each row | When you want consistent examples but varied order to reduce position bias |
random_per_row |
Randomly samples different examples for each row (using row index as seed) | When you want variety and different examples per question |
Example:
"few_shot": {
"count": 2, # Number of examples to use
"format": "shared_ordered_random_n", # Sampling strategy
"split": "train" # Use only training data for examples
}
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
License
MIT License - see LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file promptsuite-3.0.0.tar.gz.
File metadata
- Download URL: promptsuite-3.0.0.tar.gz
- Upload date:
- Size: 184.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb2cc34abafe260b91ad152c28567c95da885d0b162a6f0ef2520461a20c2ef2
|
|
| MD5 |
203f53e858072dd03b903b8257eb3162
|
|
| BLAKE2b-256 |
9e68bf5f2bfa7c88e249e13297282f6af32de7d9cfc125327933e27a2ad1fda3
|
Provenance
The following attestation bundles were made for promptsuite-3.0.0.tar.gz:
Publisher:
publish.yml on eliyahabba/PromptSuite
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
promptsuite-3.0.0.tar.gz -
Subject digest:
eb2cc34abafe260b91ad152c28567c95da885d0b162a6f0ef2520461a20c2ef2 - Sigstore transparency entry: 258661552
- Sigstore integration time:
-
Permalink:
eliyahabba/PromptSuite@42adc395fd34f1d6b8f1c86f79a84f3079d86abf -
Branch / Tag:
refs/tags/v3.0.0 - Owner: https://github.com/eliyahabba
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@42adc395fd34f1d6b8f1c86f79a84f3079d86abf -
Trigger Event:
push
-
Statement type:
File details
Details for the file promptsuite-3.0.0-py3-none-any.whl.
File metadata
- Download URL: promptsuite-3.0.0-py3-none-any.whl
- Upload date:
- Size: 119.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
887c1b0cfb428006b8e60f88eef57051e8f2f7e76256be074f5e9780e475a69a
|
|
| MD5 |
ff0d7d2816bd65157e4ac94f8cdcecd7
|
|
| BLAKE2b-256 |
04ecfacd4faff8a3be26592fa58ec0afb74c34edfcfa0842239dd7c0165f12ae
|
Provenance
The following attestation bundles were made for promptsuite-3.0.0-py3-none-any.whl:
Publisher:
publish.yml on eliyahabba/PromptSuite
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
promptsuite-3.0.0-py3-none-any.whl -
Subject digest:
887c1b0cfb428006b8e60f88eef57051e8f2f7e76256be074f5e9780e475a69a - Sigstore transparency entry: 258661558
- Sigstore integration time:
-
Permalink:
eliyahabba/PromptSuite@42adc395fd34f1d6b8f1c86f79a84f3079d86abf -
Branch / Tag:
refs/tags/v3.0.0 - Owner: https://github.com/eliyahabba
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@42adc395fd34f1d6b8f1c86f79a84f3079d86abf -
Trigger Event:
push
-
Statement type: