Skip to content

showjihyun/Prophet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

130 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
Prophet โ€” 3D social simulation spreading in real time

๐Ÿ”ฎ Prophet

The wind tunnel for marketing campaigns

Test your campaign on 10,000 AI agents before you spend a dollar on the launch.

GitHub stars License: MIT Version Last commit

Python FastAPI React TypeScript Docker Tests


๐Ÿš€ Quick Start ยท โœจ Features ยท ๐ŸŽฏ Use Cases ยท ๐Ÿ“Š Comparison ยท ๐Ÿ“– Docs ยท ๐Ÿค Contributing


git clone https://github.com/showjihyun/prophet.git
cd prophet && docker compose up -d
open http://localhost:5173

That's it. 5 minutes from clone to your first simulation. No API keys required to start โ€” Prophet runs fully locally on a laptop.


๐Ÿ’ก Why Prophet?

Focus groups lie โ€” 10 humans in a room cannot tell you how a message spreads through a community. A/B tests are too late โ€” by the time you have data, you're already paying for the launch. Brand-lift studies take 6 weeks, cost $50K, and tell you nothing about why a message failed.

Every discipline that ships things at scale โ€” aerospace, civil engineering, software โ€” gets to simulate before it builds. Marketing doesn't. Until now.

You take your campaign. You drop it into a virtual society of 10,000 AI agents organized into the communities you actually care about. You watch what happens.


โœจ Features

๐Ÿง  6-Layer Agent Engine

Each agent perceives, remembers, feels, cognizes, decides, and influences โ€” powered by LLM cognition with persistent per-agent memory.

๐Ÿ’ฐ Under $5 per run

3-tier inference (80% local SLM + 10% heuristic + 10% elite LLM) keeps 10K-agent simulations radically cheap. A naive GPT-4 run costs ~$15K.

๐ŸŒ Realistic networks

Hybrid Watts-Strogatz + Barabรกsi-Albert generator produces realistic clustering, power-law influencers, and cross-community bridges.

๐ŸŽฅ Watch it spread

Real-time 3D WebGL graph (three.js) with orbit / zoom / pan controls, community-colored nodes, and cascade highlighting.

๐Ÿ”ฅ Auto-cascade detection

Viral cascades, polarization, echo chambers, collapse, slow adoption โ€” detected and timeline-marked as the simulation runs.

๐Ÿ”Œ Multi-LLM ready

Ollama, Claude, OpenAI, Gemini, + 2026 Chinese flagships (DeepSeek, Qwen, Moonshot Kimi, Zhipu GLM) out of the box.

๐Ÿšจ Mid-run intervention

Pause any time, Inject Event (controversy / endorsement / regulation), or Replay from step N to branch the timeline and try a different shock.

โš™๏ธ Live engine control

Dial the SLM / LLM ratio while the simulation is paused. Trade cost for reasoning depth without restarting from step 0.

๐Ÿ”€ Compare scenarios

Run the same campaign with one variable changed. Compare view puts adoption / sentiment / cascades side by side. Clone any run in one click.


๐Ÿš€ Quick Start

๐Ÿณ Docker (recommended)

GPU โ€” NVIDIA (strongly recommended)

docker compose -f docker-compose.yml -f docker-compose.gpu.yml up -d
docker compose exec ollama ollama pull llama3.1:8b

On an RTX 4070-class GPU, llama3.1:8b runs at ~75 tok/s โ€” sub-second per agent tick.

CPU-only (no NVIDIA)

docker compose up -d
export OLLAMA_DEFAULT_MODEL=llama3.2:1b SLM_MODEL=llama3.2:1b
docker compose up -d --force-recreate backend
docker compose exec ollama ollama pull llama3.2:1b

Service endpoints

Service URL
๐Ÿ–ฅ๏ธ Frontend http://localhost:5173
โš™๏ธ Backend API http://localhost:8000
๐Ÿ“˜ API Docs (Swagger) http://localhost:8000/docs

Open localhost:5173 โ†’ Projects โ†’ create a scenario with a campaign message โ†’ click Run All. Watch the 3D graph spread in real time.

๐Ÿ’ป Local development

# Backend
cd backend && uv sync && uv run uvicorn app.main:app --reload

# Frontend
cd frontend && npm install && npm run dev

๐ŸŽฎ What you actually do in the UI

Prophet is not just an engine โ€” it's a workspace. Here's the loop you actually click through:

  1. Set up. Projects โ†’ New Scenario โ†’ Campaign Setup. You name the campaign, write the message, dial in novelty / controversy / utility, set the budget, pick which communities it lands on, and choose how many steps to run (default 50).
  2. Run. Run All for the whole sweep, or Step to advance one tick at a time and watch the 3D graph spread. Pause any time.
  3. Intervene mid-run. While paused you can:
    • Inject Event โ€” drop a sudden shock (Controversy / Celebrity Endorsement / Regulatory Change / etc.) targeting all or specific communities. Takes effect on the next step.
    • Engine Control โ€” change the SLM / LLM ratio live. Trade cost for reasoning depth without restarting.
    • Replay from step N โ€” branch the simulation at any past step and try a different intervention from there.
  4. Read the result. When it completes you get a Summary Report (adoption curve, sentiment, top community, scrollable Key Events timeline) and the dedicated Analytics page with deep deltas, cascade timeline, and shareable deep links.
  5. Drill into why. Opinions lets you go scenario โ†’ community โ†’ individual conversation thread. Top Influencers ranks who actually moved the needle. Agent Interview asks any single agent why it decided what it did.
  6. Compare. Run the same campaign with one variable changed (different message, different intervention, different population) and the Compare view shows them side by side. Clone any scenario in one click to start the next variant.

This is the loop. Most decisions get made between steps 3 and 6 โ€” set it up once, run it many ways.


๐ŸŽฏ Use Cases

๐Ÿงƒ Pre-test a product launch

A beverage brand was about to spend $1.2M launching a sustainability product. Ran the message against 5,000 agents (15% skeptics, 60% mainstream, 20% early adopters, 5% influencers). Prophet showed the message polarized skeptics and adoption stalled at 13%. They reframed and hit 78% by the same step in the second simulation.

๐Ÿ’‰ Pre-screen public health messages

A health agency tested 3 vaccine messages against a 5K-agent virtual population. Strategy B caused near-zero adoption in skeptical communities (no viral cascade events in the first 4 steps). Strategy C triggered three positive cascades through influencer nodes by step 4. They picked C โ€” adoption lift was 312ร— at the early-step horizon.

๐Ÿข Stress-test internal communications

A Fortune 500 ran their RTO mandate through a synthetic employee population (4,500 engineering-heavy agents). Prophet predicted complete stall + slide into negative sentiment (mean_belief = -0.23, zero cascades). Restructured with carve-outs: same population hit 94% adoption with +0.68 sentiment โ€” a +91-point swing from restructuring alone.

๐Ÿšจ Stress-test crisis response (mid-run shock injection)

A consumer brand wanted to know how a sudden negative PR event would derail an ongoing campaign. Ran the campaign normally for 20 steps (adoption climbing toward 64%), then mid-run injected Controversy + "battery explosion in 47 units" + 0.9 via the Inject Event modal targeting only the skeptic community. The next 8 steps showed adoption stall at 41% and sentiment crash from +0.42 to -0.31, with two negative cascade events on the timeline. They tested two response messages on top: "transparent recall + free replacement" recovered to 58% by step 30; "deny and deflect" drove a third cascade and stalled at 19%. Crisis playbook went from gut-feel to rehearsed.

๐Ÿ”ฌ Computational social science research

Open-source. Reproducible. Runs on a laptop. Built-in cascade detection. If you've been wanting to do agent-based diffusion research without renting a GPU cluster, Prophet is for you.

Reproducible. Every claim above is verified end-to-end against the current engine in docs/USE_CASE_PILOTS.md, with raw per-step JSON in docs/pilot_results/. Re-run any pilot with uv run python backend/scripts/run_use_case_pilot.py --case <name>.


๐Ÿ“Š How Prophet compares

Prophet OASIS (academic) AnyLogic Focus groups
๐Ÿ’ต 10K-agent simulation cost under $5 free $15K+ license $30K+
โฑ๏ธ Time to first result 5 minutes hours days 6 weeks
๐Ÿง  LLM-driven agent cognition โœ… โœ… โŒ n/a
๐ŸŽจ Real-time 3D visualization โœ… โŒ โœ… โŒ
๐ŸŒŠ Cascade / echo chamber detect โœ… โŒ โŒ โŒ
๐Ÿ“ˆ Marketing-specific metrics โœ… โŒ partial โœ…
๐Ÿ†“ Open source MIT MIT โŒ n/a
๐Ÿ’ป Runs on a laptop โœ… โœ… โœ… n/a

Numbers are rough order-of-magnitude based on public pricing and running comparable workloads. Your mileage will vary.


๐Ÿ“ธ Screenshots

3D simulation graph with cascade highlighting 3D Simulation Workspace โ€” community-colored agents, real-time cascade glow, adopted-node tinting per community. Inject Event / Engine Control / Replay live in the sidebar. Three-level Opinions hierarchy Opinions Hierarchy โ€” drill from scenario โ†’ community โ†’ individual conversation thread. See exactly which messages drove the consensus or the polarization.
Post-run Analytics page Post-Run Analytics โ€” adoption curve, sentiment trajectory, per-community breakdown, cascade timeline. Deep-link any metric for sharing. Top Influencers page Top Influencers โ€” power-law influencers ranked by network reach + step-by-step propagation contribution. Find who actually moved the needle.

Screenshots not rendering? They live in docs/assets/screenshots/ โ€” a fresh clone may be missing them while we record the next batch.


๐Ÿ“ The math & social science under the hood

Prophet isn't a "vibes" simulator. Every layer is a published, peer-reviewed model โ€” wired together so you can change one knob and see the rest react. This section names the techniques and the academic lineage so reviewers, grad students, and skeptical CMOs can audit it.

Every claim below cites the source file. Search the repo for SPEC: docstrings to trace each technique back to its formal contract.

๐ŸŒ Network structure

Technique What it does in Prophet Source
Watts-Strogatz small-world Per-community local clustering with rewiring p โ€” captures the "friend of a friend" structure of real social ties network/community_graph.py
Barabรกsi-Albert preferential attachment Generates the influencer/hub layer with a power-law degree distribution โ€” a few accounts hold most of the reach network/influencer_layer.py
Hybrid hub-merging + bridge edges BA hubs are spliced into WS communities; cross-community bridges are degree-weighted (preferential) so brokers form realistically network/generator.py
Personality homophily Edge weights boosted by Manhattan-distance similarity across 5 traits โ€” likes attract, but not exclusively network/generator.py:390
Validation: clustering coefficient ยท modularity ยท degree assortativity Generated networks are rejected unless 0.2 โ‰ค CC โ‰ค 0.6 and modularity is non-trivial โ€” guarantees real-network character network/generator.py:486

Why this matters: random graphs (Erdล‘s-Rรฉnyi) systematically underestimate cascade behavior because they have no clustering and no hubs. Prophet's hybrid generator is calibrated to reproduce the structural signatures of empirical online communities (Watts 1998; Barabรกsi-Albert 1999; Newman 2003).

๐Ÿง  Opinion & belief dynamics

Deffuant bounded-confidence model โ€” agents only listen to neighbors whose belief is within an "open mind" radius

belief_i(t+1) = belief_i(t) + ฮผ ยท (belief_j(t) โˆ’ belief_i(t)) only if |belief_i โˆ’ belief_j| < ฮต (default ฮต = 0.3, ฮผ = 0.5). This is the canonical mechanism that allows polarization to emerge endogenously โ€” without it, every model collapses to consensus. (Deffuant, Neau, Amblard, Weisbuch 2000.) โ†’ opinion_dynamics.py

Friedkin-style stubbornness โ€” convergence rate is dampened by an agent's stubbornness trait

ฮผ' = ฮผ ยท (1 โˆ’ stubbornness) so loyal-to-prior agents barely move even when exposed to contrary views. Generalizes Friedkin-Johnsen by tying anchor weight to a trait. โ†’ opinion_dynamics.py:36

Expert influence (sentiment shift) โ€” credentialed agents nudge community sentiment with a configurable ฮฑ

E_community(t+1) = clamp(E_community(t) + ฮฑ ยท O_expert) with ฮฑ = 0.3. Lets you study the asymmetry between official sources and grassroots voices. โ†’ sentiment_model.py:64

๐ŸŒŠ Diffusion & contagion

Technique Implementation
SIR-inspired state machine Agents transition SUSCEPTIBLE โ†’ EXPOSED โ†’ ADOPTED/REJECTED โ€” the canonical epidemic model adapted for information goods
Calibrated propagation probability P = max(0.1, I)ยทTยทฯƒ(โˆ’4ยทE)ยทMS where I=influence, T=trust, E=emotion, MS=message strength โ€” a logistic-modulated multiplicative form
RecSys-inspired exposure Two-phase candidate-gen + ranking: score = wโ‚ยทrecency + wโ‚‚ยทsocial_affinity + wโ‚ƒยทinterest_match + wโ‚„ยทengagement + wโ‚…ยทad_boost โˆ’ diversity_penalty (top-K feed). Mirrors industry recommender-system practice
Negative-cascade amplification Negative events trigger asymmetric (โ‰ค 0) sentiment deltas โ€” operationalizes the "bad-news-travels-faster" finding (Vosoughi, Roy, Aral 2018)
Reddit-style hot score (optional) `h = sign(net) ยท logโ‚โ‚€(max(

๐Ÿ”ฅ Emergent-behavior detection

Five auto-detectors fire as the simulation runs and surface on the timeline:

Event Trigger formula File
Viral cascade adoption_rate โ‰ฅ 0.15 in one step OR step-delta โ‰ฅ 0.15 cascade_detector.py:109
Slow adoption adoption_rate < 0.02 for โ‰ฅ 5 consecutive steps (fires once, resets on recovery) cascade_detector.py:155
Polarization community sentiment_variance > 0.05 (sample variance, nโˆ’1 Bessel correction) cascade_detector.py:210
Collapse adoption drops โ‰ฅ 20% over 3 steps cascade_detector.py:235
Echo chamber internal_links / external_links > 10 (returns max ratio across communities) cascade_detector.py:275

๐ŸŽฒ Monte Carlo & uncertainty

Aggregate Formula File
Viral probability fraction of N runs that fire โ‰ฅ 1 viral cascade simulation/monte_carlo.py:149
Expected reach mean final adoption across runs line 152
P5 / P50 / P95 reach sorted-index percentile lookup (no interpolation โ€” stable for small N) line 154

Each MC run replays the same SimulationConfig with seed = base_seed + run_id ร— 1000 for full reproducibility.

๐Ÿค– Cognition cost-control (LLM tier routing)

Phase 1: experts โˆช {agents with influence > 0.7} โˆช critical-decision agents โ†’ Tier 3 (Elite LLM)
Phase 2: {influence > 0.5} โˆช {skeptic_skepticism > 0.7}                     โ†’ Tier 2 (heuristic + LLM blend)
Otherwise                                                                    โ†’ Tier 1 (local SLM)
Caps: max_tier3_ratio โ‰ค 10%, max_tier2_ratio โ‰ค 10%

This is what keeps a 10K-agent run under $5 while keeping the high-leverage decisions on a frontier model. โ†’ agent/tier_selector.py


๐Ÿ”ฌ What this means for social science

Prophet is, in academic terms, an agent-based model (ABM) of opinion dynamics on a generative social network with calibrated viral-diffusion mechanics. Three traditions converge:

  1. Bounded-confidence opinion dynamics (Deffuant 2000, Hegselmann-Krause 2002) โ€” the "open-minded radius" mechanism that produces clustering rather than consensus.
  2. Generative network models (Watts-Strogatz 1998, Barabรกsi-Albert 1999) โ€” the structural backbone that lets micro-rules produce macro-patterns matching real platforms.
  3. Computational diffusion (Kempe-Kleinberg-Tardos 2003 cascade models, plus modern RecSys-augmented exposure) โ€” the pipeline a message follows from impression to adoption.

Why it's useful

๐ŸŽ“ For researchers

  • A reproducible substrate for replicating ABM papers without writing your own simulator
  • Built-in cascade / polarization / echo-chamber detectors mean you can study macro-patterns, not just micro-mechanics
  • Per-step JSON export โ†’ drop straight into pandas / R / Jupyter
  • LLM-driven cognition lets you study message content effects, not just topology โ€” a frontier ABMs have struggled with

๐Ÿ“ฃ For practitioners

  • Pre-test message variants against synthetic populations whose composition you control
  • Quantify uncertainty (P5 / P50 / P95 reach) before you spend
  • Identify which communities will polarize before the campaign hits them
  • Study counterfactuals โ€” "what if we removed this influencer?" / "what if the message was 0.2 less controversial?" โ€” at zero risk

๐Ÿ›๏ธ For policy & public health

  • Pre-screen public-health messaging for asymmetric uptake across communities
  • Test crisis-comms variants under simulated information shocks
  • Forecast the polarization risk of contested policy announcements
  • Compare informational interventions (transparency, framing) against structural ones (network seeding)

๐Ÿงช For social-science pedagogy

  • A live ABM students can run and break โ€” the textbook diagrams come alive
  • The 6-step UI maps cleanly to a research workflow (Generate โ†’ Inject โ†’ Simulate โ†’ Detect โ†’ Visualize โ†’ Decide)
  • Open source means students can read the equations in the same place the simulator runs them

Honest limitations

Prophet is a model โ€” and all models are wrong, some are useful. Things to be honest about:

  • Calibration is structural, not empirical. Network statistics (clustering, modularity) are validated against ranges from the literature โ€” not against your specific platform's logs.
  • LLM agents inherit LLM biases. Tier 3 cognition uses general-purpose LLMs; their persona play is consistent but is not a substitute for actual human focus-group data.
  • Bounded-confidence dynamics are a theory, not a measurement. Different opinion-dynamics models (DeGroot, voter, Hegselmann-Krause) produce different predictions; we picked Deffuant for its empirical track record on polarization, but reasonable researchers disagree.
  • Five emergent-behavior detectors do not exhaust the space. We picked the five most common in the diffusion literature; novel patterns will need custom detectors (PRs welcome).

In other words: use Prophet to generate hypotheses, narrow your search space, and rule out obvious failure modes โ€” not to replace empirical validation on real audiences.


๐Ÿ—๏ธ Architecture

1. Generate     โ†’ 10K agents in 5 communities (early adopters, mainstream,
                  skeptics, experts, influencers) with realistic clustering,
                  scale-free degree, and bridge nodes

2. Inject       โ†’ Your campaign / message / policy

3. Simulate     โ†’ Each agent runs the 6-layer loop
                  (perception โ†’ memory โ†’ emotion โ†’ cognition โ†’ decision โ†’ influence)

4. Detect       โ†’ Viral cascades, polarization, echo chambers, collapse,
                  slow adoption โ€” auto-marked on the timeline

5. Visualize    โ†’ 3D WebGL graph with orbit / zoom / pan,
                  community-colored nodes and edges, WebSocket live updates

6. Decide       โ†’ Compare scenarios, export JSON / CSV, share links

๐Ÿงฐ Tech Stack

Layer Stack
๐Ÿ–ผ๏ธ Frontend React 18 ยท TypeScript ยท Vite ยท Tailwind ยท react-force-graph-3d (three.js) ยท Cytoscape.js
๐Ÿงต State Zustand ยท TanStack Query ยท native WebSocket
โš™๏ธ Backend Python 3.12 ยท FastAPI (async) ยท SQLAlchemy 2.0 ยท Pydantic v2
๐Ÿค– LLM Ollama (local SLM) ยท Claude ยท OpenAI ยท Gemini ยท DeepSeek ยท Qwen ยท Moonshot Kimi ยท Zhipu GLM
๐Ÿ—„๏ธ Database PostgreSQL 16 + pgvector
โšก Cache Valkey
๐Ÿงช Testing pytest (1,031) ยท Vitest (736) ยท Playwright (E2E)
๐Ÿ“ฆ Package uv (Python) ยท npm (Node)

๐Ÿงช What's working today

  • โœ… 6-layer agent engine with LLM-driven cognition
  • โœ… 3-tier inference keeping 10K-agent simulations under $5
  • โœ… Real-time 3D WebGL graph that scales to 5K+ nodes
  • โœ… Cascade, echo chamber, polarization auto-detection from real network topology
  • โœ… WebSocket live streaming with pause / resume / step / run-all
  • โœ… 8 LLM providers first-class โ€” Ollama, Claude, OpenAI, Gemini + 4 Chinese flagships (2026)
  • โœ… 1,767+ automated tests with Playwright E2E coverage

๐ŸŸก In progress: hosted Cloud Starter tier, scenario template library, validation studies ๐Ÿ”ฎ Planned: plugin SDK, Segment / mParticle / HubSpot integrations, multi-language agents

Full history โ†’ CHANGELOG.md ยท Roadmap discussion โ†’ ROADMAP.md


๐Ÿ“– Documentation


โญ Star History

Star History Chart

If Prophet is useful to you, a star is the fastest way to help others find it.


๐Ÿค Contributing

We need help. Specifically:

  • ๐Ÿ› Bug reports with reproduction steps
  • ๐Ÿ“ Documentation improvements (typos, clarity, examples)
  • ๐Ÿงช Test cases for edge cases you find
  • ๐ŸŒฑ good first issue picks โ€” small, clearly-scoped tasks for newcomers
  • ๐Ÿ’ก Use cases โ€” tell us what you're trying to simulate; we may already support it

Start here:

  1. Read CONTRIBUTING.md
  2. Browse good first issue
  3. Open a Discussion before any large change
  4. Open a PR โ€” we aim to respond within 48 hours

Maintainers are active. First-time contributors get a thank-you and a fast review. We label every issue, keep the roadmap public, and publish what we ship.

๐Ÿ‘ฅ Contributors

Contributors

๐Ÿ—ฃ๏ธ Community

If you build something cool with Prophet, we want to see it. Open a Discussion and post a screenshot.


๐Ÿ™ Inspiration & Acknowledgments

Prophet stands on the shoulders of many other projects.

MiroFish โ€” biggest architectural influence

MiroFish combined OASIS (academic agent simulator) with GraphRAG and Zep Cloud for long-term memory. It proved LLM-driven agents with persistent memory could be assembled into a coherent pipeline. Prophet takes that idea, opens it up, makes it cheaper through tiered inference, and adds the marketing-specific layer (cascade detection, viral metrics, real-time viz) that MiroFish doesn't focus on.

Other prior art we learned from
  • OASIS โ€” academic foundation for large-scale agent-based social simulation
  • GraphRAG (Microsoft Research) โ€” hybrid vector + graph retrieval pattern
  • NetworkX โ€” hybrid WS+BA generator would have taken months instead of days without it
  • three.js / react-force-graph-3d โ€” 3D rendering; instanced sphere rendering scales to thousands of nodes
  • Cytoscape.js โ€” EgoGraph 2D force-directed layout
  • Ollama โ€” local SLM inference makes the 3-tier cost model possible
  • Hugging Face / open-weight LLM community โ€” proved small models are good enough for agent reasoning
  • NetLogo and MASON โ€” showed decades ago that simulating a society is a tractable engineering problem

If you contributed to any of these and feel we should credit you more specifically, open a PR โ€” we'll fix it.


๐Ÿ“œ License

MIT โ€” see LICENSE.

Use it commercially. Fork it. Modify it. Embed it. We just ask you to keep the license file and not pretend you wrote it from scratch.


๐Ÿ“š Citation

If Prophet helps your research, please cite:

@software{prophet_2026,
  title  = {Prophet: A simulation engine for marketing campaign diffusion},
  author = {Prophet Contributors},
  year   = {2026},
  url    = {https://github.com/showjihyun/prophet}
}

Built because marketing deserves a wind tunnel. Open-sourced because everyone deserves one.

Made with โšก and way too much coffee ยท โฌ† back to top