Closed milosgajdos closed 5 months ago
Hi @milosgajdos , at the moment the ReAct module is configured to only halt at the stopping condition Finish[answer]
.
It seems like the model is hallucinating a bit from the output \n\nAction 1: Search[query="other devices that can control Apple Remote"]\n\nObservation 1',
in Thought_2 which can lead to the corresponding steps to break as well.
I suspect this is due to some incompatibilities with DSPy and chat models (which is currently in-progress to fix), and not due to the ReAct setup itself, but you can add on another tool to check if the Action has reached Answer
as well and modify that stopping condition for now.
lmk if this helps or if you have any other suggestions! (ReAct is fairly experimental right now so we'd love any PRs to resolve issues like these!)
Ah, my GH notifications got outta control. Thanks for the response!!
Interesting...I'm wondering, would the instruction optimiser be able to stir the model in the right direction? Or some DSPy assertion suggestion? Sorry about the dumb questions, I'm still very new to this framework
Assertions (to validate outputs by checking for key words and/or maintaining correct formatting), few shot optimizers (bootstrapping unlabeled data to create agentic examples to learn from), instruction optimizers (better agent-based instructions), etc. are all great ways to improve agentic behavior!
I've grabbed the sample code in the docs for ReAct and tried running it.
I discovered 2 things:
ReAct
agent need a retrieve module client which isn't documented, in case one of the intermediate actions isSearch
; I made do withdspy.ColBERTv2
max_iters
is set to5
by default, but sometimes the agent seems to reach an answer before the max iters is which leads to action splitting code to throw an error https://github.com/stanfordnlp/dspy/blob/74ca4ca470c11414cafad915e2e42f47843a39e4/dspy/predict/react.py#L88Here's the code:
Here's the snippet of agent prompting history:
As you can see the
Action
has reached anAnswer
but the code continues to split the output completely ignoring it. Suggestion: check if the answer has been returned by the agent beforemax_iters
has been reached.