stanfordnlp / dspy

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

Fix: 'LM' object has no attribute 'copy' #1621

Closed xiayouran closed 1 month ago

xiayouran commented 1 month ago

Bug info:

  File "/data/liyanpeng/pywork/dspy/dspy/teleprompt/bootstrap.py", line 84, in compile
    self._bootstrap()
  File "/data/liyanpeng/pywork/dspy/dspy/teleprompt/bootstrap.py", line 154, in _bootstrap
    success = self._bootstrap_one_example(example, round_idx)
  File "/data/liyanpeng/pywork/dspy/dspy/teleprompt/bootstrap.py", line 210, in _bootstrap_one_example
    raise e
  File "/data/liyanpeng/pywork/dspy/dspy/teleprompt/bootstrap.py", line 182, in _bootstrap_one_example
    lm = lm.copy(temperature=0.7 + 0.001 * round_idx) if round_idx > 0 else lm
AttributeError: 'LM' object has no attribute 'copy'

This problem occurs when parameter max_rounds is greater than 1, so I tried to fix it by adding a copy function to LM.