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).
cd kaggle-community-pulse
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt- Install Ollama and pull a Gemma-family model (adjust name to match your install), e.g.
ollama pull gemma3:4b. - Run the UI:
streamlit run app.pyOptional environment variables:
OLLAMA_BASE_URL— defaulthttp://localhost:11434/v1OLLAMA_GEMMA_MODEL— defaultgemma3:4b(must matchollama list)OLLAMA_TIMEOUT_SEC— HTTP timeout per request (default120)
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.
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--seedfixes the initial social graph (tie pattern).--day-seedfixes within-day randomness (dialogue pairing).--outwrites the fullhistorylist (includingmetrics) as JSON.
pip install -r requirements-dev.txt
python -m pytest tests -q| 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 |
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).
- 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