-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[Feature] GEPA: Add custom component selection logic support #8765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[Feature] GEPA: Add custom component selection logic support #8765
Conversation
Released gepa==0.0.9 |
@LakshyAAAgrawal ready to go 🚀 |
@andressrg , thank you so much! The combination of this and instruction proposer is going to be super-powerful! Could you also take a look at #8767 ? I think at the moment, it will be difficult for anybody to be able to use it fully though. I believe now that this is implemented, it should also be trivial to fix #8674. It will basically require a component selector that returns all the predictor names all the time. |
These are independent issues, but at least documentation I think should be part of this PR. Would you be able to create just one example of using custom-instruction proposer, and one example of custom module selector? |
Released gepa==0.0.10. Please update accordingly. |
for sure!
makes sense! let me do the docs one and come back to you on this one |
Can you add the implementation of an "all" component selector, that selects all components to be modified. |
Sure. but here? or the gepa core lib? thinking it might be better in the gepa one |
Sure! |
Hi @andressrg , is this ready to merge? The documentation can come in a separate PR. |
It's missing this:
But I've just submitted gepa-ai/gepa#67 🚀 |
Let's finalize this! Released gepa==v0.0.11 |
6f3c034
to
e238664
Compare
Looks like we need much tighter tests in GEPA |
@andressrg I have yanked v0.0.11. Would you be able to fix this issue? |
0eb2b46
to
ebea94c
Compare
Isn't this an error in gepa repo? |
no. Issue was that the component selector that I had in the new test in this repo was not using the __call__ |
I think gepa core is correct 👍 |
pushed all the updates for dspy that should properly use component_selector |
Can you update to gepa==0.0.12 |
sure |
sorry for the scare there 😅 |
tests/teleprompt/test_gepa.py
Outdated
metric=component_selection_metric, | ||
reflection_lm=reflection_lm, | ||
max_metric_calls=4, | ||
component_selector="all" # String-based selector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add some unit test to ensure that the next proposed candidate actually updated all components?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure. on it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done 👍
This may be a lot of work, but would it be possible to create a unit test similar to https://github.com/stanfordnlp/dspy/blob/main/tests/teleprompt/test_gepa.py#L46-L53 that uses a custom instruction proposer + a custom module selector? The DictDummyLLM was created by actually running it against a real LLM and saving it. |
Enhanced test coverage to verify that the 'all' component selector actually updates all components simultaneously, while 'round_robin' updates only one component per iteration. The test directly compares the behavior of both selectors by examining the first candidate generated, confirming that 'all' updates both classifier and generator instructions while 'round_robin' updates only one.
noted. Will do 👍 not sure I'll have it today tho. But will keep you posted |
Summary
This PR implements custom component selection logic for GEPA as requested in issue #8755. It allows users to provide custom strategies for selecting which components (predictors) to optimize at each iteration, enabling more flexible optimization patterns.
Key Features
component_selector
parameter accepts any object implementing theReflectionComponentSelector
protocolRoundRobinReflectionComponentSelector
when no custom selector providedUsage Examples
Basic Custom Selector
Implementation Details
DSPy Changes
dspy/teleprompt/gepa/gepa.py
: Addedcomponent_selector
parameter and integration with gepa enginetests/teleprompt/test_gepa.py
: Tests for custom component selectionCore GEPA Library Changes Required
This PR requires corresponding changes to the
gepa-ai/gepa
repository to add themodule_selector
parameter to theoptimize()
function. Related PR: gepa-ai/gepa#52Testing
Closes