Skip to content

[Bug] Errors in Optimizer while it seems fully specified according to the docs. #8672

@MaximeRivest

Description

@MaximeRivest

What happened?

I tought, I specified all lm to used and still some missing.

Why is this not sufficient?

import dspy

lm = dspy.LM("groq/meta-llama/llama-4-scout-17b-16e-instruct")
teacherp = dprogram_optimized.deepcopy()
teacherp.set_lm(lm = dspy.LM("gemini/gemini-2.5-pro"))
dprogram_optimized.set_lm(lm = lm)
optimizer = dspy.MIPROv2(
    metric_dspy, 
    max_bootstrapped_demos = 3, 
    max_labeled_demos = 3, 
    prompt_model=dspy.LM("gemini/gemini-2.5-pro"), 
    task_model=lm,
    auto = "medium",
    num_threads=6)
dprogram_optimized_v2 = optimizer.compile(dprogram_optimized, trainset=trainset, requires_permission_to_run = False, teacher = teacherp)
==> STEP 1: BOOTSTRAP FEWSHOT EXAMPLES <==
2025/08/16 11:13:05 INFO dspy.teleprompt.mipro_optimizer_v2: These will be used as few-shot example candidates for our program and for creating instructions.

2025/08/16 11:13:05 INFO dspy.teleprompt.mipro_optimizer_v2: Bootstrapping N=12 sets of demonstrations...
Bootstrapping set 1/12
Bootstrapping set 2/12
Bootstrapping set 3/12
  0%|        | 0/3 [00:00<?, ?it/s]2025/08/16 11:13:06 
ERROR dspy.teleprompt.bootstrap: Failed to run or to evaluate example Example({'receipt_image': Image(url=data:image/jpeg;base64,<IMAGE_BASE_64_ENCODED(1357136)>), 'receipt_totals': ReceiptTotals(before_tax_total=20.99, after_tax_total=24.13)}) (input_keys={'receipt_image'}) with <function metric_dspy at 0x783f7400e5c0> due to No LM is loaded. Please configure the LM using `dspy.configure(lm=dspy.LM(...))`. e.g, `dspy.configure(lm=dspy.LM('openai/gpt-4o-mini'))`.

I have trust issues with dspy.configure(lm=..). I want to make sure I know which model is used when.

I'm not sure if it's a bug or a design decision?

Steps to reproduce

import dspy

lm = dspy.LM("groq/meta-llama/llama-4-scout-17b-16e-instruct")
teacherp = dprogram_optimized.deepcopy()
teacherp.set_lm(lm = dspy.LM("gemini/gemini-2.5-pro"))
dprogram_optimized.set_lm(lm = lm)
optimizer = dspy.MIPROv2(
    metric_dspy, 
    max_bootstrapped_demos = 3, 
    max_labeled_demos = 3, 
    prompt_model=dspy.LM("gemini/gemini-2.5-pro"), 
    task_model=lm,
    auto = "medium",
    num_threads=6)
dprogram_optimized_v2 = optimizer.compile(dprogram_optimized, trainset=trainset, requires_permission_to_run = False, teacher = teacherp)

DSPy version

3.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions