BayesAgent: Bayesian Agentic Reasoning Under Uncertainty via Verbalized Probabilistic Graphical Modeling
This repository contains the official implementation of the paper:
BayesAgent: Bayesian Agentic Reasoning Under Uncertainty via Verbalized Probabilistic Graphical Modeling
Hengguan Huang*, Xing Shen*, Guang-Yuan Hao, Songtao Wang, Lingfa Meng, Dianbo Liu, David Alejandro Duchene, Hao Wang, Samir Bhatt
*Equal contribution
AAAI Conference on Artificial Intelligence, 2026
Paper (arXiv preprint)
The technical appendix can be found at here.
In this work, we explore for the first time how to bridge LLM agents with probabilistic graphical models (PGMs) to address agentic reasoning under uncertainty. To this end, we introduce Verbalized Probabilistic Graphical Modeling (vPGM), a Bayesian agentic framework that (i) guides LLM agents in following key principles of PGMs through natural language and (ii) refines the resulting posterior distributions via numerical Bayesian inference. Unlike many traditional probabilistic methods requiring substantial domain expertise, vPGM bypasses expert‐driven model design, making it well‐suited for scenarios with limited assumptions.
It is recommended to use a virtual environment (e.g., venv) to avoid package conflicts. Here we assume you are using venv as your virtual environment. If you are using conda, please adjust the commands accordingly.
git clone https://github.com/xingbpshen/agentic-reasoning-vpgm.git
cd agentic-reasoning-vpgm/
pip install -r requirements.txtThe downloaded dataset should be structured in the following format, the datasets/ directory should be placed at the root of the repository:
datasets/
└── my_scienceqa/
├── val_1005.json
├── test_2563.json
└── DATASET_LICENSE
This dataset is a subset, and a processed (all tools' responses are included) version of the original ScienceQA dataset. For convenience, we provide a Google Drive link to download the processed dataset used in our experiments, note that the dataset is under CC BY-NC-SA 4.0 license.
We recommend to download the open-source LLMs using huggingface-cli 🤗 (make sure you obtained relevant permissions/agreement to download the models from Hugging Face):
huggingface-cli login
huggingface-cli download {REPO_NAME} --local-dir {SAVE_FOLDER} --local-dir-use-symlinks FalseFor example, the {REPO_NAME} can be meta-llama/Meta-Llama-3-8B-Instruct and {SAVE_FOLDER} can be /usr/local/data/Meta-Llama-3-8B-Instruct. The downloaded model will be saved in the specified folder {SAVE_FOLDER}.
Please modify the following arguments in auto_run.sh before running the script:
--llm_name: the name of the LLM used, e.g.,Meta-Llama-3-8B-Instruct.--model_path: the path to the downloaded LLM.--xdg_cache_home: the path to the cache directory.
Please run the following command to run inference:
bash auto_run.shThe inference results file will be saved in the specified path results/ under the project root.
S.B. acknowledges funding from the MRC Centre for Global Infectious Disease Analysis (reference MR/X020258/1), funded by the UK Medical Research Council (MRC). This UK funded award is carried out in the frame of the Global Health EDCTP3 Joint Undertaking. S.B. is funded by the National Institute for Health and Care Research (NIHR) Health Protection Research Unit in Modelling and Health Economics, a partnership between UK Health Security Agency, Imperial College London and LSHTM (grant code NIHR200908). H.W. is partially supported by Amazon Faculty Research Award, Microsoft AI & Society Fellowship, NSF CAREER Award IIS-2340125, NIH grant R01CA297832, and NSF grant IIS-2127918. We acknowledge support from OpenAI’s Researcher Access Program. Disclaimer: "The views expressed are those of the author(s) and not necessarily those of the NIHR, UK Health Security Agency or the Department of Health and Social Care." S.B. acknowledges support from the Novo Nordisk Foundation via The Novo Nordisk Young Investigator Award (NNF20OC0059309). S.B. acknowledges the Danish National Research Foundation (DNRF160) through the chair grant. S.B. acknowledges support from The Eric and Wendy Schmidt Fund For Strategic Innovation via the Schmidt Polymath Award (G-22-63345) which also supports H.H. and L.M.
Please raise a GitHub issue or email us at xing.shen@mail.mcgill.ca (with the email subject starting with "[vPGM]") if you have any question or encounter any issue.
