stanfordnlp / dspy

DSPy: The framework for programming—not prompting—foundation models
https://dspy-docs.vercel.app/
MIT License
13.95k stars 1.07k forks source link

How to optimize only a part of instruction? #1165

Open YunpengZhai opened 2 weeks ago

YunpengZhai commented 2 weeks ago

Hi,

How can I customize the prompt structure in DSPy and use teleprompter to optimize only a specific part of it? For example, my custom prompt is:

## Task
(this is the task description)

## Tips
(Tips: 1. xxxx; 2. xxxx)

How can I use an optimizer, such as copro, to optimize only the Tips section?

Thank you!

timothyvinzent commented 2 weeks ago

Im having a similar challenge when adding few shot examples. Specifically I have inputs to the model that are always identical and I would like to hide them from the examples that are provided to the LM during inference and training, since it costs a lot of tokens having unnecessary inputs be used during training (multiplied by number of examples showed). Would be nice to be able to specify which parameters should be "tuned".

okhat commented 1 week ago

@YunpengZhai consider passing the task description as a field, that way you control it, and the optimizer can't change it.