Replies: 1 comment 2 replies
-
Posting in both discussions and this may be too late... but is there any thought to 1 project integrating LLMs into models and another building a custom Mesa LLM (available via the docs?) that addresses the Mesa 2 issue? Or maybe even an agent AI that integrates the chatbot with tests so at some interval it checks and improves its responses or users have the option to have it run tests when they want more detailed responses? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
As mentioned by @colinfrisch in Discussion #2773, Colin and I will be working under @wang-boyu and @jackiekazil, to build the Mesa-LLM extension during our GSoC tenure. Details of the project can be found here.
After submitting my GSoC proposal I updated it slightly to include some other ideas I had, here is the link to the extended proposal . Other than that, here is a short overview that covers the key points of my proposal.
Mesa LLM Proposal Overview
Using the Mesa LLM Extension to Build LLM-Based Models in Mesa
LLM-based models in Mesa can broadly be envisioned under two categories:
Where the agents converse with each other in natural language using LLMs
Example: Modeling the spread of misinformation.
Where the LLMs sever purely as reasoning engines and are used just to generate logic and carry out
the necessary tasks.
Example: Modeling the spread of a disease in a city.
There could, of course, be cases where we require a mix of these two categories, and that too can be accounted for under the proposed framework.
Proposed Architecture
(Special thanks to Colin for recommending I make this diagram:))
Key Highlights
(This is done primarily through the self.execute() method under LLMAgnet via tools that enable interaction between the agent and the environment. E.g. Tools that move the agent in the grid, or tools that change the value of the property layer of a cell that the agent is on.)
The Reasoning Engine
There are three possible ways to pre-code the framework for in-context learning:
The method of pre-coding will likely be determined through trial and error. Additionally, we could consider creating a Python registry to keep track of the different reasoning engines.
Tools
Like in the reasoning engine, I would propose to maintain a registry for tools as well. We could create some built-in tools such as:
For models that are dependent on the environment and get data from property layers, we could create a tool that converts the property layer into matrix form and passes it to the reasoning engine. (Refer to the proposal extension for more clarity)
For agents falling under the conversational model, we could provide tools that retrieve particular conversations (or all conversations) and pass them into the reasoning engine if it needs context before taking action. (For instance, in relation to the sales model I had mentioned in my proposal, the prompt could be as follows:
”Decide if you want to buy product A or product B”
For this, the agent might use this tool to go through all the conversations it had with the salespeople and then come to a decision.)
Conversation
For conversational models where LLM agents communicate in natural language:
In case we are working with conversational models, where the LLM agents will be communicating in natural language to each other, we must toggle the conversation attribute of the model to on. This will create a pandas data frame (or polars, but I don’t think that would be necessary).
Now each time, an agent wants to converse with another agent, they can do so using a method resembling the following line:
Here I am giving flexibility to the user in terms of the reasoning engine they want to use to generate the conversation. If they don’t mention anything, we will use the default engine (which is the engine mentioned in the self.reasoning_engine). This method will automatically log the conversation into the database and also, If A B C are engaging in a to and fro communication, it will add those dialogues into the prompt so that there is a proper flow in the conversation.(look into proposal extension for more details about this class method)
Implementing the Disaster Response Simulation
Problem statement: There are 10 fire fighters, all initially located in their headquarters. A fire of different intensities breaks out in their city. The property layer depicts the intensity of the fire. Observe how the agents might put out the fire in the best possible way. This is a matrix representation of the property layer.
0→ No danger 1→ Small fire
2→Huge Fire $→headquarters
[
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 1, 1, 0, 0, 0, 0, 0, 0],
[0, 1, 1, 1, 0, 0, $, 0, 2, 0],
[0, 1, 1, 1, 0, 0, 0, 0, 2, 2],
[0, 0, 0, 0, 0, 0, 0, 2, 2, 2],
[0, 0, 0, 0, 0, 0, 0, 2, 2, 2],
[0, 0, 0, 0, 0, 0, 0, 2, 2, 0],
[0, 0, 0, 0, 0, 0, 0, 2, 0, 0],
[0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
]
Step 1: Create an instance of the tool class that allows the agent to move around the grid
Step 2: Create another instance of the tool class that allows the agent to alter the property layer's value of the grid that they are on.
Step 3 : Create a class for firefighting agents derived from the LLMAgent class.
Step 4 : Set the default reasoning engine (let's say OpenAI's o4 mini) and use CoT
Step 5: Set an appropriate system prompt. (You are a fire fighter etc..)
Step 6: Link the above mentioned tools to the agent class
Step 7: Also link the inbuilt tool that allows the agent to look into the current status of the property layer.
Step 8: Create 10 instances of this class.
Step 9: At each step of the model execute the following prompt for all 10 agents using the execute() method. Prompt→ Locate the fire that needs the most attention and also look into factors such as distance and the availability of a safe path to the location of the fire. Then go to that location and put out the fire.
Step 10: Run the model for a couple of steps.
Beta Was this translation helpful? Give feedback.
All reactions