Skip to content

[Feature] Declared Learnable Parameters #8593

@papaymaguire

Description

@papaymaguire

What feature would you like to see?

This issue will serve as a place to gather ideas and use cases surrounding the proposal of introducing explicitly declared learnable parameters of a DSPy program.

Central idea

The idea here is to give the optimizers a set of declared, tune-able knobs in order to optimize a DSPy program. A clear example would be tooling outputs for ReAct agents, strings that present information returned by a tool are an important part of adding context to an agent and present an important part of the program that should be optimized.

Ideally, users should be able to provide a string, or string template that is used to introduce context to the LLM. Perhaps marking them as DSPy.Parameter, with an input signature, and a seed string. For example, returning the results of a weather tool may look something like this:

class WeatherDisplaySignature(dspy.Signature):
    temperature: float
    sky: str


def get_weather(location: str):
    # run some function to get the weather
    # ...
    return dspy.Parameter(
        WeatherDisplaySignature,
        seed=lambda sig: f"Temp: {sig.temperature}. Sky: {sig.sky}",
    )

When using the get_weather tool in a ReAct agent, the optimizer would now see the return value of the tool as a tune-able prompt knob. How we present this information to the LLM could very well change how well it uses it.

Features

In my vision for something like this, all parameters used in the calculation of a forward method are displayed to an optimizer. Optimizers would see the information that they can use in the form of a signature, but could restrict the output type to a string. Before optimization, the program uses the seed template to collect traces. Once optimized, and loading a program from saved, the parameter would use the saved value instead of the seed value. This could potentially load different parameters for different programs, even if they use the same underlying tool.

Use cases

This is intended to be a community wide discussion, and further ideas/use cases can be mentioned in the comments.

Would you like to contribute?

  • Yes, I'd like to help implement this.
  • No, I just want to request it.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions