codelion commited on
Commit
ca68dca
·
verified ·
1 Parent(s): 653da52

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -64
app.py CHANGED
@@ -1002,27 +1002,13 @@ with gr.Blocks(title="OpenEvolve Prompt Optimizer", theme=gr.themes.Soft()) as d
1002
  gr.Markdown("""
1003
  # 🧬 OpenEvolve Prompt Optimizer
1004
 
1005
- Automatically evolve and optimize your prompts using evolutionary algorithms!
1006
-
1007
- This space uses [OpenEvolve](https://github.com/algorithmicsuperintelligence/openevolve) to iteratively improve prompts
1008
- by testing them on real datasets and evolving better versions.
1009
-
1010
- ## 🔑 Setup (Required)
1011
- **To use this space:**
1012
- 1. Click "⋮" (menu) → "Duplicate Space" to create your own copy
1013
- 2. In your duplicated space, go to Settings → Variables & Secrets
1014
- 3. Add your OpenRouter API key as `OPENAI_API_KEY`
1015
- 4. Get a free API key at [openrouter.ai](https://openrouter.ai/)
1016
-
1017
- ## How it works:
1018
- 1. Enter an initial prompt (use `{input}` as a placeholder for dataset inputs)
1019
- 2. Default dataset is **IMDB** (movie review sentiment classification) - great for showing prompt improvement!
1020
- 3. Specify the dataset split and field names (or use other datasets like `gsm8k`, `dair-ai/emotion`)
1021
- 4. Click "Optimize Prompt" - the system will validate everything first!
1022
- 5. Watch the evolution progress in real-time
1023
- 6. Compare initial vs. best prompt side-by-side (both evaluated on same 50 samples)!
1024
-
1025
- **Model**: Using `meta-llama/llama-3.2-3b-instruct` (reliable, very cheap at ~$0.04 per 1M tokens)
1026
  """)
1027
 
1028
  with gr.Row():
@@ -1086,49 +1072,6 @@ with gr.Blocks(title="OpenEvolve Prompt Optimizer", theme=gr.themes.Soft()) as d
1086
  with gr.Column():
1087
  final_results = gr.Markdown("### Best Prompt\nWill appear here after optimization...", visible=True)
1088
 
1089
- # Documentation section - in collapsible accordion
1090
- gr.Markdown("---")
1091
- with gr.Accordion("📚 Documentation & Examples", open=False):
1092
- gr.Markdown("""
1093
- ### Example Datasets & Fields:
1094
-
1095
- | Dataset | Split | Input Field | Target Field | Task | Size |
1096
- |---------|-------|-------------|--------------|------|------|
1097
- | **stanfordnlp/imdb** | test | text | label | Sentiment Analysis | 25,000 |
1098
- | dair-ai/emotion | test | text | label | Emotion Classification | 2,000 |
1099
- | gsm8k | train | question | answer | Grade School Math | 7,473 |
1100
- | fancyzhx/ag_news | test | text | label | News Classification | 7,600 |
1101
- | MathArena/aime_2025 | train | problem | answer | Hard Math (AIME) | 30 |
1102
-
1103
- ### About This Demo Space:
1104
-
1105
- **This is a demonstration space** showcasing OpenEvolve's prompt optimization capabilities.
1106
- The interface shows you how the system works, but **you'll need to set up your own instance to run optimizations**.
1107
-
1108
- ### How to Run This Yourself:
1109
-
1110
- 1. **Clone this Space**: Click "⋮" (three dots) at top-right → "Duplicate this Space"
1111
- 2. **Set Environment Variables** in your cloned Space's settings:
1112
- - `OPENAI_API_KEY`: Your OpenRouter API key (get free key at [openrouter.ai/keys](https://openrouter.ai/keys))
1113
- - `HF_TOKEN`: (Optional) HuggingFace token for private datasets
1114
- 3. **Configure Your Optimization**:
1115
- - Dataset: Use full name format (e.g., `stanfordnlp/imdb` or `openai/gsm8k`)
1116
- - Fields: Specify exact field names from the dataset schema
1117
- - Model: Choose from 5 curated free models (larger models = better results but slower/rate-limited)
1118
- 4. **Run & Monitor**:
1119
- - All inputs are validated before starting
1120
- - **Evaluation strategy**:
1121
- - Initial evaluation: 200 samples
1122
- - Final evaluation: Same 200 samples (fair comparison)
1123
- - Evolution: Each variant tested on same 200 samples (ensures optimization aligns with test set)
1124
- - Compare initial vs best prompt side-by-side with identical test sets
1125
-
1126
- ### About OpenEvolve:
1127
- OpenEvolve is an open-source evolutionary optimization framework. Learn more at:
1128
- - [GitHub Repository](https://github.com/algorithmicsuperintelligence/openevolve)
1129
- - [Documentation](https://github.com/algorithmicsuperintelligence/openevolve#readme)
1130
- """)
1131
-
1132
  # Wire up the optimize button with hardcoded model
1133
  def optimize_with_fixed_model(initial_prompt, dataset_name, dataset_split,
1134
  input_field, target_field, progress=gr.Progress()):
 
1002
  gr.Markdown("""
1003
  # 🧬 OpenEvolve Prompt Optimizer
1004
 
1005
+ Automatically optimize prompts using evolutionary algorithms. Evolves better prompts by testing on real datasets.
1006
+
1007
+ **Setup**: Duplicate this space, add your OpenRouter API key (`OPENAI_API_KEY`) in Settings → Secrets. Get free key at [openrouter.ai](https://openrouter.ai/)
1008
+
1009
+ **Usage**: Enter initial prompt with `{input}` placeholder → Click optimize → Compare results
1010
+
1011
+ **Model**: `meta-llama/llama-3.2-3b-instruct` (~$0.04 per 1M tokens)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1012
  """)
1013
 
1014
  with gr.Row():
 
1072
  with gr.Column():
1073
  final_results = gr.Markdown("### Best Prompt\nWill appear here after optimization...", visible=True)
1074
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1075
  # Wire up the optimize button with hardcoded model
1076
  def optimize_with_fixed_model(initial_prompt, dataset_name, dataset_split,
1077
  input_field, target_field, progress=gr.Progress()):