-
Notifications
You must be signed in to change notification settings - Fork 28
Description
Hello, thanks to your wonderful work PromptBreeder in prompt-optimization area.
When I ran the code, I felt confused about the _evaluate_fitness function. After carefully reviewing the code, I found that the following part has issues.
Lines 129 to 135 in 637ea25
| if unit.fitness > elite_fitness: | |
| # I am copying this bc I don't know how it might get manipulated by future mutations. | |
| unit = population.units[unit_index] | |
| current_elite = unit.model_copy() | |
| elite_fitness = unit.fitness |
I found others' questions about this part in the issue and submitted a PR. #1
However, I noticed that the change is incorrect, since unit, being a local variable, is referenced before declaration. It first appears in the for loop on line 102.
Line 102 in 637ea25
| for unit in population.units: |
To obtain the best elites, all instances of unit should be replaced with population.units[unit_index].
Here is my code:
if population.units[unit_index].fitness > elite_fitness:
current_elite = population.units[unit_index].model_copy()
elite_fitness = population.units[unit_index].fitnessI believe my changes may address the issue correctly and follow the original paper’s design. If you agree, I’d be happy to submit a PR. Your feedback is greatly appreciated.