This example demonstrates using Kapso's evolve() function to iteratively improve a prompt for solving American Invitational Mathematics Examination (AIME) problems.
Before running this example, install the required dependencies:
# Create and activate conda environment (recommended)
conda create -n kapso python=3.10
conda activate kapso
# Install dependencies
pip install openai datasets
# Install Kapso from the project root
cd /path/to/kapso
pip install -e .You'll also need an OpenAI API key:
export OPENAI_API_KEY=your_key_hereThe baseline implementation (optimize.py) contains a prompt template for solving AIME math problems. The goal is to optimize this prompt to improve accuracy on a subset of AIME 2024 problems.
- Must produce answers in
\boxed{XXX}format (3-digit integer 000-999) - Must work with the specified OpenAI model
- Prompt modifications only (no changes to evaluation logic)
run_evolve.py- Main script that uses Kapso to optimize the promptinitial_repo/optimize.py- Baseline prompt template to be optimizedinitial_repo/evaluate.py- Evaluation script that measures accuracyinitial_repo/requirements.txt- Python dependencies
cd examples/prompt_engineering
python run_evolve.pyThis will:
- Initialize Kapso
- Run multiple iterations to find optimized prompts
- Output the best solution to
./prompt_optimized
To evaluate a specific implementation:
cd initial_repo
python evaluate.py- Accuracy: Higher is better (baseline ~0.10-0.20)
- Format Compliance: Answers must be in
\boxed{XXX}format
A good optimization should achieve 0.30-0.50 accuracy through improved prompting techniques.