You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor and rename LLM prompt optimization example
Renamed the example directory from 'llm_prompt_optimazation' to 'llm_prompt_optimization' for correct spelling and consistency. Updated all example files, added HuggingFace dataset support, new configuration files, and improved documentation. The new example supports prompt evolution for any HuggingFace dataset with custom templates and cascading evaluation. Removed the old example files and replaced them with the new structure.
OpenEvolve supports advanced prompt template customization to increase diversity in code evolution:
305
+
306
+
#### Custom Templates with `template_dir`
307
+
308
+
You can override the default prompt templates by providing custom ones:
309
+
310
+
```yaml
311
+
prompt:
312
+
template_dir: "path/to/your/templates"
313
+
```
314
+
315
+
Create `.txt` files in your template directory with these names:
316
+
- `diff_user.txt`- Template for diff-based evolution
317
+
- `full_rewrite_user.txt`- Template for full code rewrites
318
+
- `evolution_history.txt`- Format for presenting evolution history
319
+
- `top_program.txt`- Format for top-performing programs
320
+
- `previous_attempt.txt`- Format for previous attempts
321
+
322
+
See these directories for complete examples of custom templates:
323
+
- `examples/lm_eval/prompts/`- Custom templates for evaluation tasks
324
+
- `examples/llm_prompt_optimization/templates/`- Templates for evolving prompts instead of code
325
+
326
+
#### Template Variations with Stochasticity
327
+
328
+
To add randomness to your prompts and prevent getting stuck in local optima:
329
+
330
+
1. **Enable stochasticity** in your config:
331
+
```yaml
332
+
prompt:
333
+
use_template_stochasticity: true
334
+
template_variations:
335
+
greeting:
336
+
- "Let's improve this code."
337
+
- "Time to enhance this program."
338
+
- "Here's how we can optimize:"
339
+
analysis_intro:
340
+
- "Current metrics show"
341
+
- "Performance analysis indicates"
342
+
- "The evaluation reveals"
343
+
```
344
+
345
+
2. **Use variation placeholders** in your custom templates:
346
+
```
347
+
# custom_template.txt
348
+
{greeting}
349
+
{analysis_intro} the following results:
350
+
{metrics}
351
+
```
352
+
353
+
The system will randomly select one variation for each placeholder during prompt generation, creating diverse prompts that can lead to more creative code evolutions.
354
+
355
+
**Note**: The default templates don't include variation placeholders, so you'll need to create custom templates to use this feature effectively.
356
+
297
357
### Feature Dimensions in MAP-Elites
298
358
299
359
Feature dimensions control how programs are organized in the MAP-Elites quality-diversity grid:
@@ -425,8 +485,12 @@ Demonstrates integration with [optillm](https://github.com/codelion/optillm) for
425
485
- **Mixture of Agents (MoA)**: Multi-response synthesis for improved accuracy
426
486
- **Local model optimization**: Enhanced reasoning with smaller models
0 commit comments