zou-group / textgrad

TextGrad: Automatic ''Differentiation'' via Text -- using large language models to backpropagate textual gradients.
http://textgrad.com/
MIT License
1.25k stars 91 forks source link

Guidance on describing a text loss? #45

Closed kgourgou closed 2 weeks ago

kgourgou commented 2 weeks ago

Hi all,

I've been using textgrad in experiments and it is fun to see how it updates prompts, etc., but I have a practical problem. While I'm doing my best to describe what I want in the text loss, I see drift in the objective.

Specifically, I'm trying to optimize a large system prompt over three examples. The objective is for the final answer by the llm to finish with a particular formatting, e.g.,

code: <some-code-here>

However, I see that the LLM provides feedback on other aspects of the answer as well, causing a bit of drift and growing the system_prompt.

If you have any general suggestions on how to describe a text loss, I think that would be useful to the community. Thanks!

mertyg commented 2 weeks ago

We should absolutely add more guidance about how to do this in our tutorials! Thank you for this question @kgourgou . Here are a couple things I would try:

In general, there are a bunch of places to modulate the behavior of optimizers, which is a blessing as it is expressive, but curse because grows the search space. I'd recommend starting with these -- and we'll make sure to add more tutorials on this!

Thanks again @kgourgou -- great to have you in the community.

kgourgou commented 2 weeks ago

Very interesting! Thanks for sharing all the tips.