RiverRider commited on
Commit
508f23b
·
verified ·
1 Parent(s): ec32e23

UI: add metric tooltips + glossary panel explaining each SRT number

Browse files
Files changed (1) hide show
  1. app.py +67 -9
app.py CHANGED
@@ -155,6 +155,32 @@ def _render_tokens(result, tint: str) -> str:
155
  return f"<div class='toks'>{''.join(spans)}</div>"
156
 
157
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  def _render_meter(result) -> str:
159
  steps = result.steps
160
  if not steps:
@@ -175,10 +201,15 @@ def _render_meter(result) -> str:
175
  super_frac = sum(1 for s in steps if s.regime) / n
176
  verbalized = [s for s in steps if s.roundtrip_cos is not None]
177
 
178
- def _bar(label, value, fmt, b_frac, color, unit=""):
179
  b_frac = max(0.0, min(1.0, b_frac))
 
 
 
 
 
180
  return (
181
- f"<div class='meter-row'><span>{label}</span>"
182
  f"<b style='color:{color}'>{fmt.format(value)}</b>{unit}</div>"
183
  f"<div class='bar'><div class='fill' "
184
  f"style='width:{int(b_frac * 100)}%;background:{color}'></div></div>"
@@ -186,18 +217,28 @@ def _render_meter(result) -> str:
186
 
187
  parts = [
188
  "<div class='meter'>",
189
- _bar("mean entropy", mean_e, "{:.2f}", frac, col, " nats"),
190
- f"<div class='meter-row'><span>peak entropy</span><b>{max_e:.2f}</b> nats"
 
 
 
 
191
  f" &nbsp;·&nbsp; <span>{n} tokens</span></div>",
192
  "<div class='meter-sep'></div>",
193
  # SRT divergence: how fast the metapragmatic state is moving. Bar
194
  # scaled to the run's own peak so the mean reads as a fraction of max.
195
  _bar("mean SRT divergence", mean_d, "{:.2f}",
196
- (mean_d / max_d) if max_d else 0.0, PINK),
 
 
197
  # Reflexivity r̂ is already in [0, 1].
198
- _bar("mean reflexivity r̂", mean_r, "{:.2f}", mean_r, LAVENDER),
 
 
199
  # Regime mix: share of tokens the BEN flags supercritical (bifurcating).
200
- _bar("supercritical regime", super_frac * 100, "{:.0f}", super_frac, AMBER, "%"),
 
 
201
  ]
202
 
203
  # Verbalization fidelity: mean round-trip across the verbalized slots,
@@ -208,7 +249,10 @@ def _render_meter(result) -> str:
208
  mean_fid = max(0.0, min(1.0, mean_fid))
209
  fcol = MINT if mean_fid > 0.66 else (AMBER if mean_fid > 0.33 else PINK)
210
  parts.append(_bar(f"verbalization fidelity ({len(verbalized)})",
211
- mean_fid * 100, "{:.0f}", mean_fid, fcol, "%"))
 
 
 
212
 
213
  # Per-layer divergence depth profile: average each MAH layer's divergence
214
  # across all tokens to reveal *where* in the stack the model's
@@ -216,9 +260,14 @@ def _render_meter(result) -> str:
216
  profile = _layer_profile(steps)
217
  if profile:
218
  parts.append("<div class='meter-sep'></div>")
219
- parts.append("<div class='meter-row'><span>divergence by MAH layer (depth profile)</span></div>")
 
 
 
 
220
  parts.append(_layer_bars(profile))
221
 
 
222
  parts.append("</div>")
223
  return "".join(parts)
224
 
@@ -339,6 +388,15 @@ _CSS = f"""
339
  margin: 6px 0; }}
340
  .fill {{ height: 100%; transition: width .3s ease; }}
341
  .meter-sep {{ height: 1px; background: {PANEL_ALT}; margin: 10px 0 8px; }}
 
 
 
 
 
 
 
 
 
342
  .lbars {{ display: flex; align-items: flex-end; gap: 3px; height: 60px;
343
  margin: 4px 0 2px; }}
344
  .lbar {{ flex: 1; display: flex; flex-direction: column; align-items: center;
 
155
  return f"<div class='toks'>{''.join(spans)}</div>"
156
 
157
 
158
+ _GLOSSARY_HTML = (
159
+ "<details class='glossary'><summary>What do these numbers mean?</summary>"
160
+ "<dl>"
161
+ "<dt>entropy (nats)</dt><dd>The model's uncertainty about the next token. "
162
+ "0 means it is certain; higher means more words are competing for the slot. "
163
+ "Peak entropy marks the single most uncertain moment in the answer.</dd>"
164
+ "<dt>SRT divergence</dt><dd>How fast the model's internal interpretation is "
165
+ "moving while it processes the token. High divergence = the meaning is actively "
166
+ "being revised; low = a settled reading.</dd>"
167
+ "<dt>reflexivity r&#770;</dt><dd>A 0-1 estimate of how self-referential the step "
168
+ "is: how much the model is looping back on its own representation rather than "
169
+ "simply tracking the input.</dd>"
170
+ "<dt>supercritical regime</dt><dd>The share of tokens past the bifurcation tipping "
171
+ "point, where one interpretation has won and locked in. The rest are subcritical: "
172
+ "still settling between readings.</dd>"
173
+ "<dt>verbalization fidelity</dt><dd>For the tokens where the Activation Verbalizer "
174
+ "put the hidden state into words, those words are re-encoded and compared back to "
175
+ "the original internal state. High fidelity means the readout faithfully reflects "
176
+ "what the model was representing.</dd>"
177
+ "<dt>divergence by MAH layer</dt><dd>The same divergence broken out by network "
178
+ "depth, shallow (left) to deep (right), showing where in the stack the model's "
179
+ "interpretation moves the most.</dd>"
180
+ "</dl></details>"
181
+ )
182
+
183
+
184
  def _render_meter(result) -> str:
185
  steps = result.steps
186
  if not steps:
 
201
  super_frac = sum(1 for s in steps if s.regime) / n
202
  verbalized = [s for s in steps if s.roundtrip_cos is not None]
203
 
204
+ def _bar(label, value, fmt, b_frac, color, unit="", tip=""):
205
  b_frac = max(0.0, min(1.0, b_frac))
206
+ if tip:
207
+ lab = (f"<span title=\"{html.escape(tip)}\">{label}"
208
+ f"<i class='info'>&#9432;</i></span>")
209
+ else:
210
+ lab = f"<span>{label}</span>"
211
  return (
212
+ f"<div class='meter-row'>{lab}"
213
  f"<b style='color:{color}'>{fmt.format(value)}</b>{unit}</div>"
214
  f"<div class='bar'><div class='fill' "
215
  f"style='width:{int(b_frac * 100)}%;background:{color}'></div></div>"
 
217
 
218
  parts = [
219
  "<div class='meter'>",
220
+ _bar("mean entropy", mean_e, "{:.2f}", frac, col, " nats",
221
+ tip="The model's uncertainty about the next token, in nats. "
222
+ "0 = it is sure; higher = more words are competing."),
223
+ f"<div class='meter-row'><span title=\"The single most uncertain token in "
224
+ f"the run, and how many tokens were generated.\">peak entropy<i class='info'>"
225
+ f"&#9432;</i></span><b>{max_e:.2f}</b> nats"
226
  f" &nbsp;·&nbsp; <span>{n} tokens</span></div>",
227
  "<div class='meter-sep'></div>",
228
  # SRT divergence: how fast the metapragmatic state is moving. Bar
229
  # scaled to the run's own peak so the mean reads as a fraction of max.
230
  _bar("mean SRT divergence", mean_d, "{:.2f}",
231
+ (mean_d / max_d) if max_d else 0.0, PINK,
232
+ tip="How fast the model's internal interpretation is moving as it "
233
+ "reads each token. High = meaning is being revised; low = a settled reading."),
234
  # Reflexivity r̂ is already in [0, 1].
235
+ _bar("mean reflexivity r̂", mean_r, "{:.2f}", mean_r, LAVENDER,
236
+ tip="A 0-1 estimate of how self-referential the step is: the model "
237
+ "looping on its own representation rather than just tracking the input."),
238
  # Regime mix: share of tokens the BEN flags supercritical (bifurcating).
239
+ _bar("supercritical regime", super_frac * 100, "{:.0f}", super_frac, AMBER, "%",
240
+ tip="Share of tokens past the bifurcation tipping point, where one "
241
+ "interpretation has locked in (vs subcritical: still settling)."),
242
  ]
243
 
244
  # Verbalization fidelity: mean round-trip across the verbalized slots,
 
249
  mean_fid = max(0.0, min(1.0, mean_fid))
250
  fcol = MINT if mean_fid > 0.66 else (AMBER if mean_fid > 0.33 else PINK)
251
  parts.append(_bar(f"verbalization fidelity ({len(verbalized)})",
252
+ mean_fid * 100, "{:.0f}", mean_fid, fcol, "%",
253
+ tip="For tokens where the hidden state was decoded into "
254
+ "words, those words are re-encoded and compared back to "
255
+ "the original state. High = a faithful readout."))
256
 
257
  # Per-layer divergence depth profile: average each MAH layer's divergence
258
  # across all tokens to reveal *where* in the stack the model's
 
260
  profile = _layer_profile(steps)
261
  if profile:
262
  parts.append("<div class='meter-sep'></div>")
263
+ parts.append(
264
+ "<div class='meter-row'><span title=\"The same divergence broken out by "
265
+ "network depth, shallow (left) to deep (right), showing where in the stack "
266
+ "the interpretation moves most.\">divergence by MAH layer (depth profile)"
267
+ "<i class='info'>&#9432;</i></span></div>")
268
  parts.append(_layer_bars(profile))
269
 
270
+ parts.append(_GLOSSARY_HTML)
271
  parts.append("</div>")
272
  return "".join(parts)
273
 
 
388
  margin: 6px 0; }}
389
  .fill {{ height: 100%; transition: width .3s ease; }}
390
  .meter-sep {{ height: 1px; background: {PANEL_ALT}; margin: 10px 0 8px; }}
391
+ .info {{ color: {MUTED}; font-size: 10px; margin-left: 4px; cursor: help;
392
+ font-style: normal; }}
393
+ .glossary {{ margin-top: 12px; border-top: 1px solid {PANEL_ALT}; padding-top: 8px; }}
394
+ .glossary summary {{ cursor: pointer; color: {LAVENDER}; font-size: 12px;
395
+ font-family: ui-monospace, monospace; }}
396
+ .glossary dl {{ margin: 8px 0 2px; }}
397
+ .glossary dt {{ color: {INK}; font-size: 12px; font-weight: 600; margin-top: 7px;
398
+ font-family: ui-monospace, monospace; }}
399
+ .glossary dd {{ color: {MUTED}; font-size: 12px; margin: 2px 0 0; line-height: 1.45; }}
400
  .lbars {{ display: flex; align-items: flex-end; gap: 3px; height: 60px;
401
  margin: 4px 0 2px; }}
402
  .lbar {{ flex: 1; display: flex; flex-direction: column; align-items: center;