stanfordnlp / dspy

DSPy: The framework for programming—not prompting—language models
https://dspy.ai
MIT License
19.37k stars 1.47k forks source link

[MIPRO_v2] error in bootstrapping few-shot examples raises TypeError #1580

Closed mikeedjones closed 1 month ago

mikeedjones commented 1 month ago

Any error raised whilst generating bootstrap examples is handled and sets demo_candidates = None

255            except Exception as e:
256                print(f"Error generating fewshot examples: {e}")
257                print("Running without fewshot examples.")
258                demo_candidates = None

which causes a type error with grounded_proposer.


    305 # Create an instruction for each predictor 
    306 for pred_i, predictor in enumerate(program.predictors()):
--> 307     for demo_set_i in range(len(demo_candidates[0])):
    308         if pred_i not in proposed_instructions:
    309             proposed_instructions[pred_i] = []

TypeError: 'NoneType' object is not subscriptable

Not sure if this should be fixed by either:

Or something else :)

okhat commented 1 month ago

@XenonMolecule Can you investigate?

XenonMolecule commented 1 month ago

@mikeedjones can you see if #1581 works for you? I tested on a few internal programs by simulating an exception during bootstrapping, but I would love to know if this fixes your real test case.