Skip to content

add: LLM Epidemic (SIR) model using Chain-of-Thought reasoning#372

Open
abhinavk0220 wants to merge 5 commits intomesa:mainfrom
abhinavk0220:add/llm-epidemic-model
Open

add: LLM Epidemic (SIR) model using Chain-of-Thought reasoning#372
abhinavk0220 wants to merge 5 commits intomesa:mainfrom
abhinavk0220:add/llm-epidemic-model

Conversation

@abhinavk0220
Copy link

@abhinavk0220 abhinavk0220 commented Mar 9, 2026

Summary

Adds a classic SIR (Susceptible-Infected-Recovered) epidemic simulation
where agents use LLM Chain-of-Thought reasoning to decide their
behavior during an outbreak, instead of fixed stochastic transition
probabilities.

How this differs from similar epidemic models (e.g. #359)

PR #359 adds a deterministic pathogen model with fixed quarantine
and compliance rules agents follow predefined behavioral rules
based on parameters.

This model takes a fundamentally different approach: agents have
no fixed rules. Instead they use LLM Chain-of-Thought reasoning
to decide whether to isolate, move freely, or seek treatment at
each step based on what they observe around them.

The distinction matters because:

  • Fixed-rule models are faster and reproducible
  • LLM-reasoning models produce emergent behavioral heterogeneity
    that fixed parameters cannot capture

Both approaches are valid — they answer different research questions.

What makes this different from a classical SIR model

In a standard SIR model, infection and recovery are governed by fixed
probabilities (β and γ). Here, agents reason about their situation
at each step observing neighbor health states, weighing personal risk
against community responsibility and choose an action:

  • isolate : Stay home, reduce infection risk, slower social life
  • move_freely : Normal activity, higher transmission risk
  • seek_treatment : If infected, accelerate recovery

This produces epidemic curves shaped by emergent behavioral responses
rather than fixed parameters, demonstrating how LLM-powered agents can
model nuanced human decision-making during crises.

Visualization

  • Spatial grid with agents color-coded by health state:
    • 🔵 Blue = Susceptible
    • 🔴 Red = Infected
    • 🟢 Green = Recovered
    • ○ Circle = moving freely, □ Square = isolating
  • Real-time SIR plot tracking population counts over time

How to Run

cp .env.example .env  # fill in your API key
pip install -r requirements.txt
solara run app.py

Supported LLM Providers

Gemini, OpenAI, Anthropic, Ollama (local) configured via .env.
A .env.example is included for easy setup.

Reference

Kermack, W. O., & McKendrick, A. G. (1927). A contribution to the
mathematical theory of epidemics. Proceedings of the Royal Society
of London. Series A
, 115(772), 700–721.

abhinavKumar0206 and others added 5 commits March 10, 2026 02:05
…classic SIR epidemic simulation where agents use LLMChain-of-Thought reasoning to decide their behavior during anoutbreak, instead of fixed stochastic transition probabilities.Agents choose between:- isolate: stay home, reduce infection risk- move_freely: normal activity, higher transmission risk- seek_treatment: if infected, accelerate recoveryThe model demonstrates how LLM-driven behavioral reasoningproduces emergent epidemic curves that reflect nuanced humandecision-making during crises, contrasting with classicalfixed-rule SIR dynamics.Includes .env.example for API key configuration (supportsGemini, OpenAI, Anthropic, and Ollama).Visualization includes spatial grid (color-coded by healthstate) and real-time SIR plot tracking population counts.Reference: Kermack & McKendrick (1927)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant