You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
>>> predict.save("test_lm_saving.json", save_program=False)
Traceback (most recent call last):
File "/Users/chen.qian/Documents/mlflow_team/dspy/dspy/primitives/module.py", line 218, in save
f.write(ujson.dumps(state, indent=2))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: <dspy.clients.lm.LM object at 0x10563c2c0> is not JSON serializable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/chen.qian/Documents/mlflow_team/dspy/dspy/primitives/module.py", line 220, in save
raise RuntimeError(
RuntimeError: Failed to save state to test_lm_saving.json with error: <dspy.clients.lm.LM object at 0x10563c2c0> is not JSON serializable. Your DSPy program may contain non json-serializable objects, please consider saving the state in .pkl by using `path` ending with `.pkl`, or saving the whole program by setting `save_program=True`.
DSPy version
2.6.6
The text was updated successfully, but these errors were encountered:
What happened?
save() is broken when predict has lm assigned. See code below for reproducing.
To fix it, we can serialize the model name, then at loading time, reconstruct the lm instance by calling
dspy.LM(saved_model_name)
Steps to reproduce
Raises error:
DSPy version
2.6.6
The text was updated successfully, but these errors were encountered: