📦 Installation
Install PromptSuite from PyPI:
pip install promptsuite
Or install from source:
git clone https://github.com/eliyahabba/PromptSuite.git
cd PromptSuite
pip install -e .
🚀 Basic Usage
Generate prompt variations with just a few lines of code:
from promptsuite import PromptSuite
import pandas as pd
# Initialize
ps = PromptSuite()
# Load data
data = [{"question": "What is 2+2?", "answer": "4"}]
ps.load_dataframe(pd.DataFrame(data))
# Configure template
template = {
'instruction': 'Please answer the following questions.',
'prompt format': 'Q: {question}\nA: {answer}',
'instruction variations': ['paraphrase_with_llm'],
'prompt format variations': ['format structure'],
}
ps.set_template(template)
# Generate variations
ps.configure(variations_per_field=3, api_platform="OpenAI", model_name="gpt-4o-mini")
variations = ps.generate(verbose=True)
# Export results
ps.export("output.json", format="json")
🎯 Advanced 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': 'Text: {text}\nSentiment: {label}',
'text': ['typos and noise'],
}
ps = PromptSuite()
ps.load_dataframe(data)
ps.set_template(template)
ps.configure(variations_per_field=3, max_variations_per_row=2)
variations = ps.generate(verbose=True)
Multiple Choice 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': 'same_examples__synchronized_order_variations',
'split': 'train'
}
}
ps = PromptSuite()
ps.load_dataframe(qa_data)
ps.set_template(template)
ps.configure(variations_per_field=2)
variations = ps.generate(verbose=True)
💾 Export Formats
# JSON - Full data with metadata
ps.export("output.json", format="json")
# CSV - Flattened for spreadsheets
ps.export("output.csv", format="csv")
# TXT - Plain prompts only
ps.export("output.txt", format="txt")