Skip to main content

Concordia

A library for generative social simulation

Concordia Tech Report | Concordia Design Pattern | Code Cheat Sheet

About

Concordia is a library for constructing and running generative agent-based models that simulate interactions among entities in grounded physical, social, or digital environments. It uses an interaction pattern inspired by tabletop role-playing games: a special entity called the Game Master (GM) simulates the environment in which player entities interact. Entities describe their intended actions in natural language, and the GM translates these into appropriate outcomes e.g. checking physical plausibility in simulated worlds.

Concordia supports a broad range of applications, including social science research, AI safety and ethics, cognitive neuroscience, economics, synthetic data generation for personalization, and performance evaluation of real services through simulated usage.

Concordia requires access to a standard LLM API and may optionally integrate with external applications and services.

How it Works

Concordia operates as a game engine for generative agents, built around three core concepts:

  • Entities: The actors in the simulation—either player characters (Agents) or system controllers (Game Masters).
  • Components: Modular building blocks of an Entity. Entity behaviors e.g. logic, chains of thought, memory operations, etc are all implemented within components. Concordia comes with a core library of components and user-created components are also included in the main library under the contrib directory. It's easy to create your own components and add them to the library.
  • Engine: The simulation loop. It solicits actions from entities and delegates resolution to the Game Master.

This modular architecture enables complex behaviors to be assembled from simple, reusable parts.

Folder Structure

[!TIP] The best way to learn is to watch the Concordia: Building Generative Agent-Based Models tutorial on YouTube, run the examples/tutorial.ipynb and then try modifying the Prefabs to see how agent behavior changes.

Installation

Concordia is available on PyPI and can be installed using:

pip install gdm-concordia

After doing this you can then import concordia in your own code.

Development

Codespace

The easiest way to work on the Concordia source code is to use our pre-configured development environment via a GitHub Codespace.

This provides a tested, reproducible development workflow that minimizes dependency management. We strongly recommend preparing all pull requests for Concordia via this workflow.

Manual setup

If you want to work on the Concordia source code within your own development environment you will have to handle installation and dependency management yourself.

For example, you can perform an editable installation as follows:

  1. Clone Concordia:

    git clone -b main https://github.com/google-deepmind/concordia
    cd concordia
    
  2. Create and activate a virtual environment:

    python -m venv venv
    source venv/bin/activate
    
  3. Install Concordia:

    pip install --editable .[dev]
    
  4. Test the installation:

    pytest --pyargs concordia
    
  5. Install any additional language model dependencies you will need, e.g.:

    pip install .[google]
    pip install --requirement=examples/requirements.in
    

    Note that at this stage you may find that your development environment is not supported by some underlying dependencies and you will need to do some dependency management.

Bring your own LLM

Concordia requires access to an LLM API. Any LLM API that supports sampling text should work, though result quality depends on the capabilities of the chosen model. You must also provide a text embedder for associative memory. Any fixed-dimensional embedding works for this, ideally one suited to sentence similarity or semantic search.

Example usage

Find below an illustrative social simulation where 4 friends are stuck in a snowed in pub. Two of them have a dispute over a crashed car.

The agents are built using a simple reasoning inspired by March and Olsen (2011) who posit that humans generally act as though they choose their actions by answering three key questions:

  1. What kind of situation is this?
  2. What kind of person am I?
  3. What does a person such as I do in a situation such as this?

The agents used in the following example implement exactly these questions:

Open In Colab

Citing Concordia

If you use Concordia in your work, please cite the accompanying article:

@article{vezhnevets2023generative,
  title={Generative agent-based modeling with actions grounded in physical,
  social, or digital space using Concordia},
  author={Vezhnevets, Alexander Sasha and Agapiou, John P and Aharon, Avia and
  Ziv, Ron and Matyas, Jayd and Du{\'e}{\~n}ez-Guzm{\'a}n, Edgar A and
  Cunningham, William A and Osindero, Simon and Karmon, Danny and
  Leibo, Joel Z},
  journal={arXiv preprint arXiv:2312.03664},
  year={2023}
}

Disclaimer

This is not an officially supported Google product.

Release files for gdm-concordia 2.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gdm-concordia 2.4.0
File Size Uploaded
gdm_concordia-2.4.0.tar.gz 255.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gdm-concordia 2.4.0
File Interpreter ABI Platform
gdm_concordia-2.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 680.6 kB

Release files / gdm_concordia-2.4.0.tar.gz

Download URL gdm_concordia-2.4.0.tar.gz
Size 255.1 kB
Tags Source
SHA-256 checksum
How to use checksums
133a0642ddae7204e9550cd3884160fd518ee8230cbe211d17c56a1e342cdc7f
BLAKE2b-256 checksum
How to use checksums
7246bba1c518e84891b39a93de18351213b892609754fb71dc4aaf07dd744ad8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / gdm_concordia-2.4.0-py3-none-any.whl

Download URL gdm_concordia-2.4.0-py3-none-any.whl
Size 425.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
940ff2c467c1969eef765aa316e9404893b80e04b8353a4e40eaeaecd2620908
BLAKE2b-256 checksum
How to use checksums
911a9acbd3ecedcb5a97877ba9efd31af2065c008597ad932e6b7d15120d3094
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

2.4.0 This release

2 release files

2.3.1

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.8.10

2 release files

1.8.9

2 release files

1.8.8

2 release files

1.8.7

2 release files

1.8.6

2 release files

1.8.5

2 release files

1.8.4

2 release files

1.8.3

2 release files

1.8.2

2 release files

1.8.1

2 release files

1.8.0

2 release files

1.7.0

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page