stanfordnlp / dspy

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

Unable to save model from the DSPY Example #1140

Open sartyagi91 opened 3 months ago

sartyagi91 commented 3 months ago

Hey I encountered an error when I was compiling one of the examples from the dspy library, I got an error like this "TypeError: {'Talk About a Stranger', 'Nancy Reagan'} is not JSON serializable"

link to the colab example: https://colab.research.google.com/github/stanfordnlp/dspy/blob/main/examples/longformqa/longformqa_assertions.ipynb#scrollTo=r0t33A00YzVV

tom-doerr commented 3 months ago

Did you run it with default settings? It's weird that there's a quotation mark missing after "Stranger".

sartyagi91 commented 3 months ago

Yes, I ran with default settings, But when I was saving the model using

cited_longformqa.save("FILE_NAME.json")

I encountered the error I showed above.

tom-doerr commented 3 months ago

Related: https://github.com/stanfordnlp/dspy/issues/1011 https://github.com/stanfordnlp/dspy/issues/758

sartyagi91 commented 3 months ago

Did you run it with default settings? It's weird that there's a quotation mark missing after "Stranger".

The quotation mark was there, I did not paste it correctly. abc

fivejjs commented 3 months ago

Did you run it with default settings? It's weird that there's a quotation mark missing after "Stranger".

The quotation mark was there, I did not paste it correctly. abc

It looks like the proper json object: {"some key": "values"}. But yours looks like Python set.

okhat commented 3 months ago

The examples contain sets. They should tuples or lists. That will fix it.

We can make this change in the HotPotQA class.