Skip to main content
Meta-Prompt uses a powerful teacher LLM to analyze how your prompt performs, understand why it fails on specific examples, formulate hypotheses about improvements, and completely rewrite the prompt. This approach is inspired by the promptim library and excels at tasks requiring deep reasoning.

When to Use Meta-Prompt

✅ Best For

  • Complex reasoning tasks
  • Tasks where understanding failures helps
  • Refining well-scoped prompts
  • Deep iterative improvement

❌ Not Ideal For

  • Quick experiments (slower)
  • Simple classification tasks
  • Very large datasets (costly)
  • Tasks with unclear failure patterns

How It Works

Meta-Prompt follows a systematic analysis-and-rewrite cycle:
1

Evaluate Current Prompt

Run the current prompt on a subset of your dataset and collect scores
2

Identify Failures

Focus on examples with low scores to understand what went wrong
3

Formulate Hypothesis

Teacher model analyzes failures and proposes a specific improvement theory
4

Rewrite Prompt

Generate a complete new prompt implementing the hypothesis
5

Repeat

Continue for multiple rounds, building on previous insights
Unlike optimizers that tweak parts of a prompt, Meta-Prompt rewrites the entire prompt each iteration based on deep analysis.

Basic Usage


Configuration Parameters

Core Parameters

LiteLLMGenerator
required
A powerful language model used for analyzing failures and generating improved prompts. Recommended: gpt-4o, gpt-4-turbo, or claude-3-opus.
str
default:"I want to improve my prompt."
Description of what you want the optimized prompt to achieve. More specific descriptions lead to better results.
int
default:"5"
Number of analysis-and-rewrite iterations. More rounds can lead to better results but cost more.
int
default:"40"
Number of examples to evaluate each round. Smaller = faster but less reliable signal.

The Meta-Prompt Process

What the Teacher Model Sees

In each round, the teacher model receives:
  1. Current Prompt - The prompt being evaluated
  2. Previous Failed Attempts - Prompts that performed worse (to avoid repeating mistakes)
  3. Performance Data - Detailed results showing which examples failed and why
  4. Task Description - Your goal for the optimization

What the Teacher Model Returns

The teacher provides two things:

Underlying Research

The Meta-Prompt optimizer is inspired by meta-learning and reflective AI systems, where a model improves its own processes.
  • Meta-Learning: The core idea is formalized in research like “System Prompt Optimization with Meta-Learning”, which uses bilevel optimization. Another related work is “metaTextGrad”, which optimizes both prompts and their surrounding structures.
  • Industry Tools: This reflective approach is used in tools like Google’s Vertex AI Prompt Optimizer and is a key feature in advanced models for self-improvement.
  • Frameworks: The concept is explored in libraries like promptim and is classified in surveys as a leading LLM-driven optimization method.

Advanced Examples

With Detailed Task Description


With More Rounds for Complex Tasks


Combining with Other Optimizers

Use Meta-Prompt for deep refinement after initial exploration:

Understanding the Results

Tracking Hypothesis Evolution

Meta-Prompt’s hypotheses show its reasoning process:

Analyzing Improvement Patterns


Performance Tips

Meta-Prompt’s quality depends heavily on the teacher model’s reasoning ability. Use gpt-4o, claude-3-opus, or similar high-end models.
Specific task descriptions help the teacher make targeted improvements. Include constraints, desired output format, and edge cases to handle.
5 rounds is usually enough for meaningful improvement. Increase to 7-10 only for very complex tasks where you see continued progress.
  • Too small (< 20): Unreliable signal, may optimize for noise
  • Too large (> 50): Slow and expensive
  • Sweet spot: 30-40 examples
Look at low-scoring examples in each round to understand what the optimizer is trying to fix:

Common Patterns

Complex Reasoning Tasks

Creative Writing with Constraints

Data Transformation Tasks


Troubleshooting

Problem: Improvement stops after 2-3 roundsSolution:
  • Your initial prompt might already be good - check if score is already high
  • Make task description more specific to guide further refinement
  • Try a different teacher model for fresh perspective
  • Increase eval_subset_size for more reliable signal
Problem: Each iteration adds more instructions, making prompts unwieldySolution:
  • Add to task description: “Keep the prompt concise and under 200 words”
  • Manually select a mid-optimization prompt that balances quality and length
  • Use fewer rounds (3-4 instead of 7-8)
Problem: Optimization is expensive with GPT-4Solution:
  • Reduce num_rounds to 3-5
  • Decrease eval_subset_size to 20-30
  • Use gpt-4o-mini as teacher for initial experiments
  • Run on a smaller dataset subset first to validate approach
Problem: Score goes up and down between roundsSolution:
  • Increase eval_subset_size for more stable measurements
  • Check if your evaluation metric is too noisy
  • Ensure dataset examples are high-quality and representative
  • Consider using a different evaluation metric

Comparison with Other Optimizers


Next Steps

Try ProTeGi

For more systematic error analysis

Compare All Optimizers

See which optimizer fits your needs