Knowledge Lifecycle
Browse files- index.html +1 -1
- main.js +26 -18
- style.css +2 -2
index.html
CHANGED
|
@@ -126,7 +126,7 @@
|
|
| 126 |
<div class="zone z-ok" style="width:5%"></div><div class="zone z-drift" style="width:28%"></div><div class="zone z-severe" style="width:33%"></div><div class="zone z-fail" style="width:34%"></div>
|
| 127 |
<div id="g-marker" class="marker"></div>
|
| 128 |
</div>
|
| 129 |
-
<div class="gauge-ticks"><span style="left:5%">0.
|
| 130 |
</div>
|
| 131 |
|
| 132 |
<div class="gauge-block">
|
|
|
|
| 126 |
<div class="zone z-ok" style="width:5%"></div><div class="zone z-drift" style="width:28%"></div><div class="zone z-severe" style="width:33%"></div><div class="zone z-fail" style="width:34%"></div>
|
| 127 |
<div id="g-marker" class="marker"></div>
|
| 128 |
</div>
|
| 129 |
+
<div class="gauge-ticks"><span style="left:5%">0.69<br><i>50%</i></span><span style="left:33%">4.6<br><i>1%</i></span><span style="left:66%">9.2<br><i>0.01%</i></span></div>
|
| 130 |
</div>
|
| 131 |
|
| 132 |
<div class="gauge-block">
|
main.js
CHANGED
|
@@ -25,7 +25,12 @@ const PRESETS = {
|
|
| 25 |
query: "Question: Is Vioxx safe to prescribe? Answer: Vioxx is considered",
|
| 26 |
context: "Context: In September 2004, Merck voluntarily withdrew Vioxx after trials revealed increased cardiovascular risks.",
|
| 27 |
answer: " withdrawn",
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
},
|
| 30 |
monarch: {
|
| 31 |
query: "Question: Who is the current British monarch? Answer: The current British monarch is",
|
|
@@ -99,6 +104,11 @@ async function ensureModel() {
|
|
| 99 |
}
|
| 100 |
|
| 101 |
// ---------- measurement core ----------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
async function lastLogits(text) {
|
| 103 |
const inputs = await tokenizer(text);
|
| 104 |
const { logits } = await model(inputs);
|
|
@@ -120,9 +130,8 @@ function softmax(row, temperature = 1.0) {
|
|
| 120 |
/**
|
| 121 |
* Indices of the k largest probabilities, highest first.
|
| 122 |
*
|
| 123 |
-
* One pass over the vocabulary, maintaining a short sorted list.
|
| 124 |
-
*
|
| 125 |
-
* 50,257 entries at every call site; this costs one.
|
| 126 |
*/
|
| 127 |
function topK(probs, k) {
|
| 128 |
const best = []; // indices, kept sorted by descending probability
|
|
@@ -169,10 +178,9 @@ function renderBars(pPlain, pCtx, target) {
|
|
| 169 |
/**
|
| 170 |
* Plain-language account of one measurement, written from the numbers.
|
| 171 |
*
|
| 172 |
-
* The observations are additive rather than exclusive:
|
| 173 |
-
*
|
| 174 |
-
*
|
| 175 |
-
* second, which is the more interesting half.
|
| 176 |
*/
|
| 177 |
function narrative(m) {
|
| 178 |
const answerWon = m.topCtx === m.answerPiece;
|
|
@@ -207,7 +215,7 @@ function renderStagebar(m) {
|
|
| 207 |
if (m.dsync > 9.2) {
|
| 208 |
u.textContent = "Update ✗";
|
| 209 |
note.textContent = "Retrieve succeeded: the document is in the context. Update failed: the conflict was resolved in favor of stale memory.";
|
| 210 |
-
} else if (m.dsync >
|
| 211 |
u.textContent = "Update △";
|
| 212 |
note.textContent = "Retrieve succeeded. Update is partial: the document shifted the model, but the stale memory still leads.";
|
| 213 |
} else {
|
|
@@ -274,7 +282,7 @@ $("run").addEventListener("click", async () => {
|
|
| 274 |
const topCtxId = topK(pCtx, 1)[0];
|
| 275 |
|
| 276 |
let chipText, chipClass, detail;
|
| 277 |
-
if (dsync >
|
| 278 |
if (ictx < 0.05) {
|
| 279 |
chipText = "resolution failure"; chipClass = "chip-fail";
|
| 280 |
detail = "context ignored; no realistic decoding recovers the correct answer";
|
|
@@ -282,10 +290,10 @@ $("run").addEventListener("click", async () => {
|
|
| 282 |
chipText = "drift, context losing"; chipClass = "chip-fail";
|
| 283 |
detail = "context influential but losing; no realistic decoding recovers the correct answer";
|
| 284 |
}
|
| 285 |
-
} else if (dsync >
|
| 286 |
chipText = "severe drift"; chipClass = "chip-drift";
|
| 287 |
detail = "correct answer below 1% probability";
|
| 288 |
-
} else if (dsync >
|
| 289 |
chipText = "drift"; chipClass = "chip-drift";
|
| 290 |
detail = "correct answer no longer holds most of the probability mass";
|
| 291 |
} else {
|
|
@@ -293,12 +301,12 @@ $("run").addEventListener("click", async () => {
|
|
| 293 |
detail = "correct answer holds at least half the probability mass";
|
| 294 |
}
|
| 295 |
|
| 296 |
-
// Gauge markers follow the drawn zone boundaries:
|
| 297 |
-
//
|
| 298 |
-
const dPos = dsync <=
|
| 299 |
-
: dsync <=
|
| 300 |
-
: dsync <=
|
| 301 |
-
: Math.min(100, 66 + ((dsync -
|
| 302 |
const iPos = ictx <= 0.05 ? (ictx / 0.05) * 10
|
| 303 |
: ictx <= 0.5 ? 10 + ((ictx - 0.05) / 0.45) * 40
|
| 304 |
: Math.min(100, 50 + ((ictx - 0.5) / 1.5) * 50);
|
|
|
|
| 25 |
query: "Question: Is Vioxx safe to prescribe? Answer: Vioxx is considered",
|
| 26 |
context: "Context: In September 2004, Merck voluntarily withdrew Vioxx after trials revealed increased cardiovascular risks.",
|
| 27 |
answer: " withdrawn",
|
| 28 |
+
// Stated as the direction of the change rather than as the winning token.
|
| 29 |
+
// At full precision "safe" is the top answer; under the 8-bit weights this
|
| 30 |
+
// page runs, a function word takes first place. What holds in both builds
|
| 31 |
+
// is that the corrective document pushes "safe" up and leaves "withdrawn"
|
| 32 |
+
// nowhere.
|
| 33 |
+
reading: "The headline case. The withdrawal notice is in the prompt, and the model's confidence in “safe” goes up rather than down: 37.53% to 42.58% at full precision, where the paper measures 12.05 nats, far past the 9.2 failure threshold.",
|
| 34 |
},
|
| 35 |
monarch: {
|
| 36 |
query: "Question: Who is the current British monarch? Answer: The current British monarch is",
|
|
|
|
| 104 |
}
|
| 105 |
|
| 106 |
// ---------- measurement core ----------
|
| 107 |
+
|
| 108 |
+
// Regime boundaries in nats. SYNC is ln 2 exactly, the point at which the
|
| 109 |
+
// correct answer holds half the probability mass; PERCENT and FAIL are ln 100
|
| 110 |
+
// and ln 10000 to the precision they are quoted at.
|
| 111 |
+
const SYNC = Math.LN2, PERCENT = 4.6, FAIL = 9.2;
|
| 112 |
async function lastLogits(text) {
|
| 113 |
const inputs = await tokenizer(text);
|
| 114 |
const { logits } = await model(inputs);
|
|
|
|
| 130 |
/**
|
| 131 |
* Indices of the k largest probabilities, highest first.
|
| 132 |
*
|
| 133 |
+
* One pass over the vocabulary, maintaining a short sorted list. Repeated scans
|
| 134 |
+
* with an "already taken" set cost k passes over 50,257 entries per call.
|
|
|
|
| 135 |
*/
|
| 136 |
function topK(probs, k) {
|
| 137 |
const best = []; // indices, kept sorted by descending probability
|
|
|
|
| 178 |
/**
|
| 179 |
* Plain-language account of one measurement, written from the numbers.
|
| 180 |
*
|
| 181 |
+
* The observations are additive rather than exclusive: one run can be both
|
| 182 |
+
* "the document helped" and "the document strengthened the wrong answer", so
|
| 183 |
+
* they accumulate instead of branching.
|
|
|
|
| 184 |
*/
|
| 185 |
function narrative(m) {
|
| 186 |
const answerWon = m.topCtx === m.answerPiece;
|
|
|
|
| 215 |
if (m.dsync > 9.2) {
|
| 216 |
u.textContent = "Update ✗";
|
| 217 |
note.textContent = "Retrieve succeeded: the document is in the context. Update failed: the conflict was resolved in favor of stale memory.";
|
| 218 |
+
} else if (m.dsync > SYNC) {
|
| 219 |
u.textContent = "Update △";
|
| 220 |
note.textContent = "Retrieve succeeded. Update is partial: the document shifted the model, but the stale memory still leads.";
|
| 221 |
} else {
|
|
|
|
| 282 |
const topCtxId = topK(pCtx, 1)[0];
|
| 283 |
|
| 284 |
let chipText, chipClass, detail;
|
| 285 |
+
if (dsync > FAIL) {
|
| 286 |
if (ictx < 0.05) {
|
| 287 |
chipText = "resolution failure"; chipClass = "chip-fail";
|
| 288 |
detail = "context ignored; no realistic decoding recovers the correct answer";
|
|
|
|
| 290 |
chipText = "drift, context losing"; chipClass = "chip-fail";
|
| 291 |
detail = "context influential but losing; no realistic decoding recovers the correct answer";
|
| 292 |
}
|
| 293 |
+
} else if (dsync > PERCENT) {
|
| 294 |
chipText = "severe drift"; chipClass = "chip-drift";
|
| 295 |
detail = "correct answer below 1% probability";
|
| 296 |
+
} else if (dsync > SYNC) {
|
| 297 |
chipText = "drift"; chipClass = "chip-drift";
|
| 298 |
detail = "correct answer no longer holds most of the probability mass";
|
| 299 |
} else {
|
|
|
|
| 301 |
detail = "correct answer holds at least half the probability mass";
|
| 302 |
}
|
| 303 |
|
| 304 |
+
// Gauge markers follow the drawn zone boundaries: the three thresholds sit
|
| 305 |
+
// at 5% / 33% / 66% of the track, and the scale is capped at 14 nats.
|
| 306 |
+
const dPos = dsync <= SYNC ? (dsync / SYNC) * 5
|
| 307 |
+
: dsync <= PERCENT ? 5 + ((dsync - SYNC) / (PERCENT - SYNC)) * 28
|
| 308 |
+
: dsync <= FAIL ? 33 + ((dsync - PERCENT) / (FAIL - PERCENT)) * 33
|
| 309 |
+
: Math.min(100, 66 + ((dsync - FAIL) / 4.8) * 34);
|
| 310 |
const iPos = ictx <= 0.05 ? (ictx / 0.05) * 10
|
| 311 |
: ictx <= 0.5 ? 10 + ((ictx - 0.05) / 0.45) * 40
|
| 312 |
: Math.min(100, 50 + ((ictx - 0.5) / 1.5) * 50);
|
style.css
CHANGED
|
@@ -358,8 +358,8 @@ footer { margin-top: 4rem; padding-top: 2rem; }
|
|
| 358 |
.stages td:first-child { white-space: nowrap; width: 9.5rem; }
|
| 359 |
.stages td:nth-child(2) { width: 40%; }
|
| 360 |
|
| 361 |
-
/* tabs: the browser's default focus ring
|
| 362 |
-
|
| 363 |
.tab:focus { outline: none; }
|
| 364 |
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
|
| 365 |
|
|
|
|
| 358 |
.stages td:first-child { white-space: nowrap; width: 9.5rem; }
|
| 359 |
.stages td:nth-child(2) { width: 40%; }
|
| 360 |
|
| 361 |
+
/* tabs: the browser's default focus ring boxes the active tab after a mouse
|
| 362 |
+
click, so the page supplies its own focus treatment. */
|
| 363 |
.tab:focus { outline: none; }
|
| 364 |
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
|
| 365 |
|