stanfordnlp / dspy

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

AttributeError: 'dict' object has no attribute '_store' #557

Open yasho191 opened 7 months ago

yasho191 commented 7 months ago

I was trying to replicate the flow of the multihop_finetune tutorial notebook for my use case where I want to finetune the T5 model on a custom dataset. While running the finetuning T-5 model code I am getting the following Error: AttributeError: 'dict' object has no attribute '_store'.

Sample Code:

config = dict(target='t5-large', epochs=2, bf16=True, bsize=6, accumsteps=2, lr=5e-5)

tp = BootstrapFinetune(metric=None)
t5_program = tp.compile(CustomRAG(), 
                        teacher=ensemble, 
                        trainset=trainset, **config)

# Deactivate chain of thought prompting. Let's use T5 to directly predict outputs. (Faster and similar quality.)
for p in t5_program.predictors(): p.activated = False

The log that I am getting before my program crashes is something like this: Failed to run or to evaluate example Example({'question': 'Sample Question', 'answer': 'Sample Answer)'}) (input_keys={'question'}) with <function BootstrapFinetune.__init__.<locals>.<lambda> at 0x7ad3520a4f70> due to 'dict' object has no attribute '_store'.

Can anyone help me out with this?

edwarddgao commented 7 months ago

I'm also having similar issue. Let me know if you find a fix.

staturecrane commented 6 months ago

I am getting this same error when trying to reload a saved module

cbrousseauAumni commented 3 months ago

I'm still getting this error with the most recent version of dspy. I'm only using Examples.

Code:

`config = {"target":"flan-t5-base", "epochs":2, "bf16":False, "bsize":6, "accumsteps":2, "lr":5e-5}

tp = BootstrapFinetune(metric=None)
t5_program = tp.compile(Text2Val(), teacher=ensemble, trainset=trainset, **config)

for p in t5_program.predictors(): p.activated = False
t5_program.save("./first_pass_ollama_t5.json")`