DSPy: The framework for programming—not prompting—language models
Python
Remove inspect_history from COPRO (#8033)
TomuHirata4b52b59dad46
diff --git a/docs/docs/faqs.md b/docs/docs/faqs.mdindex 67fa212b5..03c47effd 100644--- a/docs/docs/faqs.md+++ b/docs/docs/faqs.md@@ -115,3 +115,18 @@ Modules can be frozen by setting their `._compiled` attribute to be True, indicaIf you're dealing with "context too long" errors in DSPy, you're likely using DSPy optimizers to include demonstrations within your prompt, and this is exceeding your current context window. Try reducing these parameters (e.g. `max_bootstrapped_demos` and `max_labeled_demos`). Additionally, you can also reduce the number of retrieved passages/docs/embeddings to ensure your prompt is fitting within your model context length.A more general fix is simply increasing the number of `max_tokens` specified to the LM request (e.g. `lm = dspy.OpenAI(model = ..., max_tokens = ...`).++## Set Verbose Level+DSPy utilizes the [logging library](https://docs.python.org/3/library/logging.html) to print logs. If you want to debug your DSPy code, set the logging level to DEBUG with the example code below.++```python+import logging+logging.getLogger("dspy").setLevel(logging.DEBUG)+```++Alternatively, if you want to reduce the amount of logs, set the logging level to WARNING or ERROR.++```python+import logging+logging.getLogger("dspy").setLevel(logging.WARNING)+```\ No newline at end of filediff --git a/dspy/teleprompt/copro_optimizer.py b/dspy/teleprompt/copro_optimizer.pyindex feeecf9e3..6a3760d8d 100644--- a/dspy/teleprompt/copro_optimizer.py+++ b/dspy/teleprompt/copro_optimizer.py@@ -319,10 +319,6 @@ class COPRO(Teleprompter):temperature=self.init_temperature,)(attempted_instructions=attempts)- if self.prompt_model:- logger.debug(- f"(self.prompt_model.inspect_history(n=1)) {self.prompt_model.inspect_history(n=1)}"- )# Get candidates for each predictornew_candidates[id(p_base)] = instr.completionsall_candidates[id(p_base)].proposed_instruction.extend(instr.completions.proposed_instruction)@@ -330,8 +326,6 @@ class COPRO(Teleprompter):instr.completions.proposed_prefix_for_output_field,)- if self.prompt_model:- logger.debug(f"{self.prompt_model.inspect_history(n=1)}")latest_candidates = new_candidatescandidates = []