Aggregate-Intellect / sherpa

https://sherpa-ai.readthedocs.io/
Other
165 stars 46 forks source link

Slack App: Repeated action #18

Closed 20001LastOrder closed 7 months ago

20001LastOrder commented 1 year ago

During my testing on the React loop, it seems that the bot can be stuck in a loop (e.g. calling the same action with the same argument until it reaches the maximum number of actions).

Suggestion: I think the duplicated action can be determined with a simple rule-based approach. Once we detect the duplicated action, we can either stop the loop or use something like Reflexion (Paper).

YujingYang666777 commented 1 year ago

assigned to Yujing

YujingYang666777 commented 1 year ago

Description: The LLM sometimes produces duplicated actions, including the same commands and queries. This is not helpful for it to find the resources. Here is one example action: TaskAction(name='UserInput', args={'query': 'Determining the next command to use.'})

Steps to Reproduce: ask a few questions and it may reproduce. This can only be seen from the backend.

Actual Results: in the backend, it should give different action

Expected Results: in the backend, it sometimes give the same command and query

Additional Information: N/A

Reproducibility: It can be reproducible sometimes

Possible Solutions: Before executing the command, we always check whether it is the same command as the previous one. If it is the same one, we return a prompt to tell it to change a command or query word

Related Issues: N/A

Steps Taken So Far: A simple rule-based approach, as described in the possible solution section, is implemented and committed.

Environment: N/A

YujingYang666777 commented 1 year ago

resolved in the pull request #69

amirfz commented 1 year ago

waiting for @johnnykfeng since he said he still sees repeated action

johnnykfeng commented 1 year ago

This was from last night's testing. I'm using code from August 16th commit: 5ad07e8041545737bfe6826cabe84cf3f8282901

image

amirfz commented 1 year ago

@YujingYang666777 @20001LastOrder was the issue solved after August 16? @johnnykfeng could you merge in from main and test again?

amirfz commented 1 year ago

this is still not resolved completely - @YujingYang666777 is exploring

oshoma commented 1 year ago

Do we have any sort of server-side cache in place already?

If we had a cache of { tool: toolName, query: queryText, t: timestamp } then we could avoid reissuing queries for recent items in the cache. And flush the cache after some reasonable amount of time. Redis is one nice way to do this sort of thing.

amirfz commented 1 year ago

this is the core of the idea we're exploring and @YujingYang666777 and @ChenKua are doing some experiments. but I think we need to take a step back and revisit our multi agent frameworks and come up with a more robust system for knowledge tracking within the agent ecosystem to have better foundations for problems like this going forward. I'm trying to put something together so that we can discuss it

oshoma commented 1 year ago

OK - something to look at sounds good. I tried to follow the discussion in today's mtg but didn't have enough context.

I can imagine that the query will sometimes be subtly different, but (from a human standpoint) the same idea being tried again. That wouldn't work with a simple cache. So you could cache a vectorization of the query instead. But I'm sure you've thought of that already.

@YujingYang666777 and @ChenKua, for the experiments, do you have a list of what you have tried so far, and results? And/or code we can look at?

YujingYang666777 commented 1 year ago

I haven't tried the cache. Previously, I added a class named Reflection, that checks if the current action is the same as the previous action and asks it to generate a new one. Currently, it still suffers from the duplicate action issue. Since we have two tools, search and context search, it sometimes turns from search to context search, and gets back again.

We can use the cache to save actions in all steps, but since we only have two tools to select from, I am not sure how much it can improve it. Now I am adding more information for the context search tool and checking some multi-agent systems to see if we can get some idea from that.