Skip to content

Commit 58fc6cb

Browse files
committed
feat: template inspiration program type
1 parent ade1165 commit 58fc6cb

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

openevolve/prompt/sampler.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -474,21 +474,20 @@ def _determine_program_type(
474474

475475
# Check metadata for explicit type markers
476476
if metadata.get("diverse", False):
477-
return "Diverse"
477+
return self.template_manager.get_fragment("inspiration_type_diverse")
478478
if metadata.get("migrant", False):
479-
return "Migrant"
479+
return self.template_manager.get_fragment("inspiration_type_migrant")
480480
if metadata.get("random", False):
481-
return "Random"
482-
481+
return self.template_manager.get_fragment("inspiration_type_random")
483482
# Classify based on score ranges
484483
if score >= 0.8:
485-
return "High-Performer"
484+
return self.template_manager.get_fragment("inspiration_type_score_high_performer")
486485
elif score >= 0.6:
487-
return "Alternative"
486+
return self.template_manager.get_fragment("inspiration_type_score_alternative")
488487
elif score >= 0.4:
489-
return "Experimental"
488+
return self.template_manager.get_fragment("inspiration_type_score_experimental")
490489
else:
491-
return "Exploratory"
490+
return self.template_manager.get_fragment("inspiration_type_score_exploratory")
492491

493492
def _extract_unique_features(self, program: Dict[str, Any]) -> str:
494493
"""

openevolve/prompts/defaults/fragments.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,12 @@
2222
"attempt_all_metrics_regressed": "Regression in all metrics",
2323
"attempt_mixed_metrics": "Mixed results",
2424
"top_program_metrics_prefix": "Performs well on",
25-
"diverse_program_metrics_prefix": "Alternative approach to"
25+
"diverse_program_metrics_prefix": "Alternative approach to",
26+
"inspiration_type_diverse": "Diverse",
27+
"inspiration_type_migrant": "Migrant",
28+
"inspiration_type_random": "Random",
29+
"inspiration_type_score_high_performer": "High-Performer",
30+
"inspiration_type_score_alternative": "Alternative",
31+
"inspiration_type_score_experimental": "Experimental",
32+
"inspiration_type_score_exploratory": "Exploratory"
2633
}

0 commit comments

Comments
 (0)