-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix checking final chunk in ReAct agent #11280
fix checking final chunk in ReAct agent #11280
Conversation
if not latest_content.startswith( | ||
"Thought" | ||
): # doesn't follow thought-action format | ||
return True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This checking logic seems weird to me. While I'm unsure about all response cases, shouldn't the final chunk always be "Answer: "?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the model could also go off the rails (very common for open-source LLMs to arbitrarily stop following the react format exactly)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got you! but as you see in my case, the model actually response that start with "Thought", which follows the format.
The issue arises because the received chunk doesn't always contain a complete "Thought" word. For example, in my case, the sequence is: ('Th', 'Thought', 'Thought: ', 'Thought: I',...). Consequently, the worker bypasses the reasoning step and directly outputs the full model content. Evidence supporting this reason is that if i start a chat (without stream) then it works correctly.
This change then fixed my issue:
if len(latest_content) > 7 and not latest_content.startswith("Thought"):
return True
Do you have other better idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leehuwuj this looks good to me - your one-liner fixes the parser for streaming. @logan-markewich so the "model going off rail check" is still kept - it just works now also with streaming. Can you merge that?
13a0a2d
to
906d17b
Compare
Description
This PR to fix a minor issue in ReActAgent.
The issue:
ReActAgent keeps include internal states ("Though: ", "Action: ", "Observation: ",...) in chat response.
Preproduce:
I create a ReActAgent with LLama2 model:
Response output:
Expected output:
Type of Change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Suggested Checklist:
make format; make lint
to appease the lint gods