BurnyCoder commited on
Commit
5c8344f
·
verified ·
1 Parent(s): 0707cc3

Archive the complete research tree, datasets, explorer and checkpoint receipts on Hugging Face

Browse files
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ figures/curves.png filter=lfs diff=lfs merge=lfs -text
37
+ figures/penalty-directions.png filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,10 +1,13 @@
1
  ---
2
- title: Thirdloss Explorer
3
- emoji: 🐠
4
- colorFrom: purple
5
- colorTo: pink
6
  sdk: static
7
- pinned: false
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
1
  ---
2
+ title: Third derivatives in language-model training
3
+ emoji: 📈
4
+ colorFrom: green
5
+ colorTo: blue
6
  sdk: static
7
+ app_file: index.html
8
+ short_description: Explore measured losses, paired seeds and generated text.
9
  ---
10
 
11
+ # Third derivatives in language-model training
12
+
13
+ Explore the measured training curves, held-out comparisons and complete continuations for full-weight training and adapter fine-tuning. The Space updates with each published training run or evaluation. Its downloadable JSON, figures and paper use the same raw results. [Research archive](https://huggingface.co/BurnyCoder/thirdloss-study) · [Paper](https://huggingface.co/BurnyCoder/thirdloss-study/resolve/main/research/reports/paper.pdf) · [Collection](https://huggingface.co/collections/BurnyCoder/third-derivatives-in-language-model-training-6b067fb7d5ae3eca49ebb378)
explorer.css ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ :root {
2
+ color-scheme: light;
3
+ --paper: #fbfcf8;
4
+ --ink: #263733;
5
+ --muted: #52635c;
6
+ --rule: #cdd9d0;
7
+ --teal: #006d5c;
8
+ --tint: #e8f1e9;
9
+ font: 16px/1.53 system-ui, -apple-system, "Segoe UI", sans-serif;
10
+ }
11
+ *, *::before, *::after { box-sizing: border-box; }
12
+ html { scroll-behavior: smooth; scroll-padding-top: 1.5rem; }
13
+ body { margin: 0; background: var(--paper); color: var(--ink); }
14
+ a { color: var(--teal); text-underline-offset: .22em; }
15
+ a:hover { color: #09382f; }
16
+ :focus-visible { outline: 3px solid #e28941; outline-offset: 3px; }
17
+ .skip { position: absolute; transform: translateY(-130%); background: white; padding: .6rem; z-index: 4; }
18
+ .skip:focus { transform: none; }
19
+ .rail, main, footer { width: min(1120px, calc(100% - 64px)); margin: 0 auto; }
20
+ header { border-bottom: 1px solid var(--rule); background: #f4f7f0; }
21
+ .rail { display: flex; align-items: center; gap: 2rem; min-height: 64px; }
22
+ .signature { font: italic 33px/1 Georgia, serif; color: var(--ink); text-decoration: none; }
23
+ .signature sup { font: 16px Georgia, serif; vertical-align: super; }
24
+ nav { display: flex; flex-wrap: wrap; gap: 1.5rem; }
25
+ nav a, .source { color: var(--muted); font-size: .86rem; font-weight: 560; text-decoration: none; }
26
+ nav a:hover, .source:hover { text-decoration: underline; }
27
+ .source { margin-left: auto; }
28
+ .intro { display: grid; grid-template-columns: minmax(0, 3fr) minmax(200px, 1fr); align-items: end; gap: 7%; padding: 3.6rem 0 2.2rem; }
29
+ h1, h2, h3, p { margin: 0; }
30
+ h1, h2 { font-family: Georgia, "Times New Roman", serif; font-weight: normal; }
31
+ h1 { font-size: clamp(2.5rem, 5.7vw, 4.65rem); line-height: 1.02; letter-spacing: -.055em; }
32
+ .intro p, .prose { max-width: 77ch; color: var(--muted); }
33
+ .intro p { font-size: 1.06rem; margin: 1.25rem 0 .75rem; }
34
+ .protocol, .section-title a, .method-links a, .sample-controls a { font-size: .9rem; font-weight: 600; }
35
+ .summary { border-left: 2px solid #75a290; padding-left: 1.45rem; display: grid; gap: 1.05rem; }
36
+ .summary div { display: flex; flex-direction: column; }
37
+ .summary span, .curve-tools label, .filters label, .sample-controls label { font-size: .79rem; color: var(--muted); }
38
+ .summary strong { font: 1.65rem/1.12 Georgia, serif; font-variant-numeric: tabular-nums; }
39
+ .feed { font-size: .8rem; color: var(--muted); border-block: 1px solid var(--rule); padding: .64rem 0; }
40
+ .feed::before { content: ""; display: inline-block; vertical-align: .04em; width: .5rem; height: .5rem; background: #8c9389; border-radius: 100%; margin-right: .55rem; }
41
+ .feed.live::before { background: #21855d; }
42
+ main > section:not(.intro) { margin-top: 3rem; }
43
+ .section-title { display: flex; align-items: baseline; justify-content: space-between; gap: .8rem; }
44
+ h2 { font-size: clamp(2rem, 3.8vw, 2.8rem); line-height: 1.12; letter-spacing: -.045em; }
45
+ .section-title p { font-size: .87rem; color: var(--muted); }
46
+ .filters, .curve-tools, .sample-controls { display: flex; flex-wrap: wrap; gap: 1rem; align-items: end; }
47
+ .filters { margin: 1.15rem 0; }
48
+ label { display: inline-flex; flex-direction: column; gap: .25rem; }
49
+ select { display: block; min-width: 0; max-width: 100%; padding: .5rem 1.8rem .5rem .65rem; font: inherit; font-size: .9rem; color: var(--ink); background: white; border: 1px solid #afc0b4; border-radius: 4px; }
50
+ .run-filter { min-width: 12rem; max-width: 100%; }
51
+ .curve-panel { background: white; border: 1px solid var(--rule); padding: 1.2rem 1.4rem 1rem; border-radius: 6px; }
52
+ .curve-tools { justify-content: space-between; margin-bottom: .45rem; }
53
+ .chart-frame { height: clamp(245px, 30vw, 345px); position: relative; }
54
+ #chart { display: block; width: 100%; height: 100%; }
55
+ .chart-empty { pointer-events: none; position: absolute; inset: 0; margin: auto; height: fit-content; text-align: center; padding: 1.5em; color: var(--muted); }
56
+ #point { display: block; font-size: .82rem; min-height: 1.4em; color: var(--muted); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
57
+ .legend { display: flex; flex-wrap: wrap; column-gap: 1.1rem; row-gap: .3rem; padding-top: .65rem; font-size: .8rem; }
58
+ .legend span { display: inline-flex; align-items: center; gap: .35rem; }
59
+ .legend i { width: 17px; height: 3px; }
60
+ .curve-note { margin-top: .55rem; font-size: .75rem; color: var(--muted); }
61
+ .run-ledger, .table-wrap { margin-top: 1rem; }
62
+ .run-ledger summary { cursor: pointer; color: var(--teal); font-weight: 600; }
63
+ .table-wrap { max-width: 100%; overflow-x: auto; }
64
+ table { width: 100%; border-collapse: collapse; font-size: .83rem; font-variant-numeric: tabular-nums; text-align: left; }
65
+ th, td { padding: .55rem .65rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
66
+ th { color: var(--muted); font-size: .74rem; background: #edf2eb; font-weight: 600; }
67
+ td { white-space: nowrap; }
68
+ .prose { margin: .8rem 0 1rem; }
69
+ .verdict, .prompt { padding: .85rem 1rem; border-left: 3px solid #6f9d87; background: var(--tint); }
70
+ #stats details { margin: .8rem 0; }
71
+ .sample-controls { justify-content: space-between; margin: 1rem 0; }
72
+ .sample-controls label { max-width: 100%; }
73
+ .empty { color: var(--muted); padding: .85rem 0; }
74
+ .sample-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: .7rem; }
75
+ .sample-pair article { border: 1px solid var(--rule); padding: 1rem; border-radius: 5px; background: white; }
76
+ .sample-pair article:last-child { background: #f2f7f1; }
77
+ #sample-view h3 { font: 650 .85rem/1.3 system-ui, sans-serif; color: var(--teal); margin-bottom: .42rem; }
78
+ #sample-view p { white-space: pre-wrap; overflow-wrap: anywhere; font: 1.05rem/1.5 Georgia, serif; }
79
+ .architecture { display: block; width: 100%; height: auto; background: white; border: 1px solid var(--rule); }
80
+ .method-links { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: .7rem; }
81
+ footer { display: flex; justify-content: space-between; gap: 1rem; border-top: 1px solid var(--rule); margin-top: 3rem; padding: 1rem 0 2rem; font-size: .8rem; color: var(--muted); }
82
+ .sr { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
83
+ [hidden] { display: none !important; }
84
+ @media (max-width: 650px) {
85
+ .rail, main, footer { width: calc(100% - 32px); }
86
+ .rail { gap: .8rem; min-height: 52px; }
87
+ nav { gap: .7rem; }
88
+ nav a, .source { font-size: .74rem; }
89
+ .intro { display: block; padding: 2.3rem 0 1.2rem; }
90
+ .summary { border-left: 0; border-top: 1px solid var(--rule); padding: .85rem 0 0; margin: 1.1rem 0 0; display: flex; justify-content: space-between; gap: .5rem; }
91
+ .summary span { font-size: .68rem; }
92
+ .summary strong { font-size: 1.3rem; }
93
+ .filters, .curve-tools { display: grid; gap: .6rem; }
94
+ .filters { grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr)); }
95
+ .filters label, .curve-tools label { min-width: 0; }
96
+ .run-filter { grid-column: 1 / -1; }
97
+ .curve-panel { padding: .75rem .65rem; }
98
+ .curve-tools { grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }
99
+ .sample-pair { grid-template-columns: 1fr; }
100
+ .section-title { flex-wrap: wrap; }
101
+ }
102
+ @media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
explorer.js ADDED
@@ -0,0 +1,366 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // The same read-only snapshot feeds GitHub Pages and the local training server.
2
+ // Browser APIs: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D
3
+ "use strict";
4
+ const element = id => document.getElementById(id);
5
+ const repository = document.querySelector("a.source").href;
6
+ const runDirectory = document.querySelector("a.source").dataset.runs || repository + "/tree/main/results/";
7
+ const local = ["localhost", "127.0.0.1", "[::1]"].includes(location.hostname) ||
8
+ new URL(location.href).searchParams.get("live") === "1";
9
+ const metrics = {
10
+ dev_nll: ["Development NLL", "nats / target token"], loss: ["Training NLL", "nats / target token"],
11
+ dev_accuracy: ["Development accuracy", "% correct"], accuracy: ["Training accuracy", "% correct"],
12
+ penalty: ["Weighted active penalty", "weighted loss contribution"],
13
+ raw_third: ["Third-derivative norm estimate", "squared Frobenius estimate"],
14
+ raw_trace: ["Hessian trace estimate", "signed trace estimate"],
15
+ raw_hessian_norm: ["Squared Hessian norm estimate", "squared Frobenius estimate"],
16
+ };
17
+ const axes = {tokens: "training target tokens", train_seconds: "training seconds", step: "optimizer steps"};
18
+ const numeric = value => typeof value === "number" && Number.isFinite(value);
19
+ const number = (value, digits = 3) => numeric(value) ? value.toLocaleString("en-US", {
20
+ minimumFractionDigits: digits, maximumFractionDigits: digits,
21
+ }) : "—";
22
+ const compact = value => numeric(value) ? new Intl.NumberFormat("en-US", {
23
+ notation: "compact", maximumFractionDigits: 2,
24
+ }).format(value) : "—";
25
+ const isComplete = run => ["complete", "completed", "finished", "evaluated", "success"].includes(run.status);
26
+ let study = {runs: [], stages: {}, method_names: {}, colors: {}, stage_names: {}};
27
+ let filteredRuns = [];
28
+ let sampleEntries = [];
29
+ let curves = [];
30
+ let points = [];
31
+ let inspected = -1;
32
+
33
+ function node(tag, value) {
34
+ const result = document.createElement(tag);
35
+ if (value !== undefined) result.textContent = value;
36
+ return result;
37
+ }
38
+
39
+ function options(select, choices, previous) {
40
+ const entries = choices.map(([value, name]) => {
41
+ const option = node("option", name);
42
+ option.value = value;
43
+ return option;
44
+ });
45
+ select.replaceChildren(...entries);
46
+ if (choices.some(([key]) => key === previous)) select.value = previous;
47
+ }
48
+
49
+ function methodName(method) { return study.method_names[method] || method || "—"; }
50
+ function stageName(stage) { return study.stage_names[stage] || stage; }
51
+ function methodColor(method) { return study.colors[method] || "#56665c"; }
52
+
53
+ function rebuildFilters() {
54
+ const stage = element("stage").value;
55
+ const selected = study.runs.filter(run => run.stage === stage);
56
+ const phases = [...new Set(selected.map(run => run.phase).filter(Boolean))].sort();
57
+ options(element("phase"), [["", "All phases"], ...phases.map(p => [p, p])], element("phase").value);
58
+ const phase = element("phase").value;
59
+ const inPhase = phase ? selected.filter(run => run.phase === phase) : selected;
60
+ options(element("run"), [["", "All runs"], ...inPhase.map(run => [run.id, run.id])], element("run").value);
61
+ const id = element("run").value;
62
+ filteredRuns = id ? inPhase.filter(run => run.id === id) : inPhase;
63
+ }
64
+
65
+ function showTotals() {
66
+ element("runs-count").textContent = number(study.runs.filter(isComplete).length, 0);
67
+ for (const [field, target] of [["tokens", "tokens-count"], ["train_seconds", "hours-count"]]) {
68
+ const values = study.runs.map(run => run[field]).filter(numeric);
69
+ const total = values.reduce((a, b) => a + b, 0);
70
+ element(target).textContent = values.length ? (field === "tokens" ? compact(total) : number(total / 3600, 2) + " h") : "—";
71
+ if (values.length) element(target).title = number(total, 0) + (field === "tokens" ? " training tokens" : " seconds");
72
+ }
73
+ }
74
+
75
+ function showLedger() {
76
+ const body = element("ledger");
77
+ body.replaceChildren();
78
+ for (const run of filteredRuns) {
79
+ const tr = node("tr");
80
+ const first = node("td");
81
+ const link = node("a", run.id);
82
+ link.href = runDirectory + encodeURIComponent(run.id);
83
+ first.append(link);
84
+ tr.append(first);
85
+ const evaluation = run.evaluation_progress;
86
+ const status = evaluation?.targets_to_score > 0
87
+ ? `${evaluation.split === "test" ? "scoring test" : run.status} (${number(100 * evaluation.targets_scored / evaluation.targets_to_score, 1)}%)`
88
+ : run.status;
89
+ for (const value of [methodName(run.method), run.seed ?? "—", number(run.ratio, 3),
90
+ number(run.tokens, 0), number(run.dev_nll, 4), number(run.test_nll, 4),
91
+ number(run.tokens_per_sec, 0), number(run.peak_vram_mb, 0), status]) {
92
+ tr.append(node("td", value));
93
+ }
94
+ body.append(tr);
95
+ }
96
+ element("ledger-count").textContent = "(" + filteredRuns.length + ")";
97
+ if (!filteredRuns.length) {
98
+ const cell = node("td", "Awaiting a run in this selection.");
99
+ cell.colSpan = 10;
100
+ const row = node("tr");
101
+ row.append(cell);
102
+ body.append(row);
103
+ }
104
+ }
105
+
106
+ function collectCurves() {
107
+ const metric = element("metric").value;
108
+ const axis = element("axis").value;
109
+ const percent = metric.endsWith("accuracy") ? 100 : 1;
110
+ curves = filteredRuns.map(run => {
111
+ const values = (run.events || []).filter(e => numeric(e[metric]) && numeric(e[axis]))
112
+ .map(e => ({x: e[axis], y: e[metric] * percent, run}));
113
+ return {run, values};
114
+ }).filter(series => series.values.length);
115
+ const legend = element("legend");
116
+ legend.replaceChildren();
117
+ for (const method of [...new Set(curves.map(s => s.run.method))]) {
118
+ const item = node("span");
119
+ const stroke = node("i");
120
+ stroke.style.backgroundColor = methodColor(method);
121
+ item.append(stroke, document.createTextNode(methodName(method)));
122
+ legend.append(item);
123
+ }
124
+ inspected = -1;
125
+ element("point").textContent = "";
126
+ draw();
127
+ }
128
+
129
+ function draw() {
130
+ const canvas = element("chart");
131
+ const bounds = canvas.getBoundingClientRect();
132
+ const w = Math.max(100, bounds.width);
133
+ const h = Math.max(100, bounds.height);
134
+ const scale = Math.min(window.devicePixelRatio || 1, 3);
135
+ canvas.width = Math.round(w * scale);
136
+ canvas.height = Math.round(h * scale);
137
+ const ctx = canvas.getContext("2d");
138
+ ctx.scale(scale, scale);
139
+ const frame = {left: w < 480 ? 49 : 62, right: w - 13, top: 28, bottom: h - 49};
140
+ const all = curves.flatMap(s => s.values);
141
+ points = [];
142
+ element("chart-empty").hidden = all.length > 0;
143
+ element("chart-empty").textContent = "The selected measurement will appear after its first logged observation.";
144
+ if (!all.length) return;
145
+ const metric = element("metric").value;
146
+ const axis = element("axis").value;
147
+ let low = Infinity, high = -Infinity, maxX = 0;
148
+ for (const point of all) {
149
+ low = Math.min(low, point.y);
150
+ high = Math.max(high, point.y);
151
+ maxX = Math.max(maxX, point.x);
152
+ }
153
+ if (metric.endsWith("accuracy")) {
154
+ low = 0; high = 100;
155
+ } else {
156
+ const pad = (high - low || Math.max(Math.abs(high) * .1, .01)) * .09;
157
+ low -= pad; high += pad;
158
+ if (["dev_nll", "loss", "raw_third", "raw_hessian_norm"].includes(metric)) low = Math.max(0, low);
159
+ }
160
+ maxX = maxX || 1;
161
+ const positionX = value => frame.left + (frame.right - frame.left) * value / maxX;
162
+ const positionY = value => frame.bottom - (frame.bottom - frame.top) * (value - low) / (high - low);
163
+ const tick = value => Math.abs(value) >= 10000 || (value !== 0 && Math.abs(value) < .001) ?
164
+ value.toExponential(1) : Number(value.toPrecision(4)).toLocaleString("en-US");
165
+ ctx.font = "11px system-ui, sans-serif";
166
+ ctx.lineWidth = 1;
167
+ ctx.fillStyle = "#52635c";
168
+ ctx.textAlign = "left";
169
+ ctx.fillText(metrics[metric][1], frame.left, 13);
170
+ for (let i = 0; i <= 4; i++) {
171
+ const yValue = low + (high - low) * i / 4;
172
+ const y = positionY(yValue);
173
+ ctx.strokeStyle = "#dce6de";
174
+ ctx.beginPath(); ctx.moveTo(frame.left, y); ctx.lineTo(frame.right, y); ctx.stroke();
175
+ ctx.textAlign = "right";
176
+ ctx.fillText(tick(yValue), frame.left - 7, y + 3);
177
+ const xValue = maxX * i / 4;
178
+ ctx.textAlign = i === 4 ? "right" : i === 0 ? "left" : "center";
179
+ ctx.fillText(compact(xValue), positionX(xValue), frame.bottom + 18);
180
+ }
181
+ ctx.textAlign = "center";
182
+ ctx.fillText(axes[axis], (frame.left + frame.right) / 2, h - 6);
183
+ for (const series of curves) {
184
+ const color = methodColor(series.run.method);
185
+ ctx.strokeStyle = color; ctx.fillStyle = color; ctx.lineWidth = 1.65;
186
+ ctx.globalAlpha = curves.length > 10 ? .58 : .92;
187
+ ctx.beginPath();
188
+ series.values.forEach((value, i) => {
189
+ const px = positionX(value.x), py = positionY(value.y);
190
+ points.push({...value, px, py});
191
+ if (i) ctx.lineTo(px, py); else ctx.moveTo(px, py);
192
+ });
193
+ ctx.stroke();
194
+ if (series.values.length <= 60) {
195
+ for (const value of series.values) {
196
+ ctx.beginPath(); ctx.arc(positionX(value.x), positionY(value.y), 2.4, 0, Math.PI * 2); ctx.fill();
197
+ }
198
+ }
199
+ }
200
+ ctx.globalAlpha = 1;
201
+ if (inspected >= 0 && points[inspected]) {
202
+ const p = points[inspected];
203
+ ctx.fillStyle = "white"; ctx.strokeStyle = methodColor(p.run.method); ctx.lineWidth = 2.3;
204
+ ctx.beginPath(); ctx.arc(p.px, p.py, 4.7, 0, Math.PI * 2); ctx.fill(); ctx.stroke();
205
+ element("point").textContent = p.run.id + " · " + number(p.x, axis === "train_seconds" ? 1 : 0) +
206
+ " " + axes[axis] + " · " + number(p.y, 4) + " " + metrics[metric][1];
207
+ }
208
+ }
209
+
210
+ function table(headers, rows) {
211
+ const wrapper = node("div");
212
+ wrapper.className = "table-wrap";
213
+ const result = node("table");
214
+ const head = node("thead"), top = node("tr"), body = node("tbody");
215
+ headers.forEach(title => top.append(node("th", title)));
216
+ head.append(top); result.append(head);
217
+ for (const values of rows) {
218
+ const row = node("tr");
219
+ values.forEach(value => row.append(node("td", value)));
220
+ body.append(row);
221
+ }
222
+ result.append(body); wrapper.append(result);
223
+ return wrapper;
224
+ }
225
+
226
+ function showEvidence() {
227
+ const stage = element("stage").value;
228
+ const outcome = study.stages[stage] || {};
229
+ element("evidence-stage").textContent = stageName(stage);
230
+ const verdicts = {
231
+ confirmed: "The third-order objective beat both baselines under the registered rule.",
232
+ inconclusive: "The completed stage did not establish superiority over both baselines.",
233
+ adverse: "A median paired interval favors at least one baseline.",
234
+ invalid: "The registered analysis flagged incompatible run records.",
235
+ };
236
+ element("verdict").textContent = verdicts[outcome.status] ||
237
+ "Awaiting paired test results. Full-horizon training triplets: " +
238
+ (outcome.n_complete_seeds || 0) + " of " + (outcome.n_expected_seeds || 8) + ".";
239
+ const target = element("stats");
240
+ target.replaceChildren();
241
+ const pilots = (study.pilot_comparisons || {})[stage] || [];
242
+ if (pilots.length) {
243
+ const heading = node("details");
244
+ heading.append(node("summary", "Single-seed development comparisons"));
245
+ heading.append(table(["Comparator", "Training tokens", "Third-order dev NLL", "Comparator dev NLL", "ΔNLL", "Strengths"],
246
+ pilots.map(p => [methodName(p.method), number(p.tokens, 0), number(p.third_nll, 5),
247
+ number(p.baseline_nll, 5), number(p.delta, 5), p.strength_basis])));
248
+ target.append(heading);
249
+ }
250
+ const entries = Object.entries(outcome.comparisons || {});
251
+ if (entries.length) {
252
+ target.append(table(["Comparator", "Wins / ties / losses", "Median ΔNLL", "Median interval", "Coverage", "Holm p"],
253
+ entries.map(([baseline, s]) => [methodName(baseline), [s.wins, s.ties, s.losses].join(" / "),
254
+ number(s.median_delta, 5), (s.median_ci || []).map(x => number(x, 5)).join(" to "),
255
+ number(s.ci_coverage * 100, 2) + "%", number(s.p_holm, 5)])));
256
+ const details = node("details");
257
+ details.append(node("summary", "Individual paired differences"));
258
+ details.append(table(["Comparator", "Seed", "Third-order NLL", "Comparator NLL", "ΔNLL"],
259
+ entries.flatMap(([baseline, s]) => s.pairs.map(p => [methodName(baseline), p.seed,
260
+ number(p.third_nll, 5), number(p.baseline_nll, 5), number(p.delta, 5)]))));
261
+ target.append(details);
262
+ }
263
+ if ((outcome.matched_time || []).length) {
264
+ const details = node("details");
265
+ details.append(node("summary", "Development loss at matched training time"));
266
+ details.append(table(["Seed", "Cutoff (s)", "Method", "Checkpoint (s)", "Training tokens", "Dev NLL"],
267
+ outcome.matched_time.flatMap(t => Object.entries(t.by_method || {}).filter(([, m]) => m)
268
+ .map(([name, m]) => [t.seed, number(t.cutoff_seconds, 1), methodName(name),
269
+ number(m.train_seconds, 1), number(m.tokens, 0), number(m.dev_nll, 5)]))));
270
+ target.append(details);
271
+ }
272
+ if ((outcome.matched_nonhost_time || []).length) {
273
+ const details = node("details");
274
+ details.append(node("summary", "Development loss after subtracting host derivative calls"));
275
+ details.append(table(["Seed", "Cutoff (s)", "Method", "Checkpoint (s)", "Training tokens", "Dev NLL"],
276
+ outcome.matched_nonhost_time.flatMap(t => Object.entries(t.by_method).map(([name, m]) =>
277
+ [t.seed, number(t.cutoff_seconds, 1), methodName(name), number(m.clock_seconds, 1),
278
+ number(m.tokens, 0), number(m.dev_nll, 5)]))));
279
+ target.append(details);
280
+ }
281
+ }
282
+
283
+ function showSample() {
284
+ const entry = sampleEntries.find(s => s.id === element("sample").value);
285
+ element("sample-view").hidden = !entry;
286
+ if (!entry) return;
287
+ const s = entry.sample;
288
+ element("prompt-text").textContent = s.prompt ?? "";
289
+ element("reference-text").textContent = s.reference ?? "No reference continuation was recorded for this prompt.";
290
+ element("generated-text").textContent = s.continuation ?? "";
291
+ element("raw-sample").href = repository + "/blob/main/results/" + encodeURIComponent(entry.run.id) + "/samples.jsonl";
292
+ }
293
+
294
+ function showOutputs() {
295
+ sampleEntries = filteredRuns.flatMap(run => (run.samples || []).map((sample, index) => ({
296
+ id: run.id + "/" + index, name: run.id + " · sample " + (index + 1), sample, run,
297
+ })));
298
+ const menu = element("sample");
299
+ options(menu, sampleEntries.map(s => [s.id, s.name]), menu.value);
300
+ element("sample-controls").hidden = !sampleEntries.length;
301
+ element("samples-empty").hidden = sampleEntries.length > 0;
302
+ element("samples-empty").textContent = "Awaiting an archived continuation in the selected runs.";
303
+ showSample();
304
+ }
305
+
306
+ function render() {
307
+ rebuildFilters(); showTotals(); showLedger(); collectCurves(); showEvidence(); showOutputs();
308
+ }
309
+
310
+ async function getData(url) {
311
+ const response = await fetch(url, {cache: "no-store"});
312
+ if (!response.ok) throw new Error("HTTP " + response.status);
313
+ const result = await response.json();
314
+ if (!Array.isArray(result.runs) || !result.stages) throw new Error("Unrecognized study record");
315
+ return result;
316
+ }
317
+
318
+ async function refresh() {
319
+ let live = false;
320
+ const status = element("feed-status");
321
+ try {
322
+ if (local) {
323
+ try { study = await getData("/live.json"); live = true; }
324
+ catch { study = await getData("study.json"); }
325
+ } else study = await getData("study.json");
326
+ render();
327
+ element("download-records").href = live ? "/live.json" : "study.json";
328
+ const stamp = new Date(study.generated_at);
329
+ const asOf = Number.isNaN(stamp.valueOf()) ? "time unavailable" :
330
+ stamp.toLocaleString(undefined, {dateStyle: "medium", timeStyle: "medium"});
331
+ status.textContent = (live ? "Live local metrics" : "Published results") + " · Updated " + asOf;
332
+ status.classList.toggle("live", live);
333
+ } catch (error) {
334
+ status.classList.remove("live");
335
+ status.textContent = "Ledger temporarily unavailable. " + error.message + ". Retrying automatically.";
336
+ if (!study.runs.length) render();
337
+ } finally { window.setTimeout(refresh, local ? 10000 : 60000); }
338
+ }
339
+
340
+ for (const id of ["stage", "phase", "run"]) element(id).addEventListener("change", render);
341
+ for (const id of ["axis", "metric"]) element(id).addEventListener("change", collectCurves);
342
+ element("sample").addEventListener("change", showSample);
343
+ const canvas = element("chart");
344
+ new ResizeObserver(draw).observe(element("chart").parentElement);
345
+ canvas.addEventListener("pointermove", e => {
346
+ const box = canvas.getBoundingClientRect();
347
+ const x = e.clientX - box.left, y = e.clientY - box.top;
348
+ let nearest = -1, distance = 25 * 25;
349
+ points.forEach((point, i) => {
350
+ const d = (point.px - x) ** 2 + (point.py - y) ** 2;
351
+ if (d < distance) { nearest = i; distance = d; }
352
+ });
353
+ if (nearest !== inspected) {
354
+ inspected = nearest;
355
+ if (nearest < 0) element("point").textContent = "";
356
+ draw();
357
+ }
358
+ });
359
+ canvas.addEventListener("keydown", e => {
360
+ if (points.length && ["ArrowRight", "ArrowLeft"].includes(e.key)) {
361
+ e.preventDefault();
362
+ inspected = (Math.max(0, inspected + (e.key === "ArrowRight" ? 1 : -1))) % points.length;
363
+ draw();
364
+ }
365
+ });
366
+ refresh();
figures/architecture.png ADDED
figures/curves.png ADDED

Git LFS Details

  • SHA256: 589225b1384cb7692c7febbe8eb56e5a2603a8020688feab8577fd94ce38092f
  • Pointer size: 131 Bytes
  • Size of remote file: 177 kB
figures/penalty-directions.png ADDED

Git LFS Details

  • SHA256: c0a16ca06b027e3ef397dc4f4553961c1e786af3c79cac80905bc04428282ff4
  • Pointer size: 131 Bytes
  • Size of remote file: 156 kB
index.html CHANGED
@@ -1,19 +1,110 @@
1
  <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </html>
 
1
  <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <meta name="color-scheme" content="light">
7
+ <meta name="description" content="Training curves, paired comparisons and generated text from the third-derivative language-model study.">
8
+ <title>Third derivatives in language-model training</title>
9
+ <link rel="stylesheet" href="explorer.css">
10
+ <script src="explorer.js" defer></script>
11
+ </head>
12
+ <body>
13
+ <a class="skip" href="#curves">Skip to training curves</a>
14
+ <header>
15
+ <div class="rail">
16
+ <a class="signature" href="#top" aria-label="Study overview">∂<sup>3</sup></a>
17
+ <nav aria-label="Study sections">
18
+ <a href="#curves">Training</a><a href="#evidence">Evidence</a><a href="#outputs">Outputs</a><a href="#method">Method</a>
19
+ </nav>
20
+ <a class="source" data-runs="https://huggingface.co/BurnyCoder/thirdloss-study/tree/main/research/results/" href="https://huggingface.co/BurnyCoder/thirdloss-study/tree/main/research">Repository ↗</a>
21
+ </div>
22
+ </header>
23
+ <main id="top">
24
+ <section class="intro">
25
+ <div>
26
+ <h1>Third derivatives in<br>language-model training</h1>
27
+ <p>Does penalizing changes in loss curvature improve next-token predictions? Compare ordinary training, Hessian-trace regularization, and a third-derivative penalty at equal training tokens.</p>
28
+ <a class="protocol" href="https://huggingface.co/BurnyCoder/thirdloss-study/blob/main/research/reports/preregistration.md">Read the preregistration <span aria-hidden="true">↗</span></a>
29
+ </div>
30
+ <div class="summary" aria-label="Study totals">
31
+ <div><span>Completed runs</span><strong id="runs-count">—</strong></div>
32
+ <div><span>Training tokens logged</span><strong id="tokens-count">—</strong></div>
33
+ <div><span>Recorded training time</span><strong id="hours-count">—</strong></div>
34
+ </div>
35
+ </section>
36
+ <div id="feed-status" class="feed" role="status">Loading the study ledger…</div>
37
+
38
+ <section id="curves">
39
+ <div class="section-title"><h2>Training curves</h2><p>One trajectory per run</p></div>
40
+ <div class="filters">
41
+ <label>Stage<select id="stage"><option value="stories">TinyStories</option><option value="abstracts">Research abstracts</option></select></label>
42
+ <label>Phase<select id="phase"><option value="">All phases</option></select></label>
43
+ <label class="run-filter">Run<select id="run"><option value="">All runs</option></select></label>
44
+ </div>
45
+ <div class="curve-panel">
46
+ <div class="curve-tools">
47
+ <label>Measurement<select id="metric">
48
+ <option value="dev_nll">Development NLL</option><option value="loss">Training NLL</option>
49
+ <option value="dev_accuracy">Development accuracy</option><option value="accuracy">Training accuracy</option>
50
+ <option value="penalty">Weighted active penalty</option><option value="raw_third">Third-derivative norm estimate</option>
51
+ <option value="raw_trace">Hessian trace estimate</option><option value="raw_hessian_norm">Squared Hessian norm estimate</option>
52
+ </select></label>
53
+ <label>Horizontal axis<select id="axis"><option value="tokens">Training tokens</option><option value="train_seconds">Training time</option><option value="step">Optimizer steps</option></select></label>
54
+ </div>
55
+ <div class="chart-frame">
56
+ <canvas id="chart" tabindex="0" aria-label="Training curve. Focus and use left and right arrows to inspect points."></canvas>
57
+ <p id="chart-empty" class="chart-empty" hidden></p>
58
+ </div>
59
+ <output id="point" aria-live="polite"></output>
60
+ <div id="legend" class="legend"></div>
61
+ <p class="curve-note">Development curves use fixed probe windows. Completed-run tables show full development scores. The raw run logs retain every observation.</p>
62
+ </div>
63
+ <details class="run-ledger"><summary>Run ledger <span id="ledger-count"></span></summary>
64
+ <div class="table-wrap">
65
+ <table><caption class="sr">Measurements from runs matching the filters</caption><thead><tr>
66
+ <th>Run</th><th>Method</th><th>Seed</th><th>Ratio</th><th>Tokens</th><th>Dev NLL</th><th>Test NLL</th><th>Tokens/s</th><th>Peak MiB</th><th>Status</th>
67
+ </tr></thead><tbody id="ledger"></tbody></table>
68
+ </div>
69
+ </details>
70
+ </section>
71
+
72
+ <section id="evidence">
73
+ <div class="section-title"><h2>Paired evidence</h2><p id="evidence-stage"></p></div>
74
+ <p class="prose">The registered comparison uses held-out loss at equal training tokens. A negative difference favors the third-order objective. Both baseline comparisons must pass the corrected sign tests.</p>
75
+ <div id="verdict" class="verdict"></div>
76
+ <div id="stats"></div>
77
+ </section>
78
+ <section id="outputs">
79
+ <div class="section-title"><h2>Output examples</h2><p>Fixed development prompts</p></div>
80
+ <div id="sample-controls" class="sample-controls" hidden>
81
+ <label>Archived sample<select id="sample"></select></label>
82
+ <a id="raw-sample" href="#">Raw generation ↗</a>
83
+ </div>
84
+ <p id="samples-empty" class="empty"></p>
85
+ <div id="sample-view" hidden>
86
+ <div class="prompt"><h3>Prompt</h3><p id="prompt-text"></p></div>
87
+ <div class="sample-pair">
88
+ <article><h3>Reference continuation</h3><p id="reference-text"></p></article>
89
+ <article><h3>Model continuation</h3><p id="generated-text"></p></article>
90
+ </div>
91
+ </div>
92
+ </section>
93
+ <section id="method">
94
+ <div class="section-title"><h2>Method</h2><a href="https://huggingface.co/BurnyCoder/thirdloss-study/blob/main/research/reports/paper.pdf">Read the paper ↗</a></div>
95
+ <p class="prose">Hochreiter and Schmidhuber proposed that among equally good training fits, flatter minima may generalize better. If weights can be rounded more coarsely and still fit, a good predictor can take fewer bits to describe. Here the test of generalization is how well the model predicts unseen tokens. <a href="https://people.idsia.ch/~juergen/fm/node1.html">Flat Minima (1997) ↗</a></p>
96
+ <p class="prose">The Hessian describes local loss curvature. On active updates, two independent random sign vectors estimate how quickly that curvature changes for the next-token loss of two text windows. The derivatives cover all TinyStories decoder weights or only Pythia’s trainable attention adapters, including interactions between trainable weights.</p>
97
+ <p class="prose">When moving away from a flat bottom makes curvature change faster, the third-derivative penalty can pull the weights back. A steep bowl with constant curvature receives zero penalty from this term. Whether the optimizer finds wider minima is a separate question from the measured next-token loss.</p>
98
+ <img class="architecture" src="figures/penalty-directions.png" alt="Analytic loss curves. Trace and third-derivative penalties push in opposite directions at an asymmetric minimum. They pull displaced weights back in a flat quartic and give zero update in a steep quadratic." loading="lazy">
99
+ <p class="curve-note">Circles mark the ordinary loss minima. Arrows show downhill directions for each penalty. The vertical scales vary by panel. <a href="https://huggingface.co/BurnyCoder/thirdloss-study/blob/main/research/docs/third-derivative-penalty.md#when-can-the-penalty-favor-a-wider-minimum">Worked examples and the basin-width bound ↗</a></p>
100
+ <img class="architecture" src="figures/architecture.png" alt="TinyStories full-weight training and Pythia QKV adaptation feed next-token cross-entropy, a Hessian contraction, a third derivative and the regularized objective." loading="lazy">
101
+ <div class="method-links">
102
+ <a href="https://doi.org/10.1007/BFb0086566">Derivative roughness ↗</a>
103
+ <a href="https://arxiv.org/pdf/2208.05924">Hessian baseline ↗</a>
104
+ <a href="https://arxiv.org/pdf/2004.06433">Random probe estimator ↗</a>
105
+ </div>
106
+ </section>
107
+ </main>
108
+ <footer><span>Libor “Burny” Burian</span><a id="download-records" href="study.json">Download displayed records</a></footer>
109
+ </body>
110
  </html>
study.json ADDED
The diff for this file is too large to render. See raw diff