dspy
dspy copied to clipboard
Easier api for transforming modules with assertions
Now, it is possible to write assert_transform_module(module)
to transform a module to handle suggestions and assertions. The default behavior is implemented by the backtrack_handler
, which automatically backtracks for failing assertions and suggestions.
That’s so cool! Can we also shorten that function’s name?
Or even make it a module method?
program.activate_assertions()
Great advice! Now we can do:
a = Program()
a.activate_assertions()
# now a can backtrack and self-refine
or
teleprompter.compile(student=Program().activate_assertions())
Amazing! Before I merge,
will this break existing code?
is it an in-place or new-value method? either one is fine just checking
Yes. And it shouldn't break any existing code! Could you double check both the old and new api works @arnavsinghvi11?
Arnav’s answer implies it is NOT in place, just to be sure right?
Thanks! Pushed a fix. Both should work now
Looks good @Shangyint ! Just a small issue which relies on this change to be merged for activate_assertions()
to work.