Closed pranjal-joshi closed 6 days ago
UPDATE
LLM must be a dspy
wrapper, thus made following changes:
llm = dspy.AzureOpenAI(
api_base = os.getenv("azure_openai_endpoint"),
api_version = os.getenv("azure_openai_api_version"),
model = "gpt-35-turbo",
model_type = "text",
temperature = 0.7,
api_key = os.getenv("azure_openai_key"),
)
Now the compile logs are not showing errors, However, still the exception has been thrown.
Logs
100%|██████████| 3/3 [00:02<00:00, 1.30it/s]
Bootstrapped 0 full traces after 3 examples in round 0.
100%|██████████| 3/3 [00:00<00:00, 4.42it/s]
Bootstrapped 0 full traces after 3 examples in round 0.
Exception
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[13], [line 11](vscode-notebook-cell:?execution_count=13&line=11)
[2](vscode-notebook-cell:?execution_count=13&line=2) teleprompter = MIPRO(
[3](vscode-notebook-cell:?execution_count=13&line=3) prompt_model=llm,
[4](vscode-notebook-cell:?execution_count=13&line=4) task_model=llm,
[5](vscode-notebook-cell:?execution_count=13&line=5) metric=metric_function,
[6](vscode-notebook-cell:?execution_count=13&line=6) num_candidates=3
[7](vscode-notebook-cell:?execution_count=13&line=7) )
[9](vscode-notebook-cell:?execution_count=13&line=9) kwargs = dict(num_threads=1, display_progress=True, display_table=0)
---> [11](vscode-notebook-cell:?execution_count=13&line=11) MIPRO_compiled_RAG = teleprompter.compile(
[12](vscode-notebook-cell:?execution_count=13&line=12) RAG(),
[13](vscode-notebook-cell:?execution_count=13&line=13) trainset=dataset,
[14](vscode-notebook-cell:?execution_count=13&line=14) num_trials=3,
[15](vscode-notebook-cell:?execution_count=13&line=15) max_bootstrapped_demos=1,
[16](vscode-notebook-cell:?execution_count=13&line=16) max_labeled_demos=0,
[17](vscode-notebook-cell:?execution_count=13&line=17) eval_kwargs=kwargs,
[18](vscode-notebook-cell:?execution_count=13&line=18) requires_permission_to_run=False
[19](vscode-notebook-cell:?execution_count=13&line=19) )
File [c:\Users\Pranjal.Joshi\AppData\Local\anaconda3\envs\teams-bot\lib\site-packages\dspy\teleprompt\mipro_optimizer.py:368](file:///C:/Users/Pranjal.Joshi/AppData/Local/anaconda3/envs/teams-bot/lib/site-packages/dspy/teleprompt/mipro_optimizer.py:368), in MIPRO.compile(self, student, trainset, num_trials, max_bootstrapped_demos, max_labeled_demos, eval_kwargs, seed, view_data, view_examples, requires_permission_to_run)
[365](file:///C:/Users/Pranjal.Joshi/AppData/Local/anaconda3/envs/teams-bot/lib/site-packages/dspy/teleprompt/mipro_optimizer.py:365) demo_candidates[id(module_p)].append(candidate_p.demos)
[367](file:///C:/Users/Pranjal.Joshi/AppData/Local/anaconda3/envs/teams-bot/lib/site-packages/dspy/teleprompt/mipro_optimizer.py:367) # Generate N candidate prompts
--> [368](file:///C:/Users/Pranjal.Joshi/AppData/Local/anaconda3/envs/teams-bot/lib/site-packages/dspy/teleprompt/mipro_optimizer.py:368) instruction_candidates, _ = self._generate_first_N_candidates(module, self.num_candidates, view_data, view_examples, demo_candidates, trainset)
[370](file:///C:/Users/Pranjal.Joshi/AppData/Local/anaconda3/envs/teams-bot/lib/site-packages/dspy/teleprompt/mipro_optimizer.py:370) # Reset demo_candidates to None for our optimization if the user asked for no fewshot examples
...
--> [227](file:///C:/Users/Pranjal.Joshi/AppData/Local/anaconda3/envs/teams-bot/lib/site-packages/dspy/teleprompt/mipro_optimizer.py:227) raise ValueError("No examples found for the given predictor")
[228](file:///C:/Users/Pranjal.Joshi/AppData/Local/anaconda3/envs/teams-bot/lib/site-packages/dspy/teleprompt/mipro_optimizer.py:228) instruct = None
[229](file:///C:/Users/Pranjal.Joshi/AppData/Local/anaconda3/envs/teams-bot/lib/site-packages/dspy/teleprompt/mipro_optimizer.py:229) for i in range(1, self.num_candidates):
ValueError: No examples found for the given predictor
It seems like the error changes dynamically with code changes but failing exactly at the same line of the compile
method call!
Check the last few words of the error log
Failed to run or to evaluate example Example({'question': 'How to delete a study?', 'answer': 'Dummy answer', 'context': 'Dummy context'}) (input_keys={'question', 'context'}) with <function metric_function at 0x000001E03FA8A0D0> due to 'str' object has no attribute '_store'.
This other issue may be related: https://github.com/stanfordnlp/dspy/issues/865
You may consider adding the if statement suggested in that thread to fix your issue while the changes are tested and shipped out more widely!
@XenonMolecule Your suggestion is ambigous to me. Could you please explain it further?
MIPRO bootstraps example traces of your program running to show to an LLM to write better instructions. However, in your case it is logging Bootstrapped 0 full traces after 3 examples in round 0.
so the example bootstrapping is failing.
Right now MIPRO doesn't have a check for if that fails which causes the instruction proposal based on instructions to fail, so there is a suggested fix in the thread I linked above to add that if statement into mipro_optimizer.py
in order to check that there are examples before proposing instructions based on those examples. We will ship out a fix on our end soon once we test this more broadly!
MIPRO updated. Hopefully fixes this.
While trying to setup a MIPRO optimizer with ChromadbRM, I am facing the following issue:
Error Logs
Here is the section of code that I've written
Let me know what is missing in this.
Note: I've tested that ChromadbRM can get the similarity search results. So