crichalchemist commited on
Commit
62e8b35
Β·
verified Β·
1 Parent(s): b9fe24b

docs: add model card, add input_size to metadata

Browse files
Files changed (2) hide show
  1. README.md +157 -0
  2. training_metadata.json +2 -1
README.md ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - en
5
+ tags:
6
+ - welfare
7
+ - forecasting
8
+ - time-series
9
+ - pytorch
10
+ - ethics
11
+ - phi-humanity
12
+ library_name: pytorch
13
+ pipeline_tag: time-series-forecasting
14
+ datasets:
15
+ - synthetic
16
+ metrics:
17
+ - mse
18
+ model-index:
19
+ - name: PhiForecasterGPU
20
+ results:
21
+ - task:
22
+ type: time-series-forecasting
23
+ name: Welfare Trajectory Forecasting
24
+ metrics:
25
+ - name: Best Validation Loss (MSE)
26
+ type: mse
27
+ value: 0.000196
28
+ ---
29
+
30
+ # PhiForecasterGPU β€” Welfare Trajectory Forecaster
31
+
32
+ A CNN+LSTM+Attention model that forecasts **Phi(humanity)** welfare trajectories β€” predicting how 8 ethical constructs (care, compassion, joy, purpose, empathy, love, protection, truth) evolve over time.
33
+
34
+ ## Model Description
35
+
36
+ PhiForecasterGPU takes a 50-timestep window of 36 welfare signal features and predicts the next 10 timesteps for both the aggregate Phi score and all 8 individual constructs.
37
+
38
+ | Property | Value |
39
+ |----------|-------|
40
+ | **Architecture** | CNN1D (2-layer) β†’ Stacked LSTM (2-layer) β†’ Additive Attention β†’ Dual heads |
41
+ | **Parameters** | ~1.3M |
42
+ | **Input** | 50 timesteps Γ— 36 features |
43
+ | **Output** | 10-step Phi forecast + 10-step Γ— 8 construct forecast + attention weights |
44
+ | **Formula** | Phi v2.1 (recovery-aware floors) |
45
+ | **Training** | 100 epochs, 44,800 sequences from 8 scenario types Γ— 50 seeds |
46
+ | **Best Val Loss** | 0.000196 MSE |
47
+
48
+ ### Architecture
49
+
50
+ ```
51
+ Input (50 Γ— 36)
52
+ ↓
53
+ CNN1D (2 conv layers, kernel=3, hidden=256)
54
+ ↓
55
+ Stacked LSTM (2 layers, hidden=256)
56
+ ↓
57
+ Additive Attention (query-key-value)
58
+ ↓
59
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
60
+ β”‚ Phi Head β”‚ Construct Head β”‚
61
+ β”‚ (MLP β†’ 10) β”‚ (MLP β†’ 10 Γ— 8) β”‚
62
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
63
+ ```
64
+
65
+ ### 36 Input Features
66
+
67
+ - **8 raw constructs:** c, kappa, j, p, eps, lam_L, lam_P, xi
68
+ - **8 volatility signals:** rolling 20-step standard deviation per construct
69
+ - **8 momentum signals:** 10-step price momentum per construct
70
+ - **5 synergy signals:** geometric mean of construct pairs (careΓ—love, compassionΓ—protection, joyΓ—purpose, empathyΓ—truth, loveΓ—truth)
71
+ - **5 divergence signals:** squared difference of construct pairs
72
+ - **phi:** aggregate welfare score
73
+ - **dphi_dt:** first derivative of phi
74
+
75
+ ### Graph-Enhanced Mode (43 features)
76
+
77
+ When trained with `graph_features_enabled=True`, the model accepts 43 features (36 base + 7 graph topology features from the detective knowledge graph):
78
+
79
+ | Feature | Description |
80
+ |---------|-------------|
81
+ | graph_density | Edge density of the full graph |
82
+ | entity_pagerank | PageRank centrality of focal entity |
83
+ | entity_degree | Normalized degree of focal entity |
84
+ | entity_clustering | Clustering coefficient |
85
+ | community_size | Fraction of graph in same community |
86
+ | avg_neighbor_conf | Mean edge confidence to neighbors |
87
+ | hub_score | HITS hub score (normalized) |
88
+
89
+ ## The Phi(humanity) Formula
90
+
91
+ Phi is a rigorous ethical-affective objective function grounded in care ethics (hooks 2000), capability theory (Sen 1999), and Ubuntu philosophy:
92
+
93
+ ```
94
+ Phi(humanity) = f(lam_L) Β· [prod(x_tilde_i ^ w_i)] Β· Psi_ubuntu Β· (1 - Psi_penalty)
95
+ ```
96
+
97
+ - **f(lam_L):** Community solidarity multiplier
98
+ - **x_tilde_i:** Recovery-aware effective inputs (below-floor constructs get community-mediated recovery)
99
+ - **w_i:** Inverse-deprivation weights (Rawlsian maximin)
100
+ - **Psi_ubuntu:** Relational synergy term + curiosity coupling (love Γ— truth)
101
+ - **Psi_penalty:** Structural distortion penalty for mismatched construct pairs
102
+
103
+ ## Training Scenarios
104
+
105
+ | Scenario | Description |
106
+ |----------|-------------|
107
+ | stable_community | Baseline β€” all constructs ~0.5 |
108
+ | capitalism_suppresses_love | Love declines as purpose erodes |
109
+ | surveillance_state | Truth rises while love collapses |
110
+ | willful_ignorance | Love rises while truth collapses |
111
+ | recovery_arc | Collapse then community-led recovery |
112
+ | sudden_crisis | Compassion + protection crash mid-scenario |
113
+ | slow_decay | Gradual institutional erosion |
114
+ | random_walk | Correlated random walks with mean-reversion |
115
+
116
+ ## Usage
117
+
118
+ ```python
119
+ import torch
120
+ from huggingface_hub import hf_hub_download
121
+
122
+ # Download checkpoint
123
+ path = hf_hub_download("crichalchemist/phi-forecaster", "phi_forecaster_best.pt")
124
+
125
+ # Load model (see spaces/maninagarden/model.py for class definitions)
126
+ from model import PhiForecasterGPU
127
+ model = PhiForecasterGPU(input_size=36, hidden_size=256, n_layers=2, pred_len=10)
128
+ model.load_state_dict(torch.load(path, map_location="cpu", weights_only=True))
129
+ model.eval()
130
+
131
+ # Inference: (batch, seq_len=50, features=36) -> phi, constructs, attention
132
+ X = torch.randn(1, 50, 36)
133
+ phi_pred, construct_pred, attn = model(X)
134
+ # phi_pred: (1, 10, 1) β€” next 10 Phi values
135
+ # construct_pred: (1, 10, 8) β€” next 10 values for each construct
136
+ # attn: (1, 50) β€” attention weights over input window
137
+ ```
138
+
139
+ ## Live Demo
140
+
141
+ Try it at [crichalchemist/maninagarden](https://huggingface.co/spaces/crichalchemist/maninagarden) β€” interactive scenario explorer, custom forecasting, and experiment comparison.
142
+
143
+ ## Citation
144
+
145
+ This model implements the Phi(humanity) welfare function formalized in the detective-llm project. Key theoretical foundations:
146
+
147
+ - hooks, b. (2000). *All About Love: New Visions*. William Morrow.
148
+ - Sen, A. (1999). *Development as Freedom*. Oxford University Press.
149
+ - Fricker, M. (2007). *Epistemic Injustice*. Oxford University Press.
150
+ - Metz, T. (2007). Toward an African moral theory. *Journal of Political Philosophy*.
151
+
152
+ ## Limitations
153
+
154
+ - Trained on **synthetic data** β€” real-world calibration pending
155
+ - Phi is a **diagnostic tool**, not an optimization target (Goodhart's Law)
156
+ - 8-construct taxonomy is Western-situated; requires adaptation for diverse philosophical frameworks
157
+ - Recovery-aware floors add theoretical richness but the model has not yet been retrained to fully leverage them
training_metadata.json CHANGED
@@ -18,5 +18,6 @@
18
  "random_walk"
19
  ],
20
  "scenarios_per_type": 50,
21
- "formula_version": "2.1-recovery-floors"
 
22
  }
 
18
  "random_walk"
19
  ],
20
  "scenarios_per_type": 50,
21
+ "formula_version": "2.1-recovery-floors",
22
+ "input_size": 36
23
  }