Multi-agent active inference with PyMDP
This guide gives an overview of the the Designer-Artifact-User Python package. It also provides step-by-step instructions to install and set up the package on an Ubuntu 24.04 Linux system. For other operating systems, it should be easy to modify the appropriate commands.
The purpose of the dau-active-inference
package is to allow a user to run an active inference based simulation for three interacting agents: a Designer, an Artifact, and a User. The Designer is attempting to steer the Artifact, the Artifact is trying to steer the User, and the User is trying to steer the Artifact. The overall operation of the agents is based on the active inference principle and is represented in the following diagram:
After running a simulation, the outcome of the experiment can be visualized as follows, for example, in the case of the Designer/Artifact interaction:
There is much more information available inside the accompanying notebook Designer-Artifact-User.ipynb
:
https://github.com/LearnableLoopAI/Designer-Artifact-User/blob/main/Designer-Artifact-User.ipynb
There are also more active inference
related projects at:
The dau-active-inference
package primarily makes use of the pymdp
and inferactively-pymdp
packages for its operation. More information on these packages can be obtained from:
Here is a rough dependency structure:
- dau-active-inference
- numpy
- matplotlib
- pandas
- inferactively-pymdp
- pymdp
- torch
Please note that the installation will need about 6 GB of disk space. The installation process may take up to 15-20 minutes to complete if you do not have any of the dependencies installed.
Follow these steps in sequence:
- Install python tools and dependencies:
sudo apt update && sudo apt install -y python3-pip python3-virtualenv git
- Clone and change the directory to the Designer-Artifact-User directory:
git clone https://github.com/LearnableLoopAI/Designer-Artifact-User && cd Designer-Artifact-User
- Create python virtualenv (.venv) and activate it from inside the Designer-Artifact-User directory:
virtualenv .venv && source .venv/bin/activate
- Install the dau-active-inference package and its dependencies:
pip install --no-cache-dir dau-active-inference
- Run dau-active-inference package with --help flag to see switch options (currently there is only one option):
dau-active-inference --help
- To reach the PyPI repository, go to: https://pypi.org/project/dau-active-inference/
dau-active-inference --duration 20
The duration
argument specifies the number of time steps or iterations to perform. The default value of the duration argument is 20. For example, if you need a simulation run over 50 steps, provide:
dau-active-inference --duration 50
Currently, provision is only made for this single argument. In the future, the system might be expanded so that more arguments could be supplied.
If you are more technically-minded and understand the basic operation of the pymdp package, you are welcome to modify the dau_activate_inference.py
file and experiment locally.
If you are more technically-minded and understand the basic operation of the pymdp
package, you are welcome to execute/modify the Designer-Artifact-User.ipynb
notebook file. It is easy to do this using the VSCode
editor. Try these steps:
- Launch
VSCode
- Open the
Designer-Artifact-User
folder - When prompted at the bottom, confirm that you want to open the project in a
Dev Container
VSCode
will use the.devcontainer
folder in the project to spin up a container- Open the
Designer-Artifact-User.ipynb
notebook and start to experiment
Currently, only a single argument has been externalized: the duration
. It would make sense to externalize many of the other parameters too. Experimenters need not be limited by this. They can either modify the dau-active-inference.py
file, or, as just described, the dau-active-inference.ipynb
. Let us know if you have questions: