Skip to content
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

BootstrapFewShot with max_rounds > 1 fails #1612

Open
kpob opened this issue Oct 11, 2024 · 1 comment
Open

BootstrapFewShot with max_rounds > 1 fails #1612

kpob opened this issue Oct 11, 2024 · 1 comment

Comments

@kpob
Copy link

kpob commented Oct 11, 2024

I started my dspy journey with the 2.5.3 version. Following the quickstart example I created a llm instance

dspy.OpenAI(...)

However this approach seems to be deprecated, so now I use

dspy.LM(...)

I was using the BootstrapFewShot for a while. It worked until I increased to max_round param to 2, from the default 1.

The error is

  File "/home/kpob/workspace/python/dspy-test/lib/python3.10/site-packages/dspy/teleprompt/bootstrap.py", line 182, in _bootstrap_one_example
    lm = lm.copy(temperature=0.7 + 0.001 * round_idx) if round_idx > 0 else lm
AttributeError: 'LM' object has no attribute 'copy'

My issue is similar to #1391. Yet I do not implement my custom LM, but just passing a model as a teacher.

 def __init__(self, metric, lm: dspy.LM, program, program_name: str, metric_threshold=1.0):
        self.lm = lm
        self.metric = metric
        self.metric_threshold = metric_threshold
        self.program_name = program_name
        self.program = program

def __call__(self, trainset, record=True, experiment=""):
    optimizer = dspy.BootstrapFewShot(
            metric=self.metric, 
            metric_threshold=self.metric_threshold,
            max_labeled_demos=2,
            max_rounds=3,
            teacher_settings=dict(lm=self.lm)
    )
@okhat
Copy link
Collaborator

okhat commented Oct 11, 2024

Hey, thanks @kpob for the catch. This is a new bug and I'll fix it today if I can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants