Skip to content

xqscora/community-pulse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Community Pulse

A 10-resident policy simulator on Gemma 4 + Mini-Cerome (a four-layer neurobiological personality model). Built for the Kaggle Gemma 4 Good Hackathon 2026 — Tracks: Impact / Global Resilience and Special Tech / Ollama. Apache 2.0.

A small, fully-local app a policymaker can run on a laptop to rehearse a policy with ten resident archetypes (busy parent, isolated elder, anxious shopkeeper, etc.) before a real-world rollout. Each agent's daily reaction and dialogue is generated by Gemma 4 through Ollama, but every prompt is constrained by a numerical drive vector maintained in code so the personalities don't drift between days. A small social graph updates with trust and familiarity; daily community metrics (mean stress, tie trust, resilience index) roll up into a Plotly time-series.

Companion to the PAT (Personality as Trajectory) manuscript (Zeng 2026, Frontiers in Psychology accepted).

Quick start

cd kaggle-community-pulse
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
  1. Install Ollama and pull a Gemma-family model (adjust name to match your install), e.g. ollama pull gemma3:4b.
  2. Run the UI:
streamlit run app.py

Optional environment variables:

  • OLLAMA_BASE_URL — default http://localhost:11434/v1
  • OLLAMA_GEMMA_MODEL — default gemma3:4b (must match ollama list)
  • OLLAMA_TIMEOUT_SEC — HTTP timeout per request (default 120)

Parallel LLM: each simulated day runs resident reasoning and (when pairs > 1) dialogues in a thread pool; tune Parallel LLM workers in the sidebar (cap at your CPU/GPU comfort). If Ollama errors under load, set workers to 1.

Community metrics: after each day, the sim stores mean_stress (L4), mean edge trust (L3-style cohesion), and a heuristic resilience_index (see community_metrics.py).

Without Ollama, you can still click Run one simulated day with Max agents to call LLM = 0 to exercise drives, graphs, and heuristics.

Headless CLI (batch / reproducibility)

From kaggle-community-pulse/:

python cli.py run --days 3 --no-llm --seed 42 --day-seed 0
python cli.py run --days 1 --scenario close_library --out pulse_run.json
  • --seed fixes the initial social graph (tie pattern).
  • --day-seed fixes within-day randomness (dialogue pairing).
  • --out writes the full history list (including metrics) as JSON.

Tests

pip install -r requirements-dev.txt
python -m pytest tests -q

Project layout

File Role
mini_cerome.py PAT personality slice + compute_drives (Deci & Ryan 2000–aligned drive structure as in CogArch)
community_metrics.py Daily aggregates: L4 stress, tie trust (L3-style), resilience heuristic
agents.py Agent + 10 archetypes
simulation.py Policy injection, day loop, parallel LLM, social ties, scenario JSON loader
gemma_bridge.py Thin OpenAI SDK client for Ollama
app.py Streamlit dashboard (Plotly + NetworkX layout)
scenarios/*.json Preset policies

Theory note (for write-up)

Numeric L1/L2/L4 and computed drives constrain Gemma prompts so the LLM is not the only “personality”: the engine implements the same drive formulas as in the larger Cerome class documented in PAT / CogArch (Zeng 2026 framework; neurobiological mapping in Cerome docstring: Schultz 1997, Cools 2008, Deci & Ryan 2000, LeDoux 2000, Craig 2009).

MFA in prompts: gemma_bridge.py adds an explicit attention / salience instruction so residents foreground different policy facets in line with competing drives and stress (consistent with the MFA treatment in CogArch’s deliberation notes: attention as competition, not uniform scanning).

Hackathon checklist (from plan)

  • Record 3-minute demo
  • Kaggle technical write-up + GitHub public repo
  • Swap model tag to official Gemma 4 Ollama name when available on your machine

About

A 10-resident community policy simulator powered by Gemma 4 + a four-layer neurobiological personality engine (Mini-Cerome). Built for the Gemma 4 Good Hackathon 2026. Runs offline on a laptop via Ollama; Streamlit UI + headless CLI; Apache 2.0.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages