LLM-driven agent-based information diffusion simulation
Project description
LLM Society Information Diffusion Simulation
A modular repo to simulate information diffusion using LLM-based agent conversations.
Features
- Segment-based persona configuration (proportions, flexible trait specs)
- Random network generation with tie strengths
- LLM-driven conversations and belief updates, or simple/complex contagion modes
- YAML/JSON config + CLI
- Visualization utilities and notebook integration
Install
- Python 3.10+
- Install the package (from PyPI when published, or locally):
pip install llm-society
# or for local development
pip install -e .
- Set OpenAI API key via env var or add
api-key.txt(single line):
# Preferred: environment variable
export OPENAI_API_KEY=<YOUR_OPENAI_API_KEY>
# Or: file (gitignored)
echo "<YOUR_OPENAI_API_KEY>" > api-key.txt
Run from CLI
# write an example config to a path
llm-society --write-example-config my-config.yaml
# run the simulation with your config
llm-society --config my-config.yaml
# override selected parameters via flags
llm-society --config my-config.yaml --depth 0.8 --rounds 20
# run fully via flags (no config file)
llm-society \
--information "5G towers cause illness." \
--n 20 --degree 4 --rounds 10 \
--depth 0.6 --depth-max 6 --edge-frac 0.5 \
--seeds 0,1 --seed-belief 0.98 --talk-prob 0.25 \
--mode llm --complex-k 2 --rng 0 --model gpt-4.1
Use in Notebook Example snippet:
from llm_society import network
net = network(n=5, degree=2, rounds=10, depth=0.6, depth_max=6,
edge_frac=0.5, seeds=[0,1], seed_belief=0.98,
information="5G towers cause illness.", talk_prob=0.25,
mode="llm", complex_k=2, rng=0)
net.simulate() # prints conversations, belief updates, summaries
net.plot() # coverage curve + final beliefs graph
net.nodes[1].plot() # single-node belief trajectory
Config Schema
See llm_society/data/example.yaml. Key fields:
n,degree,rounds,depth(0-1),max_convo_turns,edge_sample_fracseed_nodes,seed_belief,information_text,talk_information_probcontagion_mode:llm|simple|complex;complex_threshold_kpersona_segments: list of segments withproportionandtraits.- Trait values can be fixed strings, weighted
choices, or numeric distributions (dist: normal, oruniform: [a,b]). - Extra traits allowed and included in prompts.
- Trait values can be fixed strings, weighted
Depth interpretation:
depth∈ [0,1] controls conversation length tendency. Higher means longer conversations.- Internally mapped to a geometric distribution;
depth=0→ very short;depth=1→ near themax_convo_turnscap often.
License MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm_society-0.1.1.tar.gz.
File metadata
- Download URL: llm_society-0.1.1.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6b359eabc2b302eb4385a3a727f1e0ef2c3607e9139a961c8412931df6ba429
|
|
| MD5 |
607ddd160f096ffb3b569bce2bb426c8
|
|
| BLAKE2b-256 |
0bd803cc19f71ad29a75af54d5416c685fa506f2dcc8a01867fe71d5bd12082e
|
Provenance
The following attestation bundles were made for llm_society-0.1.1.tar.gz:
Publisher:
publish.yml on TianzhuQin/LLM-ABM-Information-Network
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llm_society-0.1.1.tar.gz -
Subject digest:
d6b359eabc2b302eb4385a3a727f1e0ef2c3607e9139a961c8412931df6ba429 - Sigstore transparency entry: 611507960
- Sigstore integration time:
-
Permalink:
TianzhuQin/LLM-ABM-Information-Network@fb372f9ca0de5ca5c6a12653d5ebe8d8b5b3db6c -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/TianzhuQin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fb372f9ca0de5ca5c6a12653d5ebe8d8b5b3db6c -
Trigger Event:
push
-
Statement type:
File details
Details for the file llm_society-0.1.1-py3-none-any.whl.
File metadata
- Download URL: llm_society-0.1.1-py3-none-any.whl
- Upload date:
- Size: 20.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cac4bb8c85f8af3aa7d9ef0a5f89a1ac9d236877d6efc83bcb303e92f3cd5b3
|
|
| MD5 |
177cc1be24a6b5495a616b7e359a5b22
|
|
| BLAKE2b-256 |
6a1605e1de1a9c64b62b1b6cc928103592a5f4baa2303599d6a89311b1604c55
|
Provenance
The following attestation bundles were made for llm_society-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on TianzhuQin/LLM-ABM-Information-Network
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llm_society-0.1.1-py3-none-any.whl -
Subject digest:
6cac4bb8c85f8af3aa7d9ef0a5f89a1ac9d236877d6efc83bcb303e92f3cd5b3 - Sigstore transparency entry: 611507970
- Sigstore integration time:
-
Permalink:
TianzhuQin/LLM-ABM-Information-Network@fb372f9ca0de5ca5c6a12653d5ebe8d8b5b3db6c -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/TianzhuQin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fb372f9ca0de5ca5c6a12653d5ebe8d8b5b3db6c -
Trigger Event:
push
-
Statement type: