deploy data-use extraction webgpu demo
Browse files- .gitignore +1 -0
- README.md +39 -5
- index.html +1265 -17
- lib/provenance.js +62 -0
- main.js +876 -0
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
.DS_Store
|
README.md
CHANGED
|
@@ -1,10 +1,44 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
colorTo: pink
|
| 6 |
sdk: static
|
|
|
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Data-use Extraction — WebGPU
|
| 3 |
+
colorFrom: indigo
|
| 4 |
+
colorTo: blue
|
|
|
|
| 5 |
sdk: static
|
| 6 |
+
sdk_version: 1.0.0
|
| 7 |
pinned: false
|
| 8 |
+
license: apache-2.0
|
| 9 |
+
short_description: In-browser data-use extraction on WebGPU
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Data-use Extraction — WebGPU
|
| 13 |
+
|
| 14 |
+
Fully client-side demo that extracts data mentions from research text and
|
| 15 |
+
attributes each one with provenance and usage/impact — all running locally in
|
| 16 |
+
your browser on WebGPU. No server, no uploads; nothing leaves your machine.
|
| 17 |
+
|
| 18 |
+
## Pipeline
|
| 19 |
+
|
| 20 |
+
```
|
| 21 |
+
text
|
| 22 |
+
→ span model (GLiNER) → mention spans + specificity
|
| 23 |
+
→ LFM2.5-350M multitask → provenance {producer, year, geography, acronym}
|
| 24 |
+
+ usage/impact {data_type, usage_action, impact_label, usage_summary}
|
| 25 |
+
→ verbatim filter → render
|
| 26 |
+
```
|
| 27 |
+
|
| 28 |
+
## Models
|
| 29 |
+
|
| 30 |
+
| stage | model | HF repo |
|
| 31 |
+
|---|---|---|
|
| 32 |
+
| span detection | GLiNER | [`rafmacalaba/gliner_datause_extended-onnx`](https://huggingface.co/rafmacalaba/gliner_datause_extended-onnx) |
|
| 33 |
+
| attribution | LFM2.5-350M multitask | [`rafmacalaba/lfm2.5-350M-datause-multitask-onnx`](https://huggingface.co/rafmacalaba/lfm2.5-350M-datause-multitask-onnx) |
|
| 34 |
+
|
| 35 |
+
Models download from the Hub on first load and are cached in your browser's
|
| 36 |
+
IndexedDB. Requires a WebGPU-capable browser (Chrome/Edge with WebGPU enabled).
|
| 37 |
+
|
| 38 |
+
## Run locally
|
| 39 |
+
|
| 40 |
+
```bash
|
| 41 |
+
git clone https://github.com/rafmacalaba/ai4data-playground.git
|
| 42 |
+
cd ai4data-playground/web && python3 -m http.server 8000
|
| 43 |
+
# open http://localhost:8000
|
| 44 |
+
```
|
index.html
CHANGED
|
@@ -1,19 +1,1267 @@
|
|
| 1 |
<!doctype html>
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
<title>Data-use extraction — WebGPU demo</title>
|
| 7 |
+
<script>
|
| 8 |
+
(function () {
|
| 9 |
+
try {
|
| 10 |
+
if (localStorage.getItem("datause-theme") === "dark") {
|
| 11 |
+
document.documentElement.setAttribute("data-theme", "dark");
|
| 12 |
+
}
|
| 13 |
+
} catch (e) {}
|
| 14 |
+
})();
|
| 15 |
+
</script>
|
| 16 |
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
| 17 |
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
| 18 |
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet" />
|
| 19 |
+
<style>
|
| 20 |
+
:root {
|
| 21 |
+
--bg: #eaf3fb;
|
| 22 |
+
--bg-dot: #d6dee8;
|
| 23 |
+
--grad-1: #e9f4fc;
|
| 24 |
+
--grad-2: #b9dcef;
|
| 25 |
+
--grad-3: #7cc1e8;
|
| 26 |
+
--grad-4: #009cde;
|
| 27 |
+
--grad-glow: rgba(0, 156, 222, 0.28);
|
| 28 |
+
--grad-haze: rgba(255, 255, 255, 0.65);
|
| 29 |
+
--surface: #ffffff;
|
| 30 |
+
--surface-2: #f1f5f9;
|
| 31 |
+
--surface-3: #e7eef6;
|
| 32 |
+
--text: #0f172a;
|
| 33 |
+
--text-muted: #475569;
|
| 34 |
+
--text-subtle: #64748b;
|
| 35 |
+
--border: #e2e8f0;
|
| 36 |
+
--border-strong: #cbd5e1;
|
| 37 |
+
--accent: #002244;
|
| 38 |
+
--accent-2: #009cde;
|
| 39 |
+
--accent-hover: #00172e;
|
| 40 |
+
--accent-soft: rgba(0, 156, 222, 0.10);
|
| 41 |
+
--accent-glow: rgba(0, 156, 222, 0.35);
|
| 42 |
+
--wb: #009cde;
|
| 43 |
+
--ok: #16a34a;
|
| 44 |
+
--warn: #d97706;
|
| 45 |
+
--err: #dc2626;
|
| 46 |
+
--err-soft: rgba(220, 38, 38, 0.08);
|
| 47 |
+
--btn-fg: #ffffff;
|
| 48 |
+
--log-bg: #0b1220;
|
| 49 |
+
--log-fg: #cbd5e1;
|
| 50 |
+
--cat-fur: #ede7dc;
|
| 51 |
+
--cat-fur-shadow: #d8cfbe;
|
| 52 |
+
--cat-inner: #ffc7d6;
|
| 53 |
+
--cat-eye: #1a1a1a;
|
| 54 |
+
--cat-pupil: #ede7dc;
|
| 55 |
+
--cat-nose: #ff7a8a;
|
| 56 |
+
--cat-z: #94a3b8;
|
| 57 |
+
--cat-sparkle: #009cde;
|
| 58 |
+
--na: #1d4ed8; --na-bg: #dbeafe;
|
| 59 |
+
--de: #002244; --de-bg: #e7edf5;
|
| 60 |
+
--va: #475569; --va-bg: #f1f5f9;
|
| 61 |
+
--radius: 16px;
|
| 62 |
+
--radius-sm: 10px;
|
| 63 |
+
--radius-lg: 20px;
|
| 64 |
+
--shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
|
| 65 |
+
--shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 12px 32px -16px rgba(15, 23, 42, 0.18);
|
| 66 |
+
--shadow-lg: 0 4px 6px rgba(15, 23, 42, 0.05), 0 24px 48px -20px rgba(15, 23, 42, 0.25);
|
| 67 |
+
--font: "Inter", system-ui, -apple-system, sans-serif;
|
| 68 |
+
--mono: "JetBrains Mono", ui-monospace, monospace;
|
| 69 |
+
--ease: cubic-bezier(0.22, 1, 0.36, 1);
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
[data-theme="dark"] {
|
| 73 |
+
--bg: #05080d;
|
| 74 |
+
--bg-dot: #1c2333;
|
| 75 |
+
--grad-1: #07142a;
|
| 76 |
+
--grad-2: #0e2a4f;
|
| 77 |
+
--grad-3: #155184;
|
| 78 |
+
--grad-4: #009cde;
|
| 79 |
+
--grad-glow: rgba(0, 156, 222, 0.22);
|
| 80 |
+
--grad-haze: rgba(125, 211, 252, 0.10);
|
| 81 |
+
--surface: #0c1119;
|
| 82 |
+
--surface-2: #131a23;
|
| 83 |
+
--surface-3: #1a2230;
|
| 84 |
+
--text: #f1f5f9;
|
| 85 |
+
--text-muted: #94a3b8;
|
| 86 |
+
--text-subtle: #64748b;
|
| 87 |
+
--border: #1e293b;
|
| 88 |
+
--border-strong: #334155;
|
| 89 |
+
--accent: #38bdf8;
|
| 90 |
+
--accent-2: #38bdf8;
|
| 91 |
+
--accent-hover: #7dd3fc;
|
| 92 |
+
--accent-soft: rgba(56, 189, 248, 0.12);
|
| 93 |
+
--accent-glow: rgba(56, 189, 248, 0.35);
|
| 94 |
+
--wb: #38bdf8;
|
| 95 |
+
--ok: #4ade80;
|
| 96 |
+
--warn: #fbbf24;
|
| 97 |
+
--err: #f87171;
|
| 98 |
+
--err-soft: rgba(248, 113, 113, 0.12);
|
| 99 |
+
--btn-fg: #05080d;
|
| 100 |
+
--log-bg: #020617;
|
| 101 |
+
--log-fg: #94a3b8;
|
| 102 |
+
--cat-fur: #f5ebd7;
|
| 103 |
+
--cat-fur-shadow: #d8c8a8;
|
| 104 |
+
--cat-inner: #ff9eb5;
|
| 105 |
+
--cat-eye: #0a0e0f;
|
| 106 |
+
--cat-pupil: #f5ebd7;
|
| 107 |
+
--cat-nose: #ff7a8a;
|
| 108 |
+
--cat-z: #64748b;
|
| 109 |
+
--cat-sparkle: #38bdf8;
|
| 110 |
+
--na: #93c5fd; --na-bg: rgba(59, 130, 246, 0.18);
|
| 111 |
+
--de: #cbd5e1; --de-bg: rgba(203, 213, 225, 0.10);
|
| 112 |
+
--va: #94a3b8; --va-bg: rgba(148, 163, 184, 0.15);
|
| 113 |
+
--shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
|
| 114 |
+
--shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 12px 32px -16px rgba(0, 0, 0, 0.5);
|
| 115 |
+
--shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.4), 0 24px 48px -20px rgba(0, 0, 0, 0.6);
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
*, *::before, *::after { box-sizing: border-box; }
|
| 119 |
+
html { scroll-behavior: smooth; }
|
| 120 |
+
|
| 121 |
+
body {
|
| 122 |
+
margin: 0;
|
| 123 |
+
font-family: var(--font);
|
| 124 |
+
background-color: var(--bg);
|
| 125 |
+
background-image:
|
| 126 |
+
radial-gradient(ellipse 70% 55% at 18% 12%, var(--grad-haze), transparent 62%),
|
| 127 |
+
radial-gradient(ellipse 60% 50% at 92% 88%, var(--grad-glow), transparent 70%),
|
| 128 |
+
linear-gradient(165deg, var(--grad-1) 0%, var(--grad-2) 45%, var(--grad-3) 88%, var(--grad-4) 130%);
|
| 129 |
+
background-attachment: fixed;
|
| 130 |
+
color: var(--text);
|
| 131 |
+
line-height: 1.55;
|
| 132 |
+
-webkit-font-smoothing: antialiased;
|
| 133 |
+
-moz-osx-font-smoothing: grayscale;
|
| 134 |
+
transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
.num { font-variant-numeric: tabular-nums; }
|
| 138 |
+
|
| 139 |
+
.wrap { max-width: 1200px; margin: 0 auto; padding: 1.75rem 1.5rem 4rem; }
|
| 140 |
+
|
| 141 |
+
/* Loader ---------------------------------------------------------- */
|
| 142 |
+
.loader {
|
| 143 |
+
position: fixed; inset: 0; z-index: 100;
|
| 144 |
+
background-color: var(--bg);
|
| 145 |
+
background-image:
|
| 146 |
+
radial-gradient(ellipse 70% 55% at 18% 12%, var(--grad-haze), transparent 62%),
|
| 147 |
+
radial-gradient(ellipse 60% 50% at 92% 88%, var(--grad-glow), transparent 70%),
|
| 148 |
+
linear-gradient(165deg, var(--grad-1) 0%, var(--grad-2) 45%, var(--grad-3) 88%, var(--grad-4) 130%);
|
| 149 |
+
background-attachment: fixed;
|
| 150 |
+
display: flex; align-items: center; justify-content: center;
|
| 151 |
+
transition: opacity .55s var(--ease), visibility .55s;
|
| 152 |
+
}
|
| 153 |
+
.loader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
|
| 154 |
+
.loader-inner { width: min(860px, 92vw); text-align: left; }
|
| 155 |
+
.loader-layout {
|
| 156 |
+
display: grid;
|
| 157 |
+
grid-template-columns: minmax(0, 1.15fr) minmax(200px, 0.85fr);
|
| 158 |
+
align-items: center;
|
| 159 |
+
gap: clamp(1.5rem, 5vw, 4rem);
|
| 160 |
+
}
|
| 161 |
+
.loader-copy { min-width: 0; }
|
| 162 |
+
.loader-visual {
|
| 163 |
+
display: flex;
|
| 164 |
+
align-items: center;
|
| 165 |
+
justify-content: center;
|
| 166 |
+
position: relative;
|
| 167 |
+
}
|
| 168 |
+
.cat-sculpture {
|
| 169 |
+
width: 100%;
|
| 170 |
+
max-width: 280px;
|
| 171 |
+
height: auto;
|
| 172 |
+
max-height: min(52vh, 360px);
|
| 173 |
+
filter: drop-shadow(0 16px 36px rgba(0, 0, 0, 0.42));
|
| 174 |
+
transition: transform 0.3s var(--ease);
|
| 175 |
+
}
|
| 176 |
+
.cat-sculpture:hover {
|
| 177 |
+
transform: scale(1.02) translateY(-2px);
|
| 178 |
+
}
|
| 179 |
+
.loader-brand {
|
| 180 |
+
display: inline-flex; align-items: center; gap: .7rem;
|
| 181 |
+
font-family: var(--mono); font-size: 12px; letter-spacing: .24em;
|
| 182 |
+
text-transform: uppercase; margin-bottom: 2.2rem; color: var(--text-muted);
|
| 183 |
+
}
|
| 184 |
+
.loader-brand::before {
|
| 185 |
+
content: ""; display: inline-block;
|
| 186 |
+
width: 8px; height: 8px; border-radius: 50%;
|
| 187 |
+
background: var(--accent-2); box-shadow: 0 0 14px var(--accent-glow);
|
| 188 |
+
animation: pulse 1.4s ease-in-out infinite;
|
| 189 |
+
}
|
| 190 |
+
.loader-pct {
|
| 191 |
+
font-family: var(--mono); font-size: 72px; font-weight: 500; line-height: 1;
|
| 192 |
+
color: var(--text); letter-spacing: -.03em; font-variant-numeric: tabular-nums;
|
| 193 |
+
}
|
| 194 |
+
.loader-pct i { margin-left: .12em; color: var(--text-subtle); font-size: .36em; font-style: normal; font-weight: 400; }
|
| 195 |
+
.loader-rule {
|
| 196 |
+
position: relative; width: 100%; height: 3px; margin: 20px 0 14px;
|
| 197 |
+
background: var(--surface-2); border-radius: 999px; overflow: hidden;
|
| 198 |
+
}
|
| 199 |
+
.loader-rule i {
|
| 200 |
+
position: absolute; inset: 0 auto 0 0; display: block; width: 0%;
|
| 201 |
+
background: linear-gradient(90deg, var(--accent), var(--accent-2));
|
| 202 |
+
box-shadow: 0 0 14px var(--accent-glow);
|
| 203 |
+
transition: width .3s var(--ease); border-radius: 999px;
|
| 204 |
+
}
|
| 205 |
+
.loader-status {
|
| 206 |
+
font-family: var(--mono); font-size: 12.5px; letter-spacing: .18em;
|
| 207 |
+
text-transform: uppercase; color: var(--text); font-variant-numeric: tabular-nums;
|
| 208 |
+
font-weight: 600;
|
| 209 |
+
}
|
| 210 |
+
.loader-truth { margin: 8px 0 0; color: var(--text-muted); font-family: var(--mono); font-size: 12px; letter-spacing: .02em; }
|
| 211 |
+
.loader-cta {
|
| 212 |
+
display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
|
| 213 |
+
min-width: 220px; margin-top: 2.2rem;
|
| 214 |
+
font: inherit; font-family: var(--mono); font-size: 13px; letter-spacing: .14em;
|
| 215 |
+
text-transform: uppercase; font-weight: 600;
|
| 216 |
+
color: #071512; background: var(--accent-2);
|
| 217 |
+
border: none; border-radius: var(--radius-sm);
|
| 218 |
+
padding: 0.9rem 1.5rem; cursor: pointer;
|
| 219 |
+
box-shadow: 0 0 18px var(--accent-glow);
|
| 220 |
+
transition: background .18s var(--ease), transform .06s ease, box-shadow .18s var(--ease), opacity .3s var(--ease), color .3s var(--ease);
|
| 221 |
+
}
|
| 222 |
+
.loader-cta:hover:not(:disabled) { background: var(--accent); box-shadow: 0 0 26px var(--accent-glow); }
|
| 223 |
+
.loader-cta:active:not(:disabled) { transform: translateY(1px); }
|
| 224 |
+
.loader-cta:disabled {
|
| 225 |
+
opacity: 0.35; cursor: not-allowed; box-shadow: none;
|
| 226 |
+
background: var(--surface-3); color: var(--text-subtle);
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
@keyframes pulse { 50% { opacity: 0.35; transform: scale(0.85); } }
|
| 230 |
+
|
| 231 |
+
@media (max-width: 720px) {
|
| 232 |
+
.loader-layout { grid-template-columns: 1fr; gap: 1.2rem; }
|
| 233 |
+
.loader-visual { order: -1; }
|
| 234 |
+
.cat-sculpture { max-width: 170px; max-height: 22vh; }
|
| 235 |
+
.loader-brand { margin-bottom: 1.2rem; }
|
| 236 |
+
.loader-pct { font-size: 54px; }
|
| 237 |
+
.loader-cta { margin-top: 1.4rem; width: 100%; }
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
/* Header ---------------------------------------------------------- */
|
| 241 |
+
header {
|
| 242 |
+
display: flex; align-items: center; justify-content: space-between; gap: 1.5rem;
|
| 243 |
+
margin-bottom: 1.75rem;
|
| 244 |
+
padding-bottom: 1.5rem;
|
| 245 |
+
border-bottom: 1px solid var(--border);
|
| 246 |
+
}
|
| 247 |
+
.brand { display: flex; align-items: center; gap: .9rem; min-width: 0; }
|
| 248 |
+
.brand-mark {
|
| 249 |
+
width: 42px; height: 42px; border-radius: 12px;
|
| 250 |
+
background: linear-gradient(135deg, var(--accent), var(--accent-2));
|
| 251 |
+
display: flex; align-items: center; justify-content: center;
|
| 252 |
+
color: #ffffff;
|
| 253 |
+
box-shadow: 0 6px 20px -6px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.22);
|
| 254 |
+
flex: none;
|
| 255 |
+
}
|
| 256 |
+
.brand-mark svg { width: 22px; height: 22px; }
|
| 257 |
+
.brand-text { min-width: 0; }
|
| 258 |
+
.brand-text h1 {
|
| 259 |
+
margin: 0; font-size: 0.98rem; font-weight: 700;
|
| 260 |
+
font-family: var(--mono);
|
| 261 |
+
letter-spacing: 0.16em;
|
| 262 |
+
text-transform: uppercase;
|
| 263 |
+
color: var(--text);
|
| 264 |
+
}
|
| 265 |
+
.brand-text .sub {
|
| 266 |
+
margin: 3px 0 0; color: var(--text-muted); font-size: 0.72rem;
|
| 267 |
+
font-family: var(--mono); letter-spacing: 0.08em;
|
| 268 |
+
text-transform: uppercase;
|
| 269 |
+
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
.header-actions { display: flex; align-items: center; gap: 0.6rem; flex: none; }
|
| 273 |
+
|
| 274 |
+
.icon-btn, .status-pill {
|
| 275 |
+
display: inline-flex; align-items: center; gap: 0.5rem;
|
| 276 |
+
font-size: 0.8rem; font-weight: 500; color: var(--text-muted);
|
| 277 |
+
background: var(--surface); border: 1px solid var(--border);
|
| 278 |
+
border-radius: 999px; padding: 0.45rem 0.9rem; white-space: nowrap;
|
| 279 |
+
box-shadow: var(--shadow-sm);
|
| 280 |
+
transition: color .2s var(--ease), border-color .2s var(--ease);
|
| 281 |
+
}
|
| 282 |
+
.icon-btn { cursor: pointer; font-family: var(--font); }
|
| 283 |
+
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
|
| 284 |
+
.icon-btn svg { display: block; }
|
| 285 |
+
.status-dot {
|
| 286 |
+
width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); flex: none;
|
| 287 |
+
transition: background .2s var(--ease);
|
| 288 |
+
}
|
| 289 |
+
.status-pill.ready { color: var(--text); }
|
| 290 |
+
.status-pill.ready .status-dot { background: var(--ok); box-shadow: 0 0 10px rgba(22, 163, 74, 0.4); }
|
| 291 |
+
.status-pill.err { color: var(--text); }
|
| 292 |
+
.status-pill.err .status-dot { background: var(--err); box-shadow: 0 0 10px rgba(220, 38, 38, 0.4); }
|
| 293 |
+
.status-pill.busy { color: var(--text); }
|
| 294 |
+
.status-pill.busy .status-dot { background: var(--warn); animation: pulse 1.2s ease-in-out infinite; }
|
| 295 |
+
|
| 296 |
+
/* Pipeline step indicator ----------------------------------------- */
|
| 297 |
+
.pipeline {
|
| 298 |
+
display: flex; align-items: center; gap: 0;
|
| 299 |
+
margin-bottom: 1.5rem;
|
| 300 |
+
background: var(--surface); border: 1px solid var(--border);
|
| 301 |
+
border-radius: var(--radius); box-shadow: var(--shadow-sm);
|
| 302 |
+
padding: 0.95rem 1.25rem;
|
| 303 |
+
overflow-x: auto;
|
| 304 |
+
}
|
| 305 |
+
.step { display: flex; align-items: center; gap: 0.65rem; flex: 1; min-width: 0; }
|
| 306 |
+
.step-num {
|
| 307 |
+
width: 26px; height: 26px; border-radius: 50%;
|
| 308 |
+
background: var(--surface-2); color: var(--text-muted);
|
| 309 |
+
display: flex; align-items: center; justify-content: center;
|
| 310 |
+
font-family: var(--mono); font-size: 11px; font-weight: 600;
|
| 311 |
+
border: 1.5px solid var(--border);
|
| 312 |
+
flex: none; transition: all .2s var(--ease);
|
| 313 |
+
}
|
| 314 |
+
.step-text { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; white-space: nowrap; }
|
| 315 |
+
.step-text b { color: var(--text); font-weight: 600; }
|
| 316 |
+
.step-arrow { flex: none; color: var(--text-subtle); margin: 0 0.75rem; display: flex; align-items: center; }
|
| 317 |
+
.step-arrow svg { display: block; }
|
| 318 |
+
.step.active .step-num { background: var(--accent); color: var(--btn-fg); border-color: var(--accent); box-shadow: 0 0 14px var(--accent-glow); }
|
| 319 |
+
.step.active .step-text { color: var(--text); }
|
| 320 |
+
.step.done .step-num { background: var(--ok); color: white; border-color: var(--ok); }
|
| 321 |
+
|
| 322 |
+
/* Models strip — bento tiles --------------------------------------- */
|
| 323 |
+
.models-strip {
|
| 324 |
+
display: grid;
|
| 325 |
+
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
| 326 |
+
gap: 1rem;
|
| 327 |
+
margin-bottom: 1.5rem;
|
| 328 |
+
}
|
| 329 |
+
.model-card {
|
| 330 |
+
position: relative;
|
| 331 |
+
display: flex; flex-direction: column; gap: 0.7rem;
|
| 332 |
+
background: var(--surface); border: 1px solid var(--border);
|
| 333 |
+
border-radius: var(--radius); padding: 1.15rem 1.25rem;
|
| 334 |
+
text-decoration: none; color: var(--text);
|
| 335 |
+
box-shadow: var(--shadow-sm);
|
| 336 |
+
transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
|
| 337 |
+
overflow: hidden;
|
| 338 |
+
}
|
| 339 |
+
.model-card::before {
|
| 340 |
+
content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
|
| 341 |
+
background: linear-gradient(180deg, var(--accent), var(--accent-2));
|
| 342 |
+
opacity: 0; transition: opacity .2s var(--ease);
|
| 343 |
+
}
|
| 344 |
+
.model-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
|
| 345 |
+
.model-card:hover::before { opacity: 1; }
|
| 346 |
+
.model-card-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
|
| 347 |
+
.model-card-name { display: flex; align-items: center; gap: 0.6rem; font-weight: 600; font-size: 0.95rem; min-width: 0; }
|
| 348 |
+
.model-card-name-icon {
|
| 349 |
+
width: 28px; height: 28px; border-radius: 8px;
|
| 350 |
+
background: var(--surface-2); color: var(--accent-2);
|
| 351 |
+
display: flex; align-items: center; justify-content: center; flex: none;
|
| 352 |
+
}
|
| 353 |
+
.model-role {
|
| 354 |
+
font-size: 0.62rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
|
| 355 |
+
color: var(--accent-2); background: var(--accent-soft);
|
| 356 |
+
border-radius: 999px; padding: 0.22rem 0.6rem;
|
| 357 |
+
font-family: var(--mono); flex: none;
|
| 358 |
+
}
|
| 359 |
+
.model-card-repo {
|
| 360 |
+
font-family: var(--mono); font-size: 0.74rem; color: var(--text);
|
| 361 |
+
overflow-wrap: anywhere;
|
| 362 |
+
}
|
| 363 |
+
.model-card-repo .repo-ns { color: var(--text-muted); }
|
| 364 |
+
.model-card-file {
|
| 365 |
+
font-family: var(--mono); font-size: 0.7rem; color: var(--text-muted);
|
| 366 |
+
overflow-wrap: anywhere; padding-left: 0.9rem;
|
| 367 |
+
}
|
| 368 |
+
|
| 369 |
+
/* Status bar ------------------------------------------------------- */
|
| 370 |
+
.status-bar {
|
| 371 |
+
display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
|
| 372 |
+
background: var(--surface); border: 1px solid var(--border);
|
| 373 |
+
border-radius: var(--radius); box-shadow: var(--shadow-sm);
|
| 374 |
+
padding: 0.85rem 1.1rem; margin-bottom: 1.5rem;
|
| 375 |
+
}
|
| 376 |
+
.status-bar-label {
|
| 377 |
+
font-size: 0.82rem; color: var(--text-muted); min-width: 0; flex: 1 1 240px;
|
| 378 |
+
display: flex; align-items: center; gap: .55rem;
|
| 379 |
+
}
|
| 380 |
+
.status-bar-label .label-icon { color: var(--text-subtle); flex: none; }
|
| 381 |
+
.status-bar-label b { color: var(--text); font-family: var(--mono); font-weight: 500; }
|
| 382 |
+
.status-readout {
|
| 383 |
+
flex: 1 1 280px; min-width: 0;
|
| 384 |
+
display: flex; flex-direction: column; gap: 0.5rem;
|
| 385 |
+
}
|
| 386 |
+
.status-readout-head {
|
| 387 |
+
display: flex; align-items: center; gap: 0.55rem;
|
| 388 |
+
font-family: var(--mono); font-size: 0.7rem;
|
| 389 |
+
text-transform: uppercase; letter-spacing: 0.18em;
|
| 390 |
+
color: var(--text-sub);
|
| 391 |
+
}
|
| 392 |
+
.status-readout-head .label-icon { color: var(--text-subtle); flex: none; }
|
| 393 |
+
.status-readout-head b { color: var(--text); font-weight: 500; }
|
| 394 |
+
.status-readout-pct {
|
| 395 |
+
margin-left: auto;
|
| 396 |
+
color: var(--text); font-weight: 600; font-size: 0.88rem;
|
| 397 |
+
letter-spacing: 0.04em;
|
| 398 |
+
}
|
| 399 |
+
.status-readout-rule {
|
| 400 |
+
position: relative; height: 1px; background: var(--border-strong);
|
| 401 |
+
overflow: hidden;
|
| 402 |
+
}
|
| 403 |
+
.status-readout-rule i {
|
| 404 |
+
position: absolute; inset: 0 auto 0 0; display: block; width: 0%;
|
| 405 |
+
background: linear-gradient(90deg, var(--accent), var(--accent-2));
|
| 406 |
+
box-shadow: 0 0 8px var(--accent-glow);
|
| 407 |
+
transition: width .3s var(--ease);
|
| 408 |
+
}
|
| 409 |
+
.status-readout-status {
|
| 410 |
+
font-family: var(--mono); font-size: 0.78rem;
|
| 411 |
+
color: var(--text); font-variant-numeric: tabular-nums;
|
| 412 |
+
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
| 413 |
+
}
|
| 414 |
+
|
| 415 |
+
/* Chips ----------------------------------------------------------- */
|
| 416 |
+
.chip {
|
| 417 |
+
display: inline-flex; align-items: center; gap: 0.4rem;
|
| 418 |
+
font: inherit; font-size: 0.78rem; font-weight: 500;
|
| 419 |
+
color: var(--text); background: var(--surface);
|
| 420 |
+
border: 1px solid var(--border); border-radius: 999px;
|
| 421 |
+
padding: 0.4rem 0.85rem; cursor: pointer;
|
| 422 |
+
transition: color .15s var(--ease), border-color .15s var(--ease), background .15s var(--ease);
|
| 423 |
+
font-family: var(--font);
|
| 424 |
+
}
|
| 425 |
+
.chip:hover { border-color: var(--accent-2); color: var(--accent); background: var(--accent-soft); }
|
| 426 |
+
.chip svg { display: block; }
|
| 427 |
+
.chip.ghost { background: transparent; }
|
| 428 |
+
.chip.ghost:hover { border-color: var(--accent-2); color: var(--accent); background: var(--accent-soft); }
|
| 429 |
+
|
| 430 |
+
/* Sample selector & Segmented Controls ----------------------------- */
|
| 431 |
+
.sample-controls {
|
| 432 |
+
display: flex;
|
| 433 |
+
align-items: center;
|
| 434 |
+
justify-content: space-between;
|
| 435 |
+
gap: 0.75rem;
|
| 436 |
+
flex-wrap: wrap;
|
| 437 |
+
}
|
| 438 |
+
.sample-seg {
|
| 439 |
+
display: inline-flex;
|
| 440 |
+
padding: 3px;
|
| 441 |
+
background: var(--surface-2);
|
| 442 |
+
border: 1px solid var(--border);
|
| 443 |
+
border-radius: 9px;
|
| 444 |
+
}
|
| 445 |
+
.sample-seg-btn {
|
| 446 |
+
font: inherit;
|
| 447 |
+
font-family: var(--mono);
|
| 448 |
+
font-size: 0.68rem;
|
| 449 |
+
font-weight: 600;
|
| 450 |
+
padding: 0.35rem 0.75rem;
|
| 451 |
+
border: none;
|
| 452 |
+
background: transparent;
|
| 453 |
+
color: var(--text-muted);
|
| 454 |
+
border-radius: 6px;
|
| 455 |
+
cursor: pointer;
|
| 456 |
+
transition: color .15s var(--ease), background .15s var(--ease), box-shadow .15s var(--ease);
|
| 457 |
+
letter-spacing: 0.08em;
|
| 458 |
+
text-transform: uppercase;
|
| 459 |
+
}
|
| 460 |
+
.sample-seg-btn:hover:not(.active) { color: var(--text); }
|
| 461 |
+
.sample-seg-btn.active {
|
| 462 |
+
background: var(--surface);
|
| 463 |
+
color: var(--text);
|
| 464 |
+
box-shadow: var(--shadow-sm);
|
| 465 |
+
}
|
| 466 |
+
.sample-shuffle-btn {
|
| 467 |
+
display: inline-flex;
|
| 468 |
+
align-items: center;
|
| 469 |
+
gap: 0.4rem;
|
| 470 |
+
font: inherit;
|
| 471 |
+
font-family: var(--mono);
|
| 472 |
+
font-size: 0.68rem;
|
| 473 |
+
font-weight: 600;
|
| 474 |
+
letter-spacing: 0.08em;
|
| 475 |
+
text-transform: uppercase;
|
| 476 |
+
padding: 0.35rem 0.7rem;
|
| 477 |
+
color: var(--accent-2);
|
| 478 |
+
background: var(--surface-2);
|
| 479 |
+
border: 1px solid var(--border);
|
| 480 |
+
border-radius: 7px;
|
| 481 |
+
cursor: pointer;
|
| 482 |
+
transition: all .15s var(--ease);
|
| 483 |
+
}
|
| 484 |
+
.sample-shuffle-btn:hover {
|
| 485 |
+
background: var(--accent-soft);
|
| 486 |
+
border-color: var(--accent-2);
|
| 487 |
+
color: var(--accent);
|
| 488 |
+
box-shadow: 0 0 12px var(--accent-glow);
|
| 489 |
+
}
|
| 490 |
+
.sample-shuffle-btn svg { width: 13px; height: 13px; }
|
| 491 |
+
|
| 492 |
+
.samples-group {
|
| 493 |
+
display: flex;
|
| 494 |
+
flex-wrap: wrap;
|
| 495 |
+
gap: 0.45rem;
|
| 496 |
+
margin-top: 0.15rem;
|
| 497 |
+
}
|
| 498 |
+
.samples-group[hidden] { display: none; }
|
| 499 |
+
|
| 500 |
+
.sample-chip {
|
| 501 |
+
display: inline-flex;
|
| 502 |
+
align-items: center;
|
| 503 |
+
gap: 0.4rem;
|
| 504 |
+
font: inherit;
|
| 505 |
+
font-family: var(--mono);
|
| 506 |
+
font-size: 0.72rem;
|
| 507 |
+
font-weight: 500;
|
| 508 |
+
letter-spacing: 0.02em;
|
| 509 |
+
color: var(--text-muted);
|
| 510 |
+
background: var(--surface-2);
|
| 511 |
+
border: 1px solid var(--border);
|
| 512 |
+
border-radius: 8px;
|
| 513 |
+
padding: 0.38rem 0.75rem;
|
| 514 |
+
cursor: pointer;
|
| 515 |
+
transition: all .15s var(--ease);
|
| 516 |
+
}
|
| 517 |
+
.sample-chip:hover {
|
| 518 |
+
color: var(--text);
|
| 519 |
+
border-color: var(--accent-2);
|
| 520 |
+
background: var(--accent-soft);
|
| 521 |
+
}
|
| 522 |
+
.sample-chip.active {
|
| 523 |
+
color: var(--text);
|
| 524 |
+
background: var(--surface);
|
| 525 |
+
border-color: var(--accent-2);
|
| 526 |
+
box-shadow: 0 0 12px var(--accent-glow);
|
| 527 |
+
font-weight: 600;
|
| 528 |
+
}
|
| 529 |
+
|
| 530 |
+
/* Bento main grid -------------------------------------------------- */
|
| 531 |
+
.bento {
|
| 532 |
+
display: grid;
|
| 533 |
+
grid-template-columns: 1fr 1fr;
|
| 534 |
+
gap: 1.25rem;
|
| 535 |
+
margin-bottom: 1.25rem;
|
| 536 |
+
}
|
| 537 |
+
@media (max-width: 900px) { .bento { grid-template-columns: 1fr; } }
|
| 538 |
+
|
| 539 |
+
.card {
|
| 540 |
+
background: var(--surface); border: 1px solid var(--border);
|
| 541 |
+
border-radius: var(--radius); box-shadow: var(--shadow-sm);
|
| 542 |
+
padding: 1.5rem;
|
| 543 |
+
display: flex; flex-direction: column; gap: 1rem;
|
| 544 |
+
min-width: 0;
|
| 545 |
+
}
|
| 546 |
+
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
|
| 547 |
+
.card-head h2 {
|
| 548 |
+
margin: 0; font-size: 0.7rem; font-weight: 600;
|
| 549 |
+
text-transform: uppercase; letter-spacing: 0.1em;
|
| 550 |
+
color: var(--text-muted);
|
| 551 |
+
}
|
| 552 |
+
.badge-pill {
|
| 553 |
+
font-family: var(--mono); font-size: 0.62rem; font-weight: 500;
|
| 554 |
+
color: var(--text-subtle); background: var(--surface-2);
|
| 555 |
+
padding: 0.22rem 0.55rem; border-radius: 6px;
|
| 556 |
+
letter-spacing: 0.04em; text-transform: uppercase;
|
| 557 |
+
}
|
| 558 |
+
.card-hint { margin: 0; color: var(--text-muted); font-size: 0.82rem; line-height: 1.55; }
|
| 559 |
+
|
| 560 |
+
/* Segmented toggle ------------------------------------------------ */
|
| 561 |
+
.seg-toggle {
|
| 562 |
+
display: inline-flex; padding: 3px;
|
| 563 |
+
background: var(--surface-2); border: 1px solid var(--border);
|
| 564 |
+
border-radius: 9px;
|
| 565 |
+
}
|
| 566 |
+
.seg-opt {
|
| 567 |
+
font: inherit; font-family: var(--font);
|
| 568 |
+
font-size: 0.68rem; font-weight: 600;
|
| 569 |
+
padding: 0.32rem 0.72rem; border: none; background: transparent;
|
| 570 |
+
color: var(--text-muted); border-radius: 6px; cursor: pointer;
|
| 571 |
+
transition: color .15s var(--ease), background .15s var(--ease), box-shadow .15s var(--ease);
|
| 572 |
+
letter-spacing: 0.02em;
|
| 573 |
+
}
|
| 574 |
+
.seg-opt:hover:not(:disabled) { color: var(--text); }
|
| 575 |
+
.seg-opt.active {
|
| 576 |
+
background: var(--surface); color: var(--text);
|
| 577 |
+
box-shadow: var(--shadow-sm);
|
| 578 |
+
}
|
| 579 |
+
.seg-opt:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--accent-2); }
|
| 580 |
+
.seg-opt:disabled { opacity: 0.45; cursor: not-allowed; }
|
| 581 |
+
|
| 582 |
+
/* Results panes -------------------------------------------------- */
|
| 583 |
+
.results-host { display: contents; }
|
| 584 |
+
.result-pane { display: block; }
|
| 585 |
+
.result-pane[hidden] { display: none; }
|
| 586 |
+
|
| 587 |
+
.result-json .json-meta, .result-trace .json-meta {
|
| 588 |
+
display: flex; flex-wrap: wrap; gap: 0.5rem 1rem;
|
| 589 |
+
font-family: var(--mono); font-size: 0.72rem;
|
| 590 |
+
color: var(--text-muted); margin-bottom: 0.7rem;
|
| 591 |
+
padding-bottom: 0.6rem;
|
| 592 |
+
border-bottom: 1px dashed var(--border);
|
| 593 |
+
}
|
| 594 |
+
.result-json .json-meta b, .result-trace .json-meta b { color: var(--text); font-weight: 600; }
|
| 595 |
+
.result-json pre, .result-trace pre {
|
| 596 |
+
margin: 0; padding: 1rem 1.1rem;
|
| 597 |
+
background: #0b1220; color: #cbd5e1;
|
| 598 |
+
border: 1px solid var(--border); border-radius: var(--radius-sm);
|
| 599 |
+
font-family: var(--mono); font-size: 0.78rem; line-height: 1.65;
|
| 600 |
+
white-space: pre-wrap; word-break: break-word;
|
| 601 |
+
max-height: 36rem; overflow: auto;
|
| 602 |
+
font-variant-numeric: tabular-nums;
|
| 603 |
+
tab-size: 2;
|
| 604 |
+
}
|
| 605 |
+
[data-theme="dark"] .result-json pre, [data-theme="dark"] .result-trace pre { background: #020617; }
|
| 606 |
+
.result-json .jk, .result-trace .jk { color: #7dd3fc; }
|
| 607 |
+
.result-json .js, .result-trace .js { color: #fcd34d; }
|
| 608 |
+
.result-json .jn, .result-trace .jn { color: #c4b5fd; }
|
| 609 |
+
.result-json .jb, .result-trace .jb { color: #f472b6; }
|
| 610 |
+
|
| 611 |
+
/* Pretty tree ------------------------------------------------------ */
|
| 612 |
+
.tree {
|
| 613 |
+
background: var(--surface); border: 1px solid var(--border);
|
| 614 |
+
border-left: 3px solid var(--accent-2); border-radius: var(--radius-sm);
|
| 615 |
+
padding: 0.9rem 1.1rem;
|
| 616 |
+
}
|
| 617 |
+
.tree + .tree { margin-top: 0.6rem; }
|
| 618 |
+
.tree-root { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
|
| 619 |
+
.tree-name { font-weight: 600; font-size: 0.92rem; color: var(--text); }
|
| 620 |
+
.tree-ms { color: var(--text-subtle); font-size: 0.7rem; font-family: var(--mono); margin-left: auto; }
|
| 621 |
+
.tree-body {
|
| 622 |
+
position: relative; margin: 0.4rem 0 0 0.4rem;
|
| 623 |
+
padding-left: 1.15rem; border-left: 1px solid var(--border-strong);
|
| 624 |
+
}
|
| 625 |
+
.tree-leaf {
|
| 626 |
+
position: relative; display: flex; align-items: baseline; gap: 0.45rem;
|
| 627 |
+
padding: 0.13rem 0; font-size: 0.82rem; line-height: 1.5;
|
| 628 |
+
}
|
| 629 |
+
.tree-leaf::before {
|
| 630 |
+
content: ""; position: absolute; left: -1.15rem; top: 0.75em;
|
| 631 |
+
width: 0.9rem; height: 1px; background: var(--border-strong);
|
| 632 |
+
}
|
| 633 |
+
.tree-leaf .k { color: var(--accent-2); font-weight: 600; font-family: var(--mono); font-size: 0.74rem; white-space: nowrap; }
|
| 634 |
+
.tree-leaf .arrow { color: var(--text-subtle); }
|
| 635 |
+
.tree-leaf .v { color: var(--text); }
|
| 636 |
+
.tree-group {
|
| 637 |
+
position: relative; margin: 0.15rem 0 0; padding-left: 1.15rem;
|
| 638 |
+
border-left: 1px solid var(--border-strong);
|
| 639 |
+
}
|
| 640 |
+
.tree-group::before {
|
| 641 |
+
content: ""; position: absolute; left: -1.15rem; top: 0.75em;
|
| 642 |
+
width: 0.9rem; height: 1px; background: var(--border-strong);
|
| 643 |
+
}
|
| 644 |
+
.tree-label {
|
| 645 |
+
font-weight: 600; color: var(--text-muted); font-size: 0.74rem;
|
| 646 |
+
font-family: var(--mono); letter-spacing: 0.03em; padding: 0.1rem 0;
|
| 647 |
+
}
|
| 648 |
+
.tree-slot { display: block; }
|
| 649 |
+
.tree-stream {
|
| 650 |
+
font-family: var(--mono); font-size: 0.78rem; color: var(--text-subtle);
|
| 651 |
+
padding: 0.15rem 0; font-style: italic; line-height: 1.5;
|
| 652 |
+
}
|
| 653 |
+
.tree-stream.streaming::after {
|
| 654 |
+
content: "▌"; margin-left: 2px; color: var(--accent-2);
|
| 655 |
+
animation: blink 1s steps(2) infinite;
|
| 656 |
+
}
|
| 657 |
+
.tree-none { font-size: 0.78rem; color: var(--text-subtle); font-style: italic; margin: 0.35rem 0 0 0.4rem; padding-left: 1.15rem; }
|
| 658 |
+
|
| 659 |
+
/* Samples --------------------------------------------------------- */
|
| 660 |
+
.samples-block { display: flex; flex-direction: column; gap: 0.55rem; }
|
| 661 |
+
.samples-label {
|
| 662 |
+
font-size: 0.68rem; font-weight: 600; color: var(--text-subtle);
|
| 663 |
+
text-transform: uppercase; letter-spacing: 0.08em;
|
| 664 |
+
display: flex; align-items: center; gap: 0.45rem;
|
| 665 |
+
}
|
| 666 |
+
.samples-label .count {
|
| 667 |
+
font-family: var(--mono); font-weight: 500;
|
| 668 |
+
color: var(--text-subtle); background: var(--surface-2);
|
| 669 |
+
padding: 0.05rem 0.45rem; border-radius: 999px;
|
| 670 |
+
font-size: 0.6rem; letter-spacing: 0;
|
| 671 |
+
}
|
| 672 |
+
.samples { display: flex; flex-wrap: wrap; gap: 0.4rem; }
|
| 673 |
+
|
| 674 |
+
/* Textarea -------------------------------------------------------- */
|
| 675 |
+
.textarea-wrap { position: relative; }
|
| 676 |
+
textarea {
|
| 677 |
+
width: 100%; min-height: 11rem; resize: vertical;
|
| 678 |
+
font: inherit; font-size: 0.9rem; line-height: 1.6;
|
| 679 |
+
color: var(--text); background: var(--surface-2);
|
| 680 |
+
border: 1px solid var(--border); border-radius: var(--radius-sm);
|
| 681 |
+
padding: 0.85rem 1rem;
|
| 682 |
+
transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
|
| 683 |
+
}
|
| 684 |
+
textarea::placeholder { color: var(--text-subtle); }
|
| 685 |
+
textarea:hover { border-color: var(--border-strong); }
|
| 686 |
+
textarea:focus {
|
| 687 |
+
outline: none; border-color: var(--accent-2);
|
| 688 |
+
background: var(--surface);
|
| 689 |
+
box-shadow: 0 0 0 3px var(--accent-soft);
|
| 690 |
+
}
|
| 691 |
+
|
| 692 |
+
/* Actions / CTA --------------------------------------------------- */
|
| 693 |
+
.actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
|
| 694 |
+
.actions .meta-text { font-family: var(--mono); font-size: 0.72rem; color: var(--text-subtle); }
|
| 695 |
+
.btn {
|
| 696 |
+
display: inline-flex; align-items: center; gap: 0.55rem;
|
| 697 |
+
font: inherit; font-weight: 600; font-size: 0.88rem; color: var(--btn-fg);
|
| 698 |
+
background: linear-gradient(180deg, var(--accent), var(--accent-hover));
|
| 699 |
+
border: none; border-radius: var(--radius-sm);
|
| 700 |
+
padding: 0.72rem 1.4rem; cursor: pointer;
|
| 701 |
+
transition: box-shadow .2s var(--ease);
|
| 702 |
+
box-shadow: 0 1px 2px rgba(0,0,0,.12), 0 8px 22px -8px var(--accent-glow);
|
| 703 |
+
font-family: var(--font);
|
| 704 |
+
letter-spacing: -0.005em;
|
| 705 |
+
}
|
| 706 |
+
.btn:hover:not(:disabled) { box-shadow: 0 2px 4px rgba(0,0,0,.14), 0 12px 28px -8px var(--accent-glow); }
|
| 707 |
+
.btn:active:not(:disabled) { box-shadow: 0 1px 2px rgba(0,0,0,.12), 0 4px 12px -4px var(--accent-glow); }
|
| 708 |
+
.btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
|
| 709 |
+
.btn svg { display: block; }
|
| 710 |
+
|
| 711 |
+
/* Results --------------------------------------------------------- */
|
| 712 |
+
#results { min-height: 14rem; }
|
| 713 |
+
.empty {
|
| 714 |
+
display: flex; flex-direction: column; align-items: center; justify-content: center;
|
| 715 |
+
gap: 0.7rem; padding: 2.5rem 1rem;
|
| 716 |
+
color: var(--text-muted); text-align: center;
|
| 717 |
+
}
|
| 718 |
+
.empty .empty-icon { width: 42px; height: 42px; color: var(--text-subtle); opacity: 0.7; }
|
| 719 |
+
.empty .empty-title { font-size: 0.9rem; font-weight: 600; color: var(--text-muted); }
|
| 720 |
+
.empty .empty-sub { font-size: 0.78rem; color: var(--text-subtle); max-width: 32ch; line-height: 1.5; }
|
| 721 |
+
|
| 722 |
+
/* Perf stats ------------------------------------------------------- */
|
| 723 |
+
.perf {
|
| 724 |
+
display: flex; flex-wrap: wrap; gap: 0.5rem 0.9rem; align-items: center;
|
| 725 |
+
background: var(--surface-2); border: 1px solid var(--border);
|
| 726 |
+
border-radius: var(--radius-sm); padding: 0.65rem 0.95rem;
|
| 727 |
+
}
|
| 728 |
+
.perf-stat {
|
| 729 |
+
display: inline-flex; align-items: center; gap: 0.4rem;
|
| 730 |
+
color: var(--text-muted); font-family: var(--mono); font-size: 0.72rem;
|
| 731 |
+
}
|
| 732 |
+
.perf-stat b {
|
| 733 |
+
color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums;
|
| 734 |
+
}
|
| 735 |
+
.perf-stat .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--text-subtle); }
|
| 736 |
+
/* Legacy .stat class — emitted by main.js inline HTML, kept for compat. */
|
| 737 |
+
.perf .stat { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--text-muted); font-family: var(--mono); font-size: 0.72rem; }
|
| 738 |
+
.perf .stat b { color: var(--accent); font-family: var(--mono); font-weight: 700; font-variant-numeric: tabular-nums; }
|
| 739 |
+
|
| 740 |
+
/* Mention card ----------------------------------------------------- */
|
| 741 |
+
.mention-list { display: flex; flex-direction: column; gap: 0.6rem; }
|
| 742 |
+
.mention {
|
| 743 |
+
display: flex; flex-direction: column; gap: 0.55rem;
|
| 744 |
+
padding: 1rem 1.1rem;
|
| 745 |
+
background: var(--surface); border: 1px solid var(--border);
|
| 746 |
+
border-left: 3px solid var(--accent-2);
|
| 747 |
+
border-radius: var(--radius-sm);
|
| 748 |
+
transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
|
| 749 |
+
}
|
| 750 |
+
.mention:hover { box-shadow: var(--shadow-sm); }
|
| 751 |
+
.mention .head { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
|
| 752 |
+
.mention .name { font-weight: 600; font-size: 0.92rem; color: var(--text); }
|
| 753 |
+
.mention .ms { color: var(--text-subtle); font-size: 0.7rem; font-family: var(--mono); margin-left: auto; }
|
| 754 |
+
.mention .attr {
|
| 755 |
+
font-family: var(--mono); font-size: 0.8rem; color: var(--text);
|
| 756 |
+
padding: 0.55rem 0.75rem;
|
| 757 |
+
background: var(--surface-2); border-radius: 6px;
|
| 758 |
+
line-height: 1.65;
|
| 759 |
+
}
|
| 760 |
+
.mention .attr .k { color: var(--accent-2); font-weight: 600; }
|
| 761 |
+
.mention .attr .v { color: var(--text); }
|
| 762 |
+
.mention .attr .v.miss { color: var(--text-subtle); font-style: italic; }
|
| 763 |
+
.mention .attr.streaming::after {
|
| 764 |
+
content: "▌"; margin-left: 2px;
|
| 765 |
+
animation: blink 1s steps(2) infinite;
|
| 766 |
+
color: var(--accent-2);
|
| 767 |
+
}
|
| 768 |
+
@keyframes blink { 50% { opacity: 0; } }
|
| 769 |
+
|
| 770 |
+
.mention-summary {
|
| 771 |
+
font-size: 0.85rem; color: var(--text); line-height: 1.55;
|
| 772 |
+
padding: 0.6rem 0.8rem;
|
| 773 |
+
background: var(--surface-2); border-radius: 6px;
|
| 774 |
+
border-left: 2px solid var(--border-strong);
|
| 775 |
+
}
|
| 776 |
+
|
| 777 |
+
/* Badges ----------------------------------------------------------- */
|
| 778 |
+
.badge {
|
| 779 |
+
font-size: 0.6rem; font-weight: 700; letter-spacing: 0.06em;
|
| 780 |
+
text-transform: uppercase; border-radius: 6px; padding: 0.2rem 0.55rem;
|
| 781 |
+
font-family: var(--mono);
|
| 782 |
+
}
|
| 783 |
+
.badge-NAMED_DATA { background: var(--na-bg); color: var(--na); }
|
| 784 |
+
.badge-DESCRIPTIVE_DATA { background: var(--de-bg); color: var(--de); }
|
| 785 |
+
.badge-VAGUE_DATA { background: var(--va-bg); color: var(--va); }
|
| 786 |
+
|
| 787 |
+
/* Details / log ---------------------------------------------------- */
|
| 788 |
+
details.log-wrap, details.models-wrap {
|
| 789 |
+
margin-top: 1rem;
|
| 790 |
+
background: var(--surface); border: 1px solid var(--border);
|
| 791 |
+
border-radius: var(--radius);
|
| 792 |
+
box-shadow: var(--shadow-sm);
|
| 793 |
+
overflow: hidden;
|
| 794 |
+
}
|
| 795 |
+
details > summary {
|
| 796 |
+
cursor: pointer; font-size: 0.7rem; font-weight: 600;
|
| 797 |
+
color: var(--text-muted);
|
| 798 |
+
text-transform: uppercase; letter-spacing: 0.1em;
|
| 799 |
+
padding: 0.95rem 1.25rem;
|
| 800 |
+
user-select: none; list-style: none;
|
| 801 |
+
display: flex; align-items: center; gap: 0.6rem;
|
| 802 |
+
transition: background .15s var(--ease), color .15s var(--ease);
|
| 803 |
+
}
|
| 804 |
+
details > summary::-webkit-details-marker { display: none; }
|
| 805 |
+
details > summary::before {
|
| 806 |
+
content: ""; width: 6px; height: 6px;
|
| 807 |
+
border-right: 1.5px solid currentColor;
|
| 808 |
+
border-bottom: 1.5px solid currentColor;
|
| 809 |
+
transform: rotate(-45deg); transition: transform .2s var(--ease);
|
| 810 |
+
display: inline-block;
|
| 811 |
+
}
|
| 812 |
+
details[open] > summary::before { transform: rotate(45deg); }
|
| 813 |
+
details > summary:hover { background: var(--surface-2); color: var(--text); }
|
| 814 |
+
.summary-body { padding: 0 1.25rem 1.25rem; }
|
| 815 |
+
|
| 816 |
+
#log {
|
| 817 |
+
background: var(--log-bg); color: var(--log-fg);
|
| 818 |
+
border: 1px solid var(--border);
|
| 819 |
+
border-radius: var(--radius-sm);
|
| 820 |
+
padding: 0.9rem 1rem;
|
| 821 |
+
font-family: var(--mono); font-size: 0.74rem; line-height: 1.65;
|
| 822 |
+
max-height: 16rem; overflow-y: auto; white-space: pre-wrap;
|
| 823 |
+
font-variant-numeric: tabular-nums;
|
| 824 |
+
}
|
| 825 |
+
#log .ok { color: var(--ok); }
|
| 826 |
+
#log .warn { color: var(--warn); }
|
| 827 |
+
#log .err { color: var(--err); }
|
| 828 |
+
|
| 829 |
+
#models-info { display: grid; gap: 1rem; }
|
| 830 |
+
.info-card {
|
| 831 |
+
background: var(--surface-2); border: 1px solid var(--border);
|
| 832 |
+
border-radius: var(--radius-sm); padding: 1rem 1.2rem;
|
| 833 |
+
}
|
| 834 |
+
.info-card h3 {
|
| 835 |
+
margin: 0 0 0.35rem; font-size: 0.9rem;
|
| 836 |
+
display: flex; align-items: center; gap: 0.5rem;
|
| 837 |
+
}
|
| 838 |
+
.info-card h3 a { color: var(--accent-2); text-decoration: none; }
|
| 839 |
+
.info-card h3 a:hover { text-decoration: underline; }
|
| 840 |
+
.info-card h3 svg { color: var(--text-subtle); flex: none; }
|
| 841 |
+
.info-card .task { color: var(--text-muted); font-size: 0.82rem; margin: 0 0 0.65rem; line-height: 1.55; }
|
| 842 |
+
.info-card .meta {
|
| 843 |
+
font-size: 0.76rem; color: var(--text-muted);
|
| 844 |
+
font-family: var(--mono); white-space: pre-wrap; line-height: 1.6;
|
| 845 |
+
}
|
| 846 |
+
|
| 847 |
+
/* Focus rings ------------------------------------------------------ */
|
| 848 |
+
.icon-btn:focus-visible,
|
| 849 |
+
.btn:focus-visible,
|
| 850 |
+
.chip:focus-visible,
|
| 851 |
+
textarea:focus-visible,
|
| 852 |
+
details > summary:focus-visible {
|
| 853 |
+
outline: none;
|
| 854 |
+
box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 1px var(--accent-2);
|
| 855 |
+
}
|
| 856 |
+
|
| 857 |
+
/* Reduced motion --------------------------------------------------- */
|
| 858 |
+
@media (prefers-reduced-motion: reduce) {
|
| 859 |
+
*, *::before, *::after {
|
| 860 |
+
animation-duration: 0.001ms !important;
|
| 861 |
+
animation-iteration-count: 1 !important;
|
| 862 |
+
transition-duration: 0.001ms !important;
|
| 863 |
+
}
|
| 864 |
+
}
|
| 865 |
+
|
| 866 |
+
/* Responsive ------------------------------------------------------- */
|
| 867 |
+
@media (max-width: 640px) {
|
| 868 |
+
.wrap { padding: 1.1rem 1rem 3rem; }
|
| 869 |
+
header { flex-direction: column; align-items: stretch; gap: 1rem; padding-bottom: 1rem; }
|
| 870 |
+
.header-actions { justify-content: space-between; }
|
| 871 |
+
.brand-text .sub { font-size: 0.7rem; }
|
| 872 |
+
.pipeline { padding: 0.75rem 1rem; }
|
| 873 |
+
.step-text { font-size: 0.7rem; }
|
| 874 |
+
.step-arrow { margin: 0 0.5rem; }
|
| 875 |
+
.step-arrow svg { width: 12px; height: 12px; }
|
| 876 |
+
.models-strip { grid-template-columns: 1fr; }
|
| 877 |
+
.card { padding: 1.2rem; }
|
| 878 |
+
.loader-pct { font-size: 56px; }
|
| 879 |
+
}
|
| 880 |
+
</style>
|
| 881 |
+
</head>
|
| 882 |
+
<body>
|
| 883 |
+
<div class="loader" id="loader" data-state="sleeping">
|
| 884 |
+
<div class="loader-inner">
|
| 885 |
+
<div class="loader-layout">
|
| 886 |
+
<div class="loader-copy">
|
| 887 |
+
<div class="loader-brand">Data-use extraction · WebGPU</div>
|
| 888 |
+
|
| 889 |
+
<div class="loader-pct num"><span id="loader-pct">0</span><i>%</i></div>
|
| 890 |
+
<div class="loader-rule"><i id="loader-rule-fill"></i></div>
|
| 891 |
+
<div class="loader-status" id="loader-status">Initialising</div>
|
| 892 |
+
<div class="loader-truth" id="loader-truth">Loading models…</div>
|
| 893 |
+
|
| 894 |
+
<button class="loader-cta" id="loader-cta" type="button" disabled>Get started</button>
|
| 895 |
+
</div>
|
| 896 |
+
|
| 897 |
+
<div class="loader-visual">
|
| 898 |
+
<svg class="cat-sculpture" viewBox="0 0 240 320" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
| 899 |
+
<defs>
|
| 900 |
+
<filter id="cat-glow" x="-20%" y="-20%" width="140%" height="140%">
|
| 901 |
+
<feGaussianBlur stdDeviation="3.5" result="blur" />
|
| 902 |
+
<feMerge>
|
| 903 |
+
<feMergeNode in="blur" />
|
| 904 |
+
<feMergeNode in="SourceGraphic" />
|
| 905 |
+
</feMerge>
|
| 906 |
+
</filter>
|
| 907 |
+
<linearGradient id="cat-laser" x1="0" y1="0" x2="1" y2="0">
|
| 908 |
+
<stop offset="0%" stop-color="#7cf0de" stop-opacity="0" />
|
| 909 |
+
<stop offset="25%" stop-color="#7cf0de" stop-opacity="0.9" />
|
| 910 |
+
<stop offset="50%" stop-color="#ebfffa" stop-opacity="1" />
|
| 911 |
+
<stop offset="75%" stop-color="#7cf0de" stop-opacity="0.9" />
|
| 912 |
+
<stop offset="100%" stop-color="#7cf0de" stop-opacity="0" />
|
| 913 |
+
</linearGradient>
|
| 914 |
+
<clipPath id="cat-fill-clip">
|
| 915 |
+
<rect id="cat-fill-rect" x="0" y="320" width="240" height="320" />
|
| 916 |
+
</clipPath>
|
| 917 |
+
</defs>
|
| 918 |
+
|
| 919 |
+
<!-- Base Obsidian Low-Poly Facets -->
|
| 920 |
+
<g class="cat-base" stroke="#0e1318" stroke-width="0.8" stroke-linejoin="round">
|
| 921 |
+
<!-- Crown & Ears -->
|
| 922 |
+
<polygon points="120,54 98,28 108,68" fill="#1b2028" />
|
| 923 |
+
<polygon points="120,54 108,68 116,78" fill="#242b36" />
|
| 924 |
+
<polygon points="120,54 116,78 128,78" fill="#2d3542" />
|
| 925 |
+
<polygon points="120,54 128,78 138,66" fill="#28303c" />
|
| 926 |
+
<polygon points="120,54 138,66 148,34" fill="#1f252f" />
|
| 927 |
+
<polygon points="148,34 138,66 156,72" fill="#161b22" />
|
| 928 |
+
<polygon points="98,28 108,68 88,66" fill="#14181f" />
|
| 929 |
+
|
| 930 |
+
<!-- Forehead & Eyes -->
|
| 931 |
+
<polygon points="116,78 128,78 122,96" fill="#323b49" />
|
| 932 |
+
<polygon points="108,68 116,78 102,92" fill="#28303c" />
|
| 933 |
+
<polygon points="116,78 122,96 102,92" fill="#364050" />
|
| 934 |
+
<polygon points="128,78 138,66 142,88" fill="#202631" />
|
| 935 |
+
<polygon points="128,78 142,88 122,96" fill="#2a323f" />
|
| 936 |
+
<polygon points="102,92 122,96 118,110" fill="#3c4758" />
|
| 937 |
+
<polygon points="122,96 142,88 132,108" fill="#242b36" />
|
| 938 |
+
<polygon points="122,96 132,108 118,110" fill="#2e3745" />
|
| 939 |
+
|
| 940 |
+
<!-- Muzzle & Chin -->
|
| 941 |
+
<polygon points="102,92 118,110 96,116" fill="#262d38" />
|
| 942 |
+
<polygon points="118,110 126,122 114,130" fill="#343e4e" />
|
| 943 |
+
<polygon points="118,110 132,108 126,122" fill="#2b3340" />
|
| 944 |
+
<polygon points="132,108 144,118 126,122" fill="#1d222b" />
|
| 945 |
+
<polygon points="114,130 126,122 120,138" fill="#3a4555" />
|
| 946 |
+
<polygon points="96,116 114,130 102,142" fill="#202630" />
|
| 947 |
+
|
| 948 |
+
<!-- Neck & Throat -->
|
| 949 |
+
<polygon points="114,130 120,138 116,162" fill="#323c4a" />
|
| 950 |
+
<polygon points="102,142 114,130 116,162" fill="#272e3a" />
|
| 951 |
+
<polygon points="120,138 136,148 116,162" fill="#232a35" />
|
| 952 |
+
<polygon points="126,122 144,118 136,148" fill="#1a1f27" />
|
| 953 |
+
<polygon points="102,142 116,162 94,172" fill="#1e242e" />
|
| 954 |
+
<polygon points="88,66 102,92 84,106" fill="#12161c" />
|
| 955 |
+
<polygon points="84,106 96,116 78,138" fill="#10141a" />
|
| 956 |
+
<polygon points="78,138 102,142 94,172" fill="#151920" />
|
| 957 |
+
<polygon points="78,138 94,172 72,176" fill="#0f1217" />
|
| 958 |
+
|
| 959 |
+
<!-- Chest & Front Shoulders -->
|
| 960 |
+
<polygon points="116,162 128,190 108,198" fill="#343e4e" />
|
| 961 |
+
<polygon points="116,162 136,148 128,190" fill="#262d39" />
|
| 962 |
+
<polygon points="94,172 116,162 108,198" fill="#2a323f" />
|
| 963 |
+
<polygon points="94,172 108,198 88,206" fill="#1d222b" />
|
| 964 |
+
<polygon points="72,176 94,172 88,206" fill="#14181f" />
|
| 965 |
+
<polygon points="128,190 146,182 138,214" fill="#1b2028" />
|
| 966 |
+
<polygon points="136,148 146,182 128,190" fill="#1e232c" />
|
| 967 |
+
|
| 968 |
+
<!-- Straight Forelegs -->
|
| 969 |
+
<polygon points="108,198 128,190 120,230" fill="#384252" />
|
| 970 |
+
<polygon points="108,198 120,230 104,234" fill="#2b3340" />
|
| 971 |
+
<polygon points="88,206 108,198 104,234" fill="#202630" />
|
| 972 |
+
<polygon points="120,230 128,190 138,214" fill="#242b36" />
|
| 973 |
+
<polygon points="120,230 138,214 132,248" fill="#202631" />
|
| 974 |
+
<polygon points="104,234 120,230 114,272" fill="#323c4a" />
|
| 975 |
+
<polygon points="120,230 132,248 126,274" fill="#262d38" />
|
| 976 |
+
<polygon points="104,234 114,272 100,274" fill="#222832" />
|
| 977 |
+
<polygon points="114,272 126,274 122,306" fill="#2d3644" />
|
| 978 |
+
<polygon points="100,274 114,272 108,306" fill="#242b35" />
|
| 979 |
+
<polygon points="126,274 138,272 134,306" fill="#1a1f27" />
|
| 980 |
+
|
| 981 |
+
<!-- Seated Hindquarters (Haunches & Back) -->
|
| 982 |
+
<polygon points="72,176 88,206 64,216" fill="#12151b" />
|
| 983 |
+
<polygon points="64,216 88,206 78,246" fill="#161b22" />
|
| 984 |
+
<polygon points="64,216 78,246 52,254" fill="#0f1217" />
|
| 985 |
+
<polygon points="88,206 104,234 78,246" fill="#1b2029" />
|
| 986 |
+
<polygon points="78,246 104,234 92,268" fill="#1f252f" />
|
| 987 |
+
<polygon points="52,254 78,246 62,284" fill="#11151b" />
|
| 988 |
+
<polygon points="78,246 92,268 76,288" fill="#181d24" />
|
| 989 |
+
<polygon points="62,284 76,288 68,306" fill="#14181f" />
|
| 990 |
+
<polygon points="76,288 92,268 86,306" fill="#1c222b" />
|
| 991 |
+
<polygon points="92,268 100,274 108,306" fill="#222833" />
|
| 992 |
+
<polygon points="92,268 108,306 86,306" fill="#1e242d" />
|
| 993 |
+
|
| 994 |
+
<!-- Tail along floor -->
|
| 995 |
+
<polygon points="52,254 62,284 38,288" fill="#0d1014" />
|
| 996 |
+
<polygon points="38,288 62,284 48,304" fill="#11141a" />
|
| 997 |
+
<polygon points="38,288 48,304 24,302" fill="#0e1116" />
|
| 998 |
+
<polygon points="24,302 48,304 32,310" fill="#13171e" />
|
| 999 |
+
<polygon points="24,302 32,310 16,304" fill="#0b0e12" />
|
| 1000 |
+
</g>
|
| 1001 |
+
|
| 1002 |
+
<!-- Overlaid Glowing Energy Layer (clipped dynamically) -->
|
| 1003 |
+
<g clip-path="url(#cat-fill-clip)">
|
| 1004 |
+
<!-- Glowing Facets -->
|
| 1005 |
+
<g stroke="#7cf0de" stroke-width="1.2" stroke-linejoin="round" opacity="0.92">
|
| 1006 |
+
<polygon points="120,54 98,28 108,68" fill="#7cf0de" fill-opacity="0.28" />
|
| 1007 |
+
<polygon points="120,54 108,68 116,78" fill="#7cf0de" fill-opacity="0.38" />
|
| 1008 |
+
<polygon points="120,54 116,78 128,78" fill="#ebfffa" fill-opacity="0.45" />
|
| 1009 |
+
<polygon points="120,54 128,78 138,66" fill="#7cf0de" fill-opacity="0.35" />
|
| 1010 |
+
<polygon points="120,54 138,66 148,34" fill="#7cf0de" fill-opacity="0.25" />
|
| 1011 |
+
<polygon points="148,34 138,66 156,72" fill="#38bdf8" fill-opacity="0.22" />
|
| 1012 |
+
<polygon points="98,28 108,68 88,66" fill="#38bdf8" fill-opacity="0.22" />
|
| 1013 |
+
<polygon points="116,78 128,78 122,96" fill="#ebfffa" fill-opacity="0.52" />
|
| 1014 |
+
<polygon points="108,68 116,78 102,92" fill="#7cf0de" fill-opacity="0.36" />
|
| 1015 |
+
<polygon points="116,78 122,96 102,92" fill="#7cf0de" fill-opacity="0.48" />
|
| 1016 |
+
<polygon points="128,78 142,88 122,96" fill="#7cf0de" fill-opacity="0.4" />
|
| 1017 |
+
<polygon points="102,92 122,96 118,110" fill="#ebfffa" fill-opacity="0.55" />
|
| 1018 |
+
<polygon points="122,96 132,108 118,110" fill="#7cf0de" fill-opacity="0.42" />
|
| 1019 |
+
<polygon points="102,92 118,110 96,116" fill="#38bdf8" fill-opacity="0.32" />
|
| 1020 |
+
<polygon points="118,110 126,122 114,130" fill="#ebfffa" fill-opacity="0.5" />
|
| 1021 |
+
<polygon points="118,110 132,108 126,122" fill="#7cf0de" fill-opacity="0.38" />
|
| 1022 |
+
<polygon points="114,130 126,122 120,138" fill="#7cf0de" fill-opacity="0.5" />
|
| 1023 |
+
<polygon points="96,116 114,130 102,142" fill="#38bdf8" fill-opacity="0.3" />
|
| 1024 |
+
<polygon points="114,130 120,138 116,162" fill="#7cf0de" fill-opacity="0.46" />
|
| 1025 |
+
<polygon points="102,142 114,130 116,162" fill="#7cf0de" fill-opacity="0.38" />
|
| 1026 |
+
<polygon points="120,138 136,148 116,162" fill="#38bdf8" fill-opacity="0.32" />
|
| 1027 |
+
<polygon points="102,142 116,162 94,172" fill="#38bdf8" fill-opacity="0.28" />
|
| 1028 |
+
<polygon points="78,138 102,142 94,172" fill="#0284c7" fill-opacity="0.24" />
|
| 1029 |
+
<polygon points="116,162 128,190 108,198" fill="#ebfffa" fill-opacity="0.5" />
|
| 1030 |
+
<polygon points="116,162 136,148 128,190" fill="#7cf0de" fill-opacity="0.36" />
|
| 1031 |
+
<polygon points="94,172 116,162 108,198" fill="#7cf0de" fill-opacity="0.42" />
|
| 1032 |
+
<polygon points="94,172 108,198 88,206" fill="#38bdf8" fill-opacity="0.3" />
|
| 1033 |
+
<polygon points="108,198 128,190 120,230" fill="#ebfffa" fill-opacity="0.52" />
|
| 1034 |
+
<polygon points="108,198 120,230 104,234" fill="#7cf0de" fill-opacity="0.4" />
|
| 1035 |
+
<polygon points="120,230 128,190 138,214" fill="#7cf0de" fill-opacity="0.36" />
|
| 1036 |
+
<polygon points="104,234 120,230 114,272" fill="#7cf0de" fill-opacity="0.46" />
|
| 1037 |
+
<polygon points="120,230 132,248 126,274" fill="#38bdf8" fill-opacity="0.35" />
|
| 1038 |
+
<polygon points="114,272 126,274 122,306" fill="#ebfffa" fill-opacity="0.48" />
|
| 1039 |
+
<polygon points="100,274 114,272 108,306" fill="#7cf0de" fill-opacity="0.4" />
|
| 1040 |
+
<polygon points="64,216 88,206 78,246" fill="#0284c7" fill-opacity="0.25" />
|
| 1041 |
+
<polygon points="88,206 104,234 78,246" fill="#38bdf8" fill-opacity="0.32" />
|
| 1042 |
+
<polygon points="78,246 104,234 92,268" fill="#7cf0de" fill-opacity="0.35" />
|
| 1043 |
+
<polygon points="78,246 92,268 76,288" fill="#38bdf8" fill-opacity="0.3" />
|
| 1044 |
+
<polygon points="76,288 92,268 86,306" fill="#7cf0de" fill-opacity="0.38" />
|
| 1045 |
+
<polygon points="92,268 100,274 108,306" fill="#ebfffa" fill-opacity="0.45" />
|
| 1046 |
+
<polygon points="38,288 48,304 24,302" fill="#0284c7" fill-opacity="0.22" />
|
| 1047 |
+
<polygon points="24,302 48,304 32,310" fill="#38bdf8" fill-opacity="0.25" />
|
| 1048 |
+
</g>
|
| 1049 |
+
|
| 1050 |
+
<!-- Glowing Meniscus / Laser Line at Liquid Boundary -->
|
| 1051 |
+
<line id="cat-meniscus" x1="10" y1="320" x2="230" y2="320" stroke="url(#cat-laser)" stroke-width="3.5" filter="url(#cat-glow)" />
|
| 1052 |
+
</g>
|
| 1053 |
+
</svg>
|
| 1054 |
+
</div>
|
| 1055 |
+
</div>
|
| 1056 |
+
</div>
|
| 1057 |
+
</div>
|
| 1058 |
+
|
| 1059 |
+
<div class="wrap">
|
| 1060 |
+
<header>
|
| 1061 |
+
<div class="brand">
|
| 1062 |
+
<div class="brand-mark" aria-hidden="true">
|
| 1063 |
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
| 1064 |
+
<path d="M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83" />
|
| 1065 |
+
<circle cx="12" cy="12" r="3" fill="currentColor" fill-opacity="0.3" />
|
| 1066 |
+
</svg>
|
| 1067 |
+
</div>
|
| 1068 |
+
<div class="brand-text">
|
| 1069 |
+
<h1>DATA USE EXTRACTION</h1>
|
| 1070 |
+
<p class="sub">WebGPU · GLiNER + LFM2.5 multitask</p>
|
| 1071 |
+
</div>
|
| 1072 |
+
</div>
|
| 1073 |
+
<div class="header-actions">
|
| 1074 |
+
<div class="status-pill" id="status-pill"><span class="status-dot" aria-hidden="true"></span><span id="status">Initialising…</span></div>
|
| 1075 |
+
<button class="icon-btn" id="theme-toggle" title="Toggle light/dark" aria-label="Toggle theme">
|
| 1076 |
+
<svg id="theme-icon-moon" viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"/></svg>
|
| 1077 |
+
<svg id="theme-icon-sun" viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" style="display:none"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg>
|
| 1078 |
+
<span id="theme-label">Dark</span>
|
| 1079 |
+
</button>
|
| 1080 |
+
</div>
|
| 1081 |
+
</header>
|
| 1082 |
+
|
| 1083 |
+
<nav class="pipeline" aria-label="Pipeline">
|
| 1084 |
+
<div class="step active" data-step="load">
|
| 1085 |
+
<div class="step-num">1</div>
|
| 1086 |
+
<div class="step-text">Load <b>models</b></div>
|
| 1087 |
+
</div>
|
| 1088 |
+
<div class="step-arrow" aria-hidden="true"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14M13 5l7 7-7 7"/></svg></div>
|
| 1089 |
+
<div class="step" data-step="input">
|
| 1090 |
+
<div class="step-num">2</div>
|
| 1091 |
+
<div class="step-text">Paste <b>text</b></div>
|
| 1092 |
+
</div>
|
| 1093 |
+
<div class="step-arrow" aria-hidden="true"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14M13 5l7 7-7 7"/></svg></div>
|
| 1094 |
+
<div class="step" data-step="extract">
|
| 1095 |
+
<div class="step-num">3</div>
|
| 1096 |
+
<div class="step-text"><b>Extract</b></div>
|
| 1097 |
+
</div>
|
| 1098 |
+
<div class="step-arrow" aria-hidden="true"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14M13 5l7 7-7 7"/></svg></div>
|
| 1099 |
+
<div class="step" data-step="results">
|
| 1100 |
+
<div class="step-num">4</div>
|
| 1101 |
+
<div class="step-text">Review <b>mentions</b></div>
|
| 1102 |
+
</div>
|
| 1103 |
+
</nav>
|
| 1104 |
+
|
| 1105 |
+
<div class="models-strip">
|
| 1106 |
+
<a class="model-card" href="https://huggingface.co/rafmacalaba/gliner_datause_extended-onnx" target="_blank" rel="noopener">
|
| 1107 |
+
<div class="model-card-top">
|
| 1108 |
+
<div class="model-card-name">
|
| 1109 |
+
<span class="model-card-name-icon" aria-hidden="true">
|
| 1110 |
+
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>
|
| 1111 |
+
</span>
|
| 1112 |
+
<span>GLiNER</span>
|
| 1113 |
+
</div>
|
| 1114 |
+
<span class="model-role">span</span>
|
| 1115 |
+
</div>
|
| 1116 |
+
<div class="model-card-repo"><span class="repo-ns">huggingface/</span>rafmacalaba/gliner_datause_extended-onnx</div>
|
| 1117 |
+
<div class="model-card-file">onnx/gliner_datause_extended_fp16.onnx</div>
|
| 1118 |
+
</a>
|
| 1119 |
+
<a class="model-card" href="https://huggingface.co/rafmacalaba/lfm2.5-350M-datause-multitask-onnx" target="_blank" rel="noopener">
|
| 1120 |
+
<div class="model-card-top">
|
| 1121 |
+
<div class="model-card-name">
|
| 1122 |
+
<span class="model-card-name-icon" aria-hidden="true">
|
| 1123 |
+
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83"/></svg>
|
| 1124 |
+
</span>
|
| 1125 |
+
<span>LFM2.5-350M</span>
|
| 1126 |
+
</div>
|
| 1127 |
+
<span class="model-role">attribution</span>
|
| 1128 |
+
</div>
|
| 1129 |
+
<div class="model-card-repo"><span class="repo-ns">huggingface/</span>rafmacalaba/lfm2.5-350M-datause-multitask-onnx</div>
|
| 1130 |
+
<div class="model-card-file">onnx/lfm2_multitask_fp16_v2.onnx</div>
|
| 1131 |
+
</a>
|
| 1132 |
+
</div>
|
| 1133 |
+
|
| 1134 |
+
<div class="status-bar">
|
| 1135 |
+
<div class="status-readout">
|
| 1136 |
+
<div class="status-readout-head">
|
| 1137 |
+
<svg class="label-icon" viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"/></svg>
|
| 1138 |
+
<span>WebGPU pipeline</span>
|
| 1139 |
+
<span class="status-readout-pct num" id="status-pct">0%</span>
|
| 1140 |
+
</div>
|
| 1141 |
+
<div class="status-readout-rule"><i id="status-rule-fill"></i></div>
|
| 1142 |
+
<div class="status-readout-status" id="model-status-text">Loading models…</div>
|
| 1143 |
+
</div>
|
| 1144 |
+
<button class="chip ghost" id="force-redownload" title="Clear the browser cache and re-download the models" aria-label="Re-download models">
|
| 1145 |
+
<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 12a9 9 0 1 1-3.05-6.78"/><path d="M21 4v5h-5"/></svg>
|
| 1146 |
+
<span>Re-download</span>
|
| 1147 |
+
</button>
|
| 1148 |
+
</div>
|
| 1149 |
+
|
| 1150 |
+
<div class="bento">
|
| 1151 |
+
<section class="card" aria-labelledby="input-card-title">
|
| 1152 |
+
<div class="card-head">
|
| 1153 |
+
<h2 id="input-card-title">Input text</h2>
|
| 1154 |
+
<span class="badge-pill">stage 2 → 3</span>
|
| 1155 |
+
</div>
|
| 1156 |
+
<p class="card-hint">Paste research text, or load a sample — synthetic examples or real research holdout excerpts.</p>
|
| 1157 |
+
|
| 1158 |
+
<div class="sample-controls">
|
| 1159 |
+
<div class="sample-seg" role="tablist" aria-label="Sample category">
|
| 1160 |
+
<button type="button" class="sample-seg-btn active" data-category="synthetic" role="tab" aria-selected="true">SYNTHETIC (3)</button>
|
| 1161 |
+
<button type="button" class="sample-seg-btn" data-category="holdout" role="tab" aria-selected="false">HOLDOUT REAL (13)</button>
|
| 1162 |
+
</div>
|
| 1163 |
+
<button type="button" class="sample-shuffle-btn" id="sample-shuffle" title="Pick a random sample from active category">
|
| 1164 |
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21.5 2v6h-6M21.34 15.57a10 10 0 1 1-.57-8.38l5.67-5.67"/></svg>
|
| 1165 |
+
<span>Random</span>
|
| 1166 |
+
</button>
|
| 1167 |
+
</div>
|
| 1168 |
+
|
| 1169 |
+
<div class="samples-group" data-group="synthetic">
|
| 1170 |
+
<button type="button" class="sample-chip" data-sample="0">Multiple mentions</button>
|
| 1171 |
+
<button type="button" class="sample-chip" data-sample="1">Single mention</button>
|
| 1172 |
+
<button type="button" class="sample-chip" data-sample="2">No mention</button>
|
| 1173 |
+
</div>
|
| 1174 |
+
|
| 1175 |
+
<div class="samples-group" data-group="holdout" hidden>
|
| 1176 |
+
<button type="button" class="sample-chip" data-sample="3">Acronym panels (H8BS)</button>
|
| 1177 |
+
<button type="button" class="sample-chip" data-sample="4">GPS plot (EAC-I)</button>
|
| 1178 |
+
<button type="button" class="sample-chip" data-sample="5">NFHS India</button>
|
| 1179 |
+
<button type="button" class="sample-chip" data-sample="6">Spatial (DHS + GLSS)</button>
|
| 1180 |
+
<button type="button" class="sample-chip" data-sample="7">Geospatial (SRTM + GAEZ)</button>
|
| 1181 |
+
<button type="button" class="sample-chip" data-sample="8">Energy poverty (HBS)</button>
|
| 1182 |
+
<button type="button" class="sample-chip" data-sample="9">COVID NLPS r4</button>
|
| 1183 |
+
<button type="button" class="sample-chip" data-sample="10">GIS (MODIS + Lloyd's)</button>
|
| 1184 |
+
<button type="button" class="sample-chip" data-sample="11">Governance (WGI)</button>
|
| 1185 |
+
<button type="button" class="sample-chip" data-sample="12">Niger fiscal (ECVMA)</button>
|
| 1186 |
+
<button type="button" class="sample-chip" data-sample="13">Sending areas (VHLSS)</button>
|
| 1187 |
+
<button type="button" class="sample-chip" data-sample="14">Gender norms (DHS/WVS)</button>
|
| 1188 |
+
<button type="button" class="sample-chip" data-sample="15">Return (IOM Index)</button>
|
| 1189 |
+
</div>
|
| 1190 |
+
|
| 1191 |
+
<div class="textarea-wrap">
|
| 1192 |
+
<textarea id="text" placeholder="Paste research text here…">the Demographic and Health Survey (DHS) by EuStatistics in 2021 is the main dataset</textarea>
|
| 1193 |
+
</div>
|
| 1194 |
+
|
| 1195 |
+
<div class="actions">
|
| 1196 |
+
<span class="meta-text num">WebGPU · client-side · no server</span>
|
| 1197 |
+
<button class="btn" id="run" disabled>
|
| 1198 |
+
<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 5v14l11-7z"/></svg>
|
| 1199 |
+
<span>Extract</span>
|
| 1200 |
+
</button>
|
| 1201 |
+
</div>
|
| 1202 |
+
</section>
|
| 1203 |
+
|
| 1204 |
+
<section class="card" aria-labelledby="results-card-title">
|
| 1205 |
+
<div class="card-head">
|
| 1206 |
+
<h2 id="results-card-title">Extracted mentions</h2>
|
| 1207 |
+
<div class="seg-toggle" role="tablist" aria-label="Output format">
|
| 1208 |
+
<button type="button" class="seg-opt active" data-mode="pretty" role="tab" aria-selected="true">Pretty</button>
|
| 1209 |
+
<button type="button" class="seg-opt" data-mode="json" role="tab" aria-selected="false" disabled>JSON</button>
|
| 1210 |
+
<button type="button" class="seg-opt" data-mode="trace" role="tab" aria-selected="false" disabled>Trace</button>
|
| 1211 |
+
</div>
|
| 1212 |
+
</div>
|
| 1213 |
+
<p class="card-hint">Spans as a tree — provenance and usage/impact. Toggle JSON for clean extraction or Trace for timings.</p>
|
| 1214 |
+
<div id="results" class="results-host">
|
| 1215 |
+
<div class="result-pane result-pretty" data-pane="pretty" aria-live="polite">
|
| 1216 |
+
<div class="empty">
|
| 1217 |
+
<svg class="empty-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><path d="M14 2v6h6M16 13H8M16 17H8M10 9H8"/></svg>
|
| 1218 |
+
<div class="empty-title">No mentions yet</div>
|
| 1219 |
+
<div class="empty-sub">Paste text or pick a sample, then press Extract.</div>
|
| 1220 |
+
</div>
|
| 1221 |
+
</div>
|
| 1222 |
+
<div class="result-pane result-json" data-pane="json" aria-live="polite" hidden>
|
| 1223 |
+
<div class="empty">
|
| 1224 |
+
<svg class="empty-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2h-2M8 3a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2M8 3a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2"/><path d="M7 12h10M7 16h6"/></svg>
|
| 1225 |
+
<div class="empty-title">No JSON yet</div>
|
| 1226 |
+
<div class="empty-sub">Run Extract to populate the JSON view.</div>
|
| 1227 |
+
</div>
|
| 1228 |
+
</div>
|
| 1229 |
+
<div class="result-pane result-trace" data-pane="trace" aria-live="polite" hidden>
|
| 1230 |
+
<div class="empty">
|
| 1231 |
+
<svg class="empty-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 17l6-5-6-5M12 19h8"/></svg>
|
| 1232 |
+
<div class="empty-title">No trace yet</div>
|
| 1233 |
+
<div class="empty-sub">Run Extract to populate the trace view.</div>
|
| 1234 |
+
</div>
|
| 1235 |
+
</div>
|
| 1236 |
+
</div>
|
| 1237 |
+
</section>
|
| 1238 |
+
</div>
|
| 1239 |
+
</div>
|
| 1240 |
+
|
| 1241 |
+
<script>
|
| 1242 |
+
(function () {
|
| 1243 |
+
var btn = document.getElementById("theme-toggle");
|
| 1244 |
+
var moon = document.getElementById("theme-icon-moon");
|
| 1245 |
+
var sun = document.getElementById("theme-icon-sun");
|
| 1246 |
+
var label = document.getElementById("theme-label");
|
| 1247 |
+
function apply() {
|
| 1248 |
+
var dark = document.documentElement.getAttribute("data-theme") === "dark";
|
| 1249 |
+
moon.style.display = dark ? "none" : "block";
|
| 1250 |
+
sun.style.display = dark ? "block" : "none";
|
| 1251 |
+
label.textContent = dark ? "Light" : "Dark";
|
| 1252 |
+
btn.title = dark ? "Switch to light mode" : "Switch to dark mode";
|
| 1253 |
+
}
|
| 1254 |
+
btn.addEventListener("click", function () {
|
| 1255 |
+
var dark = document.documentElement.getAttribute("data-theme") === "dark";
|
| 1256 |
+
if (dark) document.documentElement.removeAttribute("data-theme");
|
| 1257 |
+
else document.documentElement.setAttribute("data-theme", "dark");
|
| 1258 |
+
try { localStorage.setItem("datause-theme", dark ? "light" : "dark"); } catch (e) {}
|
| 1259 |
+
apply();
|
| 1260 |
+
});
|
| 1261 |
+
apply();
|
| 1262 |
+
})();
|
| 1263 |
+
</script>
|
| 1264 |
+
|
| 1265 |
+
<script type="module" src="./main.js"></script>
|
| 1266 |
+
</body>
|
| 1267 |
</html>
|
lib/provenance.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export function extractFinalJson(text) {
|
| 2 |
+
if (!text) return null;
|
| 3 |
+
if (text.includes("</think>")) text = text.split("</think>").at(-1);
|
| 4 |
+
text = text.replace(/```(?:json)?\s*/g, "");
|
| 5 |
+
const blocks = [];
|
| 6 |
+
for (let i = 0; i < text.length; i++) {
|
| 7 |
+
if (text[i] !== "{") continue;
|
| 8 |
+
let depth = 0;
|
| 9 |
+
for (let j = i; j < text.length; j++) {
|
| 10 |
+
if (text[j] === "{") depth++;
|
| 11 |
+
else if (text[j] === "}") {
|
| 12 |
+
depth--;
|
| 13 |
+
if (depth === 0) { blocks.push(text.slice(i, j + 1)); break; }
|
| 14 |
+
}
|
| 15 |
+
}
|
| 16 |
+
}
|
| 17 |
+
for (let b = blocks.length - 1; b >= 0; b--) {
|
| 18 |
+
try { return JSON.parse(blocks[b]); } catch { /* try next */ }
|
| 19 |
+
}
|
| 20 |
+
return null;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
export function filterVerbatim(answer, text) {
|
| 24 |
+
const out = {};
|
| 25 |
+
for (const [k, v] of Object.entries(answer ?? {})) {
|
| 26 |
+
if (typeof v === "string" && v && text.includes(v)) out[k] = v;
|
| 27 |
+
}
|
| 28 |
+
return out;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
export function buildPrompt(text, mention) {
|
| 32 |
+
return (
|
| 33 |
+
"Extract attributes of this data mention. Output ONLY a JSON object with " +
|
| 34 |
+
"keys producer, year, geography, acronym. Each value must be an exact " +
|
| 35 |
+
"substring of the text; omit keys that are absent.\n\n" +
|
| 36 |
+
`Mention: "${mention}"\n\nText: ${text}`
|
| 37 |
+
);
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
export function buildUsageImpactPrompt(mention, usage, context) {
|
| 41 |
+
return (
|
| 42 |
+
"Classify the usage and impact of this data mention. Output ONLY a JSON " +
|
| 43 |
+
"object with keys data_type, usage_action, impact_label, usage_summary. " +
|
| 44 |
+
"usage_summary is one sentence in your own words, derived from the labels; " +
|
| 45 |
+
"do not invent specifics not present in the text.\n\n" +
|
| 46 |
+
`Mention: "${mention}"\n\nUsage: "${usage}"\n\nText: ${context}`
|
| 47 |
+
);
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
export function sentenceContaining(text, mention) {
|
| 51 |
+
const idx = text.indexOf(mention);
|
| 52 |
+
if (idx < 0) return text;
|
| 53 |
+
const re = /[.!?](?=\s|$)/g;
|
| 54 |
+
let start = 0;
|
| 55 |
+
let end = text.length;
|
| 56 |
+
let m;
|
| 57 |
+
while ((m = re.exec(text)) !== null) {
|
| 58 |
+
if (m.index < idx) start = m.index + 1;
|
| 59 |
+
else { end = m.index + 1; break; }
|
| 60 |
+
}
|
| 61 |
+
return text.slice(start, end).trim();
|
| 62 |
+
}
|
main.js
ADDED
|
@@ -0,0 +1,876 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as ort from "https://cdn.jsdelivr.net/npm/onnxruntime-web@1.27.0/dist/ort.webgpu.bundle.min.mjs";
|
| 2 |
+
import { AutoTokenizer, env } from "https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.0.2";
|
| 3 |
+
import { extractFinalJson, filterVerbatim, buildPrompt, buildUsageImpactPrompt, sentenceContaining } from "./lib/provenance.js";
|
| 4 |
+
|
| 5 |
+
const HF = (repo, file) => `https://huggingface.co/${repo}/resolve/main/${file}`;
|
| 6 |
+
const SPAN_REPO = "rafmacalaba/gliner_datause_extended-onnx";
|
| 7 |
+
const SPAN2_REPO = "rafmacalaba/gliner2_datause-onnx";
|
| 8 |
+
const MULTITASK_REPO = "rafmacalaba/lfm2.5-350M-datause-multitask-onnx";
|
| 9 |
+
const SPAN_LABELS = ["NAMED_DATA", "DESCRIPTIVE_DATA", "VAGUE_DATA"];
|
| 10 |
+
const MAX_WIDTH = 12;
|
| 11 |
+
const MAX_WIDTH2 = 8;
|
| 12 |
+
const MAX_COUNT2 = 20;
|
| 13 |
+
const SPAN_THRESHOLD = 0.6;
|
| 14 |
+
|
| 15 |
+
// Local ONNX files (serve the repo root, not just web/, so ../onnx is reachable).
|
| 16 |
+
const LOCAL = {
|
| 17 |
+
span: "../onnx/gliner_datause_extended_fp16.onnx",
|
| 18 |
+
span2: "../onnx/gliner2_datause_fp16_v2.onnx",
|
| 19 |
+
multitaskOnnx: "../onnx/lfm2_multitask_fp16_v2.onnx",
|
| 20 |
+
multitaskData: "../onnx/lfm2_multitask_fp16_v2.onnx_data",
|
| 21 |
+
};
|
| 22 |
+
|
| 23 |
+
env.allowRemoteModels = true;
|
| 24 |
+
env.useBrowserCache = true;
|
| 25 |
+
|
| 26 |
+
const status = document.getElementById("status");
|
| 27 |
+
const runBtn = document.getElementById("run");
|
| 28 |
+
const results = document.getElementById("results");
|
| 29 |
+
const resultsPretty = results.querySelector(".result-pretty");
|
| 30 |
+
const resultsJson = results.querySelector(".result-json");
|
| 31 |
+
const resultsTrace = results.querySelector(".result-trace");
|
| 32 |
+
const segOpts = document.querySelectorAll(".seg-opt");
|
| 33 |
+
const segJson = document.querySelector('.seg-opt[data-mode="json"]');
|
| 34 |
+
const segTrace = document.querySelector('.seg-opt[data-mode="trace"]');
|
| 35 |
+
const logEl = document.getElementById("log");
|
| 36 |
+
|
| 37 |
+
let lastResult = null;
|
| 38 |
+
const statusRule = document.getElementById("status-rule-fill");
|
| 39 |
+
const statusPct = document.getElementById("status-pct");
|
| 40 |
+
const modelStatusText = document.getElementById("model-status-text");
|
| 41 |
+
const textEl = document.getElementById("text");
|
| 42 |
+
|
| 43 |
+
const SAMPLES = [
|
| 44 |
+
"To assess the distributional impact of agricultural interventions, we draw on several complementary data sources that jointly cover the period of interest. The first is the Demographic and Health Survey (DHS), collected by EuStatistics in 2021, which records health and nutrition outcomes for a nationally representative sample of households across all administrative regions. The second is the Ghana Living Standards Survey (GLSS), administered by the Ghana Statistical Service in 2017, which provides detailed consumption, expenditure, and income modules at the household level. Because both surveys report household consumption using broadly comparable definitions, we are able to pool the two samples and estimate a common poverty line across years and districts. We further merge in the World Bank's World Development Indicators (WDI) to control for district-level economic conditions, population density, and access to infrastructure. Following standard practice, we restrict the estimation sample to rural households and exclude observations with implausible consumption values, and we cluster standard errors at the district level throughout. All monetary variables are expressed in constant local currency units to ensure comparability across survey rounds.",
|
| 45 |
+
"Poverty rates in this paper are estimated using the National Family Health Survey (NFHS-3) for India, a large, nationally representative household survey fielded across all states and union territories. We restrict the estimation sample to ever-married women aged 15 to 49 and cluster standard errors at the district level to account for within-district correlation in household outcomes. The survey records a rich set of household characteristics, including caste, religion, asset ownership, and household size, which we use as controls throughout the analysis. Following the existing literature, we construct a household wealth index from the reported asset holdings using principal components analysis, and we measure poverty with a consumption-based welfare aggregate deflated to a common base year. To guard against measurement error, we exclude observations with missing values on any of the core variables and winsorize the dependent variable at the first and ninety-ninth percentiles. All specifications include state fixed effects and a full set of survey-month fixed effects, and we report robust standard errors clustered at the primary sampling unit level.",
|
| 46 |
+
"This paper estimates the returns to secondary education using a within-family identification strategy that compares the labor-market outcomes of siblings who differ in their educational attainment. The central empirical challenge is that ability and family background jointly determine both schooling and later earnings, so naive comparisons of more- and less-educated individuals confound the causal effect of schooling with pre-existing differences in talent and resources. By restricting attention to brothers and sisters raised in the same household, we remove all time-invariant household characteristics that would otherwise bias the estimates. Our main finding is that an additional year of secondary schooling raises hourly earnings substantially, and the effect is larger for women than for men. We show that this result is robust to a wide range of alternative specifications, including controls for birth order, age spacing, and gender composition, and to alternative definitions of the outcome measure. We also document that the returns to schooling vary with local labor-market conditions, being higher in urban areas and in regions with greater industrial concentration. Finally, we provide evidence that the estimated effects are not driven by selective migration or by differential measurement error in self-reported earnings.",
|
| 47 |
+
"Considerable provincial variation in insurance coverage is evident in the H8BS. Two of the surveys contain self-assessed health (in the GSCF, the assessment was actually done by the woman of the household), which at least in industrialized countries has been found to be a good predictor of mortality. We measured schooling by years of schooling in the CHNS and the GSCF, but in the H8BS have left education coded as levels of attainment. The basic CHNS results are reported in Table 4, the results for the Gansu panel in Table 6, and the results for the Health VIII baseline survey in Table 7.",
|
| 48 |
+
"One of the main advantages of the data from the EAC-I is that plot size is measured by GPS. This avoids measurement errors that lead to biased results. We aggregate crop yields at the household level. We convert production to kilograms using World Bank conversion factors. Interestingly, our data indicate that crop yields vary according to the extent to which polygyny is practiced in the commune.",
|
| 49 |
+
"Data are from the 2015-16 National Family Health Survey (NFHS) of India. Panels A-C present 2SLS estimates as specified by equations 1 and 2 and using cross-sectional data. Panel D presents 2SLS estimates using the retrospective woman-year panel data. Column (1) shows estimates for the full sample, while columns (2) and (3) restrict the samples to those living in rural and urban areas, respectively.",
|
| 50 |
+
"A second contribution of this paper is to show the importance of decomposing the effects with respect to distance from the mines. Given the spatial heterogeneity of the results, we explore the effects in an individual-level, difference-in-differences analysis by using spatial lag models to allow for nonlinear effects with distance from mine. We also allow for spillovers across districts, in a district-level analysis. We use two complementary geocoded household data sets to analyze outcomes in Ghana: the Demographic and Health Survey (DHS) and the Ghana Living Standard Survey (GLSS), which provide information on a wide range of welfare outcomes.",
|
| 51 |
+
"We use geospatial data to test the validity of the local continuity assumption around the boundaries of guerrilla-controlled areas. Elevation was obtained from NASA's Shuttle Radar Topography Mission (SRTM). Information on surface water bodies comes from the MERIT Hydro dataset. Agro-climatic yield rasters with a spatial resolution of five arc minutes (nine km) come from the Global Agro-Ecological Zones (GAEZ) project. For all yields, we are using the 30-year average beginning in 1961.",
|
| 52 |
+
"The average energy spending share observed in the HBS 2019 in Bulgaria is 13.1 percent. The largest energy spending component is on electricity (59.3 percent of all energy expenditure), followed by other solid fuels (27.5 percent) and heat energy (9.3 percent). One stream of literature defines the energy poor as all households that spend more than 10 percent of their total expenditure on energy.",
|
| 53 |
+
"In the COVID-19 NLPS round 4 conducted in August 2020, households were asked to compare their current income from various sources to their income in August 2019, and to indicate whether these incomes had increased, decreased, or remained the same.",
|
| 54 |
+
"Natural amenities were calculated using several GIS layers from the GHS layers. Water bodies were used to calculate dummy variables for location near the sea (coast). We used the 250 meters resolution raster MODIS Water Mask (Carroll et al., 2009) for this purpose. Finally, we used the Lloyd's lists of maritime and fluvial ports to account for the presence of ports.",
|
| 55 |
+
"This annex summarizes how the individual indicators from the WGI data sources are assigned to the six governance dimensions corresponding to the six aggregate WGI indicators in the most recent year in which they appear in the WGI dataset. For most data sources, this is 2023 (the most recent year available in the 2024 WGI update).",
|
| 56 |
+
"The application of this fiscal incidence framework requires both microdata and macrodata. The microdata come from the second wave of the National Survey on Household Living Conditions and Agriculture (ECVMA), and the state budget and national account data provide the macrodata. The ECVMA is a survey analogous to the Living Standards Measurement Study-Integrated Survey on Agriculture (LSMS-ISA), a World Bank Group program designed to collect nationally representative data at the household and individual levels on consumption, agriculture, and other social indicators. The second wave of the panel survey in Niger was implemented in 2014, covering urban and rural areas in all regions of the country. The sample was chosen through a random two-stage process, using the 2001 General Census of Population and Housing as the base for the first stage.",
|
| 57 |
+
"In order to proxy for the origin characteristics, a set of economic variables aggregated at the province (and urban/rural) level is used. Average per capita monthly household expenditures and average per capita land areas owned by households are computed by province (and urban/rural) from the VHLSS 2004 in order to capture living standards and the opportunities for agricultural, forestry, and fishery activities. To proxy for the chance of obtaining a job in the state sector, the proportion of state workers in total employment at each sending area is calculated from the VHLSS 2004. In terms of the proportion of workers employed by foreign firms, the number of workers in the latter sector for each location is taken from the Enterprise Survey data (GSO) and divided by total employment.",
|
| 58 |
+
"Following the survey identification, we proceeded to review the indicators in the identified surveys that were related to norms and female labor force participation. Building on the literature on agency and empowerment, we identified a set of indicators and variables repeatedly appearing in the literature as norms-related indicators. The surveys considered included the Demographic and Health Survey (DHS), World Values Survey (WVS), Multiple Indicator Cluster Surveys (MICS), Gallup Poll, and Gender and Adolescence: Global Evidence (GAGE). WVS, though not available for all countries in the region, was selected due to the availability of gender attitude variables that could serve as a proxy for relevant norms. Upon careful review, the latter three were dropped due to limited data availability and duplication of variables already available in the DHS.",
|
| 59 |
+
"According to IOM's Integrated Location Assessment 4, the rate of physical violence, threats, mistrust and returnees feeling unwelcome decreased within 12 months, but still remained. Context indicators such as blocked return, social cohesion and movement restriction remained similar, according to IOM's Return Index 12. Context indicators in Yathrib showed marked improvement, with threats between tribal groups, blocked IDP return, and returnees feeling unwelcome reported before the LPA was signed and absent three months post-signature.",
|
| 60 |
+
];
|
| 61 |
+
|
| 62 |
+
// --- status logging + progress -------------------------------------------------
|
| 63 |
+
function log(msg, cls = "") {
|
| 64 |
+
if (!logEl) return;
|
| 65 |
+
const line = document.createElement("div");
|
| 66 |
+
if (cls) line.className = cls;
|
| 67 |
+
line.textContent = `[${new Date().toLocaleTimeString()}] ${msg}`;
|
| 68 |
+
logEl.appendChild(line);
|
| 69 |
+
logEl.scrollTop = logEl.scrollHeight;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
function showProgress(frac, label) {
|
| 73 |
+
modelStatusText.textContent = label;
|
| 74 |
+
const pctEl = document.getElementById("loader-pct");
|
| 75 |
+
const ruleEl = document.getElementById("loader-rule-fill");
|
| 76 |
+
const truthEl = document.getElementById("loader-truth");
|
| 77 |
+
const loaderEl = document.getElementById("loader");
|
| 78 |
+
const fillRect = document.getElementById("cat-fill-rect");
|
| 79 |
+
const meniscus = document.getElementById("cat-meniscus");
|
| 80 |
+
const pct = Math.round(frac * 100);
|
| 81 |
+
if (pctEl) pctEl.textContent = pct;
|
| 82 |
+
if (ruleEl) ruleEl.style.width = `${pct}%`;
|
| 83 |
+
if (truthEl) truthEl.textContent = label;
|
| 84 |
+
if (statusRule) statusRule.style.width = `${pct}%`;
|
| 85 |
+
if (statusPct) statusPct.textContent = `${pct}%`;
|
| 86 |
+
if (loaderEl) loaderEl.dataset.state = pct < 50 ? "sleeping" : pct < 90 ? "alert" : "excited";
|
| 87 |
+
|
| 88 |
+
if (fillRect) {
|
| 89 |
+
const fillY = Math.max(0, Math.min(320, 320 - frac * 320));
|
| 90 |
+
const fillH = Math.max(0, Math.min(320, frac * 320));
|
| 91 |
+
fillRect.setAttribute("y", fillY);
|
| 92 |
+
fillRect.setAttribute("height", fillH);
|
| 93 |
+
if (meniscus) {
|
| 94 |
+
meniscus.setAttribute("y1", fillY);
|
| 95 |
+
meniscus.setAttribute("y2", fillY);
|
| 96 |
+
meniscus.style.opacity = frac > 0.01 && frac < 0.99 ? "1" : "0.4";
|
| 97 |
+
}
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
function setLoaderStatus(msg) {
|
| 102 |
+
const el = document.getElementById("loader-status");
|
| 103 |
+
if (el) el.textContent = msg;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
function hideLoader() {
|
| 107 |
+
document.getElementById("loader")?.classList.add("hidden");
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
function enableLoaderButton() {
|
| 111 |
+
const btn = document.getElementById("loader-cta");
|
| 112 |
+
if (btn) btn.disabled = false;
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
function setStatus(msg) {
|
| 116 |
+
status.textContent = msg;
|
| 117 |
+
const pill = document.getElementById("status-pill");
|
| 118 |
+
if (!pill) return;
|
| 119 |
+
const t = /error|unavailable|not found|rejected|failed/i.test(msg) ? "err"
|
| 120 |
+
: /ready|done/i.test(msg) ? "ready"
|
| 121 |
+
: "busy";
|
| 122 |
+
pill.className = "status-pill " + t;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
// --- IndexedDB cache -----------------------------------------------------------
|
| 126 |
+
function openCache() {
|
| 127 |
+
return new Promise((resolve, reject) => {
|
| 128 |
+
const req = indexedDB.open("datause-models", 1);
|
| 129 |
+
req.onupgradeneeded = () => req.result.createObjectStore("files");
|
| 130 |
+
req.onsuccess = () => resolve(req.result);
|
| 131 |
+
req.onerror = () => reject(req.error);
|
| 132 |
+
});
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
async function cacheGet(key) {
|
| 136 |
+
const db = await openCache();
|
| 137 |
+
return new Promise((resolve) => {
|
| 138 |
+
const tx = db.transaction("files", "readonly");
|
| 139 |
+
const req = tx.objectStore("files").get(key);
|
| 140 |
+
req.onsuccess = () => resolve(req.result?.buffer ?? null);
|
| 141 |
+
req.onerror = () => resolve(null);
|
| 142 |
+
});
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
async function cacheSet(key, buffer) {
|
| 146 |
+
const db = await openCache();
|
| 147 |
+
return new Promise((resolve) => {
|
| 148 |
+
const tx = db.transaction("files", "readwrite");
|
| 149 |
+
tx.objectStore("files").put({ buffer, ts: Date.now() }, key);
|
| 150 |
+
tx.oncomplete = () => resolve();
|
| 151 |
+
tx.onerror = () => resolve();
|
| 152 |
+
});
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
// --- download with progress + cache -------------------------------------------
|
| 156 |
+
async function loadFile(url, label) {
|
| 157 |
+
const cached = await cacheGet(url);
|
| 158 |
+
if (cached) { log(`cached: ${label} (${(cached.byteLength / 1e6).toFixed(1)} MB)`, "ok"); return cached; }
|
| 159 |
+
|
| 160 |
+
log(`downloading ${label} …`);
|
| 161 |
+
setLoaderStatus("Downloading");
|
| 162 |
+
const resp = await fetch(url);
|
| 163 |
+
if (!resp.ok) throw new Error(`${resp.status} for ${url}`);
|
| 164 |
+
const total = Number(resp.headers.get("content-length") || 0);
|
| 165 |
+
const reader = resp.body.getReader();
|
| 166 |
+
const chunks = [];
|
| 167 |
+
let received = 0;
|
| 168 |
+
while (true) {
|
| 169 |
+
const { done, value } = await reader.read();
|
| 170 |
+
if (done) break;
|
| 171 |
+
chunks.push(value);
|
| 172 |
+
received += value.length;
|
| 173 |
+
const mb = (received / 1e6).toFixed(1);
|
| 174 |
+
if (total) {
|
| 175 |
+
showProgress(received / total, `${label} ${mb} / ${(total / 1e6).toFixed(1)} MB`);
|
| 176 |
+
setStatus(`Downloading ${label}… ${mb} / ${(total / 1e6).toFixed(1)} MB`);
|
| 177 |
+
} else {
|
| 178 |
+
showProgress(0.5, `${label} ${mb} MB`);
|
| 179 |
+
setStatus(`Downloading ${label}… ${mb} MB`);
|
| 180 |
+
}
|
| 181 |
+
}
|
| 182 |
+
const buffer = new Uint8Array(received);
|
| 183 |
+
let off = 0;
|
| 184 |
+
for (const c of chunks) { buffer.set(c, off); off += c.length; }
|
| 185 |
+
log(`downloaded ${label} (${(received / 1e6).toFixed(1)} MB)`, "ok");
|
| 186 |
+
showProgress(1, label);
|
| 187 |
+
cacheSet(url, buffer.buffer)
|
| 188 |
+
.then(() => log(`cached ${label}`, "ok"))
|
| 189 |
+
.catch(() => log(`cache skipped for ${label} (quota?)`, "warn")); // never block on IndexedDB
|
| 190 |
+
return buffer.buffer;
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
// --- LFM2.5 generation ----------------------------------------------------------
|
| 194 |
+
const HIDDEN = 1024, NUM_KV_HEADS = 8, HEAD_DIM = 64;
|
| 195 |
+
|
| 196 |
+
async function generateRaw(session, tokenizer, prompt, onToken, stopWhen) {
|
| 197 |
+
const rendered = `<|startoftext|><|im_start|>user\n${prompt}<|im_end|>\n<|im_start|>assistant\n`;
|
| 198 |
+
const ids = tokenizer.encode(rendered, { add_special_tokens: false });
|
| 199 |
+
|
| 200 |
+
const cache = {};
|
| 201 |
+
for (const name of session.inputNames) {
|
| 202 |
+
if (name.startsWith("past_conv")) cache[name] = new ort.Tensor("float16", new Uint16Array(HIDDEN * 3), [1, HIDDEN, 3]);
|
| 203 |
+
else if (name.startsWith("past_key_values")) cache[name] = new ort.Tensor("float16", new Uint16Array(0), [1, NUM_KV_HEADS, 0, HEAD_DIM]);
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
const eos = tokenizer.eos_token_id;
|
| 207 |
+
const gen = [];
|
| 208 |
+
let cur = ids;
|
| 209 |
+
let lastText = "";
|
| 210 |
+
for (let step = 0; step < 256; step++) {
|
| 211 |
+
const feed = {
|
| 212 |
+
input_ids: new ort.Tensor("int64", new BigInt64Array(cur.map(BigInt)), [1, cur.length]),
|
| 213 |
+
attention_mask: new ort.Tensor("int64", new BigInt64Array(ids.length + gen.length).fill(1n), [1, ids.length + gen.length]),
|
| 214 |
+
num_logits_to_keep: new ort.Tensor("int64", new BigInt64Array([1n]), []),
|
| 215 |
+
...cache,
|
| 216 |
+
};
|
| 217 |
+
const out = await session.run(feed);
|
| 218 |
+
const logits = out.logits.data;
|
| 219 |
+
const V = out.logits.dims[2];
|
| 220 |
+
const start = (out.logits.dims[1] - 1) * V;
|
| 221 |
+
let best = 0;
|
| 222 |
+
for (let i = 1; i < V; i++) if (logits[start + i] > logits[start + best]) best = i;
|
| 223 |
+
if (best === eos) break;
|
| 224 |
+
gen.push(best);
|
| 225 |
+
lastText = tokenizer.decode(gen, { skip_special_tokens: true });
|
| 226 |
+
if (onToken) onToken(lastText);
|
| 227 |
+
if (stopWhen && stopWhen(lastText)) break;
|
| 228 |
+
for (const [name, t] of Object.entries(out)) {
|
| 229 |
+
if (name.startsWith("present_conv")) cache["past_conv." + name.slice("present_conv.".length)] = t;
|
| 230 |
+
else if (name.startsWith("present.")) cache["past_key_values." + name.slice("present.".length)] = t;
|
| 231 |
+
}
|
| 232 |
+
cur = [best];
|
| 233 |
+
}
|
| 234 |
+
return lastText || tokenizer.decode(gen, { skip_special_tokens: true });
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
// True once a complete JSON object has been emitted (after any <think> block).
|
| 238 |
+
function jsonComplete(text) {
|
| 239 |
+
if (text.includes("<think>") && !text.includes("</think>")) return false;
|
| 240 |
+
return extractFinalJson(text) !== null;
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
function escapeHtml(s) {
|
| 244 |
+
return String(s).replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[c]));
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
// Render a parsed JSON value as HTML: keys navy-bold (span.k), values plain.
|
| 248 |
+
function jsonToHtml(value) {
|
| 249 |
+
if (value === null || value === undefined) return "null";
|
| 250 |
+
const t = typeof value;
|
| 251 |
+
if (t === "string") return escapeHtml(JSON.stringify(value));
|
| 252 |
+
if (t === "number" || t === "boolean") return String(value);
|
| 253 |
+
if (Array.isArray(value)) return "[" + value.map(jsonToHtml).join(", ") + "]";
|
| 254 |
+
if (t === "object") {
|
| 255 |
+
return "{ " + Object.entries(value)
|
| 256 |
+
.map(([k, v]) => '<span class="k">' + escapeHtml(JSON.stringify(k)) + "</span>: " + jsonToHtml(v))
|
| 257 |
+
.join(", ") + " }";
|
| 258 |
+
}
|
| 259 |
+
return escapeHtml(String(value));
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
// --- Pretty tree rendering ------------------------------------------------------
|
| 263 |
+
const PROV_KEYS = ["acronym", "producer", "year", "geography"];
|
| 264 |
+
const UI_KEYS = ["data_type", "usage_action", "impact_label", "usage_summary"];
|
| 265 |
+
|
| 266 |
+
function leafHtml(k, v) {
|
| 267 |
+
return `<div class="tree-leaf"><span class="k">${escapeHtml(k)}</span><span class="arrow">→</span><span class="v">${escapeHtml(String(v))}</span></div>`;
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
function leavesHtml(obj, keys) {
|
| 271 |
+
if (!obj) return '<div class="tree-none">none</div>';
|
| 272 |
+
const out = [];
|
| 273 |
+
for (const k of keys) {
|
| 274 |
+
const v = obj[k];
|
| 275 |
+
if (v === undefined || v === null || v === "") continue;
|
| 276 |
+
out.push(leafHtml(k, v));
|
| 277 |
+
}
|
| 278 |
+
return out.length ? out.join("") : '<div class="tree-none">none</div>';
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
function mentionTreeHtml(m) {
|
| 282 |
+
const badge = `<span class="badge badge-${m.label}">${escapeHtml(m.label)}</span>`;
|
| 283 |
+
const name = `<span class="tree-name">${escapeHtml(m.text)}</span>`;
|
| 284 |
+
if (m.label === "VAGUE_DATA") {
|
| 285 |
+
return `<div class="tree"><div class="tree-root">${badge}${name}</div><div class="tree-none">no attributes</div></div>`;
|
| 286 |
+
}
|
| 287 |
+
return (
|
| 288 |
+
`<div class="tree">` +
|
| 289 |
+
`<div class="tree-root">${badge}${name}<span class="tree-ms">…</span></div>` +
|
| 290 |
+
`<div class="tree-body">` +
|
| 291 |
+
`<div class="tree-slot" data-slot="prov"><div class="tree-stream streaming">attributing…</div></div>` +
|
| 292 |
+
`<div class="tree-group"><div class="tree-label">usage/impact</div><div class="tree-slot" data-slot="ui"></div></div>` +
|
| 293 |
+
`</div></div>`
|
| 294 |
+
);
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
async function runProvenance(session, tokenizer, text, mention, onToken) {
|
| 298 |
+
const raw = await generateRaw(session, tokenizer, buildPrompt(text, mention), onToken, jsonComplete);
|
| 299 |
+
return filterVerbatim(extractFinalJson(raw), text);
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
+
async function runUsageImpact(session, tokenizer, text, mention, onToken) {
|
| 303 |
+
const usage = sentenceContaining(text, mention);
|
| 304 |
+
const raw = await generateRaw(session, tokenizer, buildUsageImpactPrompt(mention, usage, text), onToken, jsonComplete);
|
| 305 |
+
return extractFinalJson(raw) ?? {};
|
| 306 |
+
}
|
| 307 |
+
|
| 308 |
+
// --- GLiNER span detection ------------------------------------------------------
|
| 309 |
+
function prepareSpanIdx(numWords, maxWidth) {
|
| 310 |
+
const starts = [], ends = [], mask = [];
|
| 311 |
+
for (let s = 0; s < numWords; s++) {
|
| 312 |
+
for (let w = 0; w < maxWidth; w++) {
|
| 313 |
+
const e = s + w;
|
| 314 |
+
starts.push(s);
|
| 315 |
+
ends.push(e);
|
| 316 |
+
mask.push(e < numWords ? 1 : 0);
|
| 317 |
+
}
|
| 318 |
+
}
|
| 319 |
+
return { starts, ends, mask };
|
| 320 |
+
}
|
| 321 |
+
|
| 322 |
+
function tokenizeWords(text) {
|
| 323 |
+
// Approximate spaCy `blank('en')` word splitting: whitespace + punctuation.
|
| 324 |
+
const out = [];
|
| 325 |
+
for (const chunk of text.split(/\s+/)) {
|
| 326 |
+
if (!chunk) continue;
|
| 327 |
+
const parts = chunk.match(/[A-Za-z0-9][A-Za-z0-9'\-]*|[^\s]/g);
|
| 328 |
+
if (parts) out.push(...parts);
|
| 329 |
+
}
|
| 330 |
+
return out;
|
| 331 |
+
}
|
| 332 |
+
|
| 333 |
+
function buildSpanInput(tokenizer, text) {
|
| 334 |
+
// GLiNER uni-encoder prompt: <<ENT>> label, repeated per label, then <<SEP>>.
|
| 335 |
+
const prompt = ["<<ENT>>", "NAMED_DATA", "<<ENT>>", "DESCRIPTIVE_DATA",
|
| 336 |
+
"<<ENT>>", "VAGUE_DATA", "<<SEP>>"];
|
| 337 |
+
const words = tokenizeWords(text);
|
| 338 |
+
const clsId = tokenizer.cls_token_id ?? 1;
|
| 339 |
+
const sepId = tokenizer.sep_token_id ?? 2;
|
| 340 |
+
|
| 341 |
+
const ids = [clsId];
|
| 342 |
+
const wordsMask = [0n];
|
| 343 |
+
for (const w of prompt) {
|
| 344 |
+
for (const s of tokenizer.encode(w, { add_special_tokens: false })) {
|
| 345 |
+
ids.push(s); wordsMask.push(0n);
|
| 346 |
+
}
|
| 347 |
+
}
|
| 348 |
+
let wordId = 0;
|
| 349 |
+
for (const w of words) {
|
| 350 |
+
wordId++;
|
| 351 |
+
const sub = tokenizer.encode(w, { add_special_tokens: false });
|
| 352 |
+
for (let i = 0; i < sub.length; i++) {
|
| 353 |
+
ids.push(sub[i]);
|
| 354 |
+
wordsMask.push(i === 0 ? BigInt(wordId) : 0n);
|
| 355 |
+
}
|
| 356 |
+
}
|
| 357 |
+
ids.push(sepId);
|
| 358 |
+
wordsMask.push(0n);
|
| 359 |
+
|
| 360 |
+
return {
|
| 361 |
+
ids,
|
| 362 |
+
wordsMask: new BigInt64Array(wordsMask),
|
| 363 |
+
numWords: wordId,
|
| 364 |
+
words,
|
| 365 |
+
};
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
async function runSpan(session, tokenizer, text) {
|
| 369 |
+
const { ids, wordsMask, numWords, words } = buildSpanInput(tokenizer, text);
|
| 370 |
+
if (numWords <= 0) return [];
|
| 371 |
+
|
| 372 |
+
const { starts, ends, mask } = prepareSpanIdx(numWords, MAX_WIDTH);
|
| 373 |
+
const spanIdx = [];
|
| 374 |
+
for (let i = 0; i < starts.length; i++) spanIdx.push([starts[i], ends[i]]);
|
| 375 |
+
|
| 376 |
+
const feed = {
|
| 377 |
+
input_ids: new ort.Tensor("int64", new BigInt64Array(ids.map(BigInt)), [1, ids.length]),
|
| 378 |
+
attention_mask: new ort.Tensor("int64", new BigInt64Array(ids.length).fill(1n), [1, ids.length]),
|
| 379 |
+
words_mask: new ort.Tensor("int64", wordsMask, [1, ids.length]),
|
| 380 |
+
text_lengths: new ort.Tensor("int64", new BigInt64Array([BigInt(numWords)]), [1, 1]),
|
| 381 |
+
span_idx: new ort.Tensor("int64", new BigInt64Array(spanIdx.flat().map(BigInt)), [1, spanIdx.length, 2]),
|
| 382 |
+
span_mask: new ort.Tensor("int64", new BigInt64Array(mask.map(BigInt)), [1, mask.length]),
|
| 383 |
+
};
|
| 384 |
+
const out = await session.run(feed);
|
| 385 |
+
const logits = out.logits.data;
|
| 386 |
+
const C = out.logits.dims[3];
|
| 387 |
+
const W = out.logits.dims[2];
|
| 388 |
+
const numSpanTotal = out.logits.dims[1] * W;
|
| 389 |
+
|
| 390 |
+
const spans = [];
|
| 391 |
+
for (let i = 0; i < numSpanTotal; i++) {
|
| 392 |
+
if (!mask[i]) continue;
|
| 393 |
+
const base = i * C;
|
| 394 |
+
let cls = 0;
|
| 395 |
+
for (let c = 1; c < C; c++) if (logits[base + c] > logits[base + cls]) cls = c;
|
| 396 |
+
spans.push({ start: starts[i], end: ends[i], cls, score: logits[base + cls] });
|
| 397 |
+
}
|
| 398 |
+
spans.sort((a, b) => b.score - a.score);
|
| 399 |
+
const kept = [];
|
| 400 |
+
const used = new Set();
|
| 401 |
+
for (const sp of spans) {
|
| 402 |
+
if (sp.score < SPAN_THRESHOLD) continue;
|
| 403 |
+
let overlaps = false;
|
| 404 |
+
for (let i = sp.start; i <= sp.end; i++) if (used.has(i)) { overlaps = true; break; }
|
| 405 |
+
if (overlaps) continue;
|
| 406 |
+
for (let i = sp.start; i <= sp.end; i++) used.add(i);
|
| 407 |
+
const label = SPAN_LABELS[sp.cls];
|
| 408 |
+
const txt = words.slice(sp.start, sp.end + 1).join(" ");
|
| 409 |
+
kept.push({ text: txt, label });
|
| 410 |
+
}
|
| 411 |
+
return kept;
|
| 412 |
+
}
|
| 413 |
+
|
| 414 |
+
async function loadModelFile(localPath, hfUrl, label) {
|
| 415 |
+
// Try local file first (fast, offline); fall back to HuggingFace.
|
| 416 |
+
try {
|
| 417 |
+
const r = await fetch(localPath, { method: "HEAD" });
|
| 418 |
+
if (r.ok) { log(`using local ${label}`); return loadFile(localPath, label); }
|
| 419 |
+
} catch { /* no local server path */ }
|
| 420 |
+
return loadFile(hfUrl, label);
|
| 421 |
+
}
|
| 422 |
+
|
| 423 |
+
// --- GLiNER2 span detection (schema-based) --------------------------------------
|
| 424 |
+
function tokenizeWords2(text) {
|
| 425 |
+
// GLiNER2's regex word splitter (lowercased), returning tokens with char offsets.
|
| 426 |
+
const lower = text.toLowerCase();
|
| 427 |
+
const re = /(?:https?:\/\/[^\s]+|www\.[^\s]+)|[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}|@[a-z0-9_]+|\w+(?:[-_]\w+)*|\S/gi;
|
| 428 |
+
const out = [];
|
| 429 |
+
let m;
|
| 430 |
+
while ((m = re.exec(lower)) !== null) {
|
| 431 |
+
out.push({ t: m[0], s: m.index, e: m.index + m[0].length });
|
| 432 |
+
}
|
| 433 |
+
return out;
|
| 434 |
+
}
|
| 435 |
+
|
| 436 |
+
function buildSpan2Input(tokenizer, text) {
|
| 437 |
+
if (text && !/[.!?]$/.test(text)) text += ".";
|
| 438 |
+
const schema = ["(", "[P]", "entities", "(", "[E]", "NAMED_DATA", "[E]",
|
| 439 |
+
"DESCRIPTIVE_DATA", "[E]", "VAGUE_DATA", ")", ")"];
|
| 440 |
+
const words = tokenizeWords2(text);
|
| 441 |
+
const combined = [...schema, "[SEP_TEXT]", ...words.map((w) => w.t)];
|
| 442 |
+
|
| 443 |
+
const ids = [];
|
| 444 |
+
const schemaSpecial = [];
|
| 445 |
+
const textWordIndices = [];
|
| 446 |
+
const startMap = [];
|
| 447 |
+
const endMap = [];
|
| 448 |
+
|
| 449 |
+
let pos = 0;
|
| 450 |
+
for (let i = 0; i < combined.length; i++) {
|
| 451 |
+
const w = combined[i];
|
| 452 |
+
const sub = tokenizer.encode(w, { add_special_tokens: false });
|
| 453 |
+
const startPos = pos;
|
| 454 |
+
for (const s of sub) { ids.push(s); pos++; }
|
| 455 |
+
if (i < schema.length && (w === "[P]" || w === "[E]")) schemaSpecial.push(startPos);
|
| 456 |
+
if (i >= schema.length + 1) {
|
| 457 |
+
textWordIndices.push(startPos);
|
| 458 |
+
startMap.push(words[i - schema.length - 1].s);
|
| 459 |
+
endMap.push(words[i - schema.length - 1].e);
|
| 460 |
+
}
|
| 461 |
+
}
|
| 462 |
+
return { ids, schemaSpecial, textWordIndices, startMap, endMap, numWords: words.length };
|
| 463 |
+
}
|
| 464 |
+
|
| 465 |
+
function prepareSpanIdx2(numWords, maxWidth) {
|
| 466 |
+
const starts = [], ends = [], mask = [];
|
| 467 |
+
for (let s = 0; s < numWords; s++) {
|
| 468 |
+
for (let w = 0; w < maxWidth; w++) {
|
| 469 |
+
const e = s + w;
|
| 470 |
+
starts.push(e < numWords ? s : -1);
|
| 471 |
+
ends.push(e < numWords ? e : -1);
|
| 472 |
+
mask.push(e < numWords ? 1 : 0);
|
| 473 |
+
}
|
| 474 |
+
}
|
| 475 |
+
return { starts, ends, mask };
|
| 476 |
+
}
|
| 477 |
+
|
| 478 |
+
async function runSpan2(session, tokenizer, text) {
|
| 479 |
+
const { ids, schemaSpecial, textWordIndices, startMap, endMap, numWords } =
|
| 480 |
+
buildSpan2Input(tokenizer, text);
|
| 481 |
+
if (numWords <= 0) return [];
|
| 482 |
+
|
| 483 |
+
const { starts, ends, mask } = prepareSpanIdx2(numWords, MAX_WIDTH2);
|
| 484 |
+
const spanIdx = [];
|
| 485 |
+
for (let i = 0; i < starts.length; i++) {
|
| 486 |
+
const a = starts[i] < 0 ? 0 : starts[i];
|
| 487 |
+
const b = ends[i] < 0 ? 0 : ends[i];
|
| 488 |
+
spanIdx.push([a, b]);
|
| 489 |
+
}
|
| 490 |
+
|
| 491 |
+
const feed = {
|
| 492 |
+
input_ids: new ort.Tensor("int64", new BigInt64Array(ids.map(BigInt)), [1, ids.length]),
|
| 493 |
+
attention_mask: new ort.Tensor("int64", new BigInt64Array(ids.length).fill(1n), [1, ids.length]),
|
| 494 |
+
text_word_indices: new ort.Tensor("int64", new BigInt64Array(textWordIndices.map(BigInt)), [1, numWords]),
|
| 495 |
+
schema_special_indices: new ort.Tensor("int64", new BigInt64Array(schemaSpecial.map(BigInt)), [1, schemaSpecial.length]),
|
| 496 |
+
span_idx: new ort.Tensor("int64", new BigInt64Array(spanIdx.flat().map(BigInt)), [1, spanIdx.length, 2]),
|
| 497 |
+
};
|
| 498 |
+
const out = await session.run(feed);
|
| 499 |
+
const scores = out.span_scores.data; // (1, W, K=8, max_count=20, M=3)
|
| 500 |
+
const W = out.span_scores.dims[1];
|
| 501 |
+
const K = out.span_scores.dims[2];
|
| 502 |
+
const MC = out.span_scores.dims[3];
|
| 503 |
+
const M = out.span_scores.dims[4];
|
| 504 |
+
|
| 505 |
+
// slot 0 scores: (W, K, M)
|
| 506 |
+
const kept = [];
|
| 507 |
+
for (let mIdx = 0; mIdx < M; mIdx++) {
|
| 508 |
+
const label = SPAN_LABELS[mIdx];
|
| 509 |
+
const cand = [];
|
| 510 |
+
for (let w = 0; w < W; w++) {
|
| 511 |
+
for (let k = 0; k < K; k++) {
|
| 512 |
+
if (!mask[w * K + k]) continue;
|
| 513 |
+
const idx = (((w * K + k) * MC + 0) * M) + mIdx;
|
| 514 |
+
const sc = scores[idx];
|
| 515 |
+
if (sc >= SPAN_THRESHOLD) {
|
| 516 |
+
const start = w;
|
| 517 |
+
const end = w + k; // inclusive word span [w, w+k]
|
| 518 |
+
cand.push({ start, end, score: sc });
|
| 519 |
+
}
|
| 520 |
+
}
|
| 521 |
+
}
|
| 522 |
+
cand.sort((a, b) => b.score - a.score);
|
| 523 |
+
const used = new Set();
|
| 524 |
+
for (const c of cand) {
|
| 525 |
+
let overlap = false;
|
| 526 |
+
for (let i = c.start; i <= c.end; i++) if (used.has(i)) { overlap = true; break; }
|
| 527 |
+
if (overlap) continue;
|
| 528 |
+
for (let i = c.start; i <= c.end; i++) used.add(i);
|
| 529 |
+
const charStart = startMap[c.start];
|
| 530 |
+
const charEnd = endMap[c.end];
|
| 531 |
+
const txt = text.slice(charStart, charEnd).trim();
|
| 532 |
+
if (txt) kept.push({ text: txt, label });
|
| 533 |
+
}
|
| 534 |
+
}
|
| 535 |
+
return kept;
|
| 536 |
+
}
|
| 537 |
+
|
| 538 |
+
// --- init -----------------------------------------------------------------------
|
| 539 |
+
async function init() {
|
| 540 |
+
if (!navigator.gpu) { setStatus("WebGPU unavailable"); log("WebGPU unavailable", "warn"); return null; }
|
| 541 |
+
setStatus("Requesting WebGPU adapter…");
|
| 542 |
+
const adapter = await navigator.gpu.requestAdapter();
|
| 543 |
+
if (!adapter) { setStatus("WebGPU adapter not found"); log("WebGPU adapter not found", "warn"); return null; }
|
| 544 |
+
ort.env.wasm.numThreads = 1;
|
| 545 |
+
|
| 546 |
+
setStatus("Loading span model (GLiNER)…");
|
| 547 |
+
log("loading span model (GLiNER) …");
|
| 548 |
+
const spanBuffer = await loadModelFile(LOCAL.span, HF(SPAN_REPO, "onnx/gliner_datause_extended_fp16.onnx"), "GLiNER span model");
|
| 549 |
+
setStatus("Initializing span model (WebGPU)…");
|
| 550 |
+
const spanSession = await ort.InferenceSession.create(spanBuffer, { executionProviders: ["webgpu"] });
|
| 551 |
+
log("span model ready", "ok");
|
| 552 |
+
|
| 553 |
+
setStatus("Loading tokenizers…");
|
| 554 |
+
log("loading tokenizers …");
|
| 555 |
+
const spanTokenizer = await AutoTokenizer.from_pretrained("rafmacalaba/gliner_datause_extended-onnx");
|
| 556 |
+
const multitaskTokenizer = await AutoTokenizer.from_pretrained(MULTITASK_REPO);
|
| 557 |
+
log("tokenizers ready", "ok");
|
| 558 |
+
|
| 559 |
+
const multitaskSession = await loadMultitaskSession();
|
| 560 |
+
|
| 561 |
+
setStatus("Ready");
|
| 562 |
+
modelStatusText.textContent = "Models ready — cached in browser · WebGPU";
|
| 563 |
+
if (statusRule) statusRule.style.width = "100%";
|
| 564 |
+
if (statusPct) statusPct.textContent = "100%";
|
| 565 |
+
runBtn.disabled = false;
|
| 566 |
+
setLoaderStatus("Ready");
|
| 567 |
+
log("execution provider: WebGPU (all models)", "ok");
|
| 568 |
+
enableLoaderButton();
|
| 569 |
+
return { spanSession, spanTokenizer, multitaskTokenizer, multitaskSession };
|
| 570 |
+
}
|
| 571 |
+
|
| 572 |
+
// --- LFM2.5 multitask attribution ------------------------------------------------
|
| 573 |
+
async function createLlmSession(onnxBuffer, dataBuffer, dataPath, label) {
|
| 574 |
+
const extData = [{ path: dataPath, data: dataBuffer }];
|
| 575 |
+
setStatus(`Initializing ${label} (WebGPU)…`);
|
| 576 |
+
try {
|
| 577 |
+
return await ort.InferenceSession.create(onnxBuffer, { executionProviders: ["webgpu"], externalData: extData });
|
| 578 |
+
} catch (e) {
|
| 579 |
+
log(`WebGPU rejected ${label}: ${e?.message || e}`, "warn");
|
| 580 |
+
console.error("webgpu create error:", e);
|
| 581 |
+
setStatus(`WebGPU rejected ${label} — trying wasm (CPU)…`);
|
| 582 |
+
const s = await ort.InferenceSession.create(onnxBuffer, { executionProviders: ["wasm"], externalData: extData });
|
| 583 |
+
log(`${label} loaded on wasm (CPU) fallback`, "warn");
|
| 584 |
+
return s;
|
| 585 |
+
}
|
| 586 |
+
}
|
| 587 |
+
|
| 588 |
+
async function loadMultitaskSession() {
|
| 589 |
+
setStatus("Loading multitask model (LFM2.5)…");
|
| 590 |
+
log("loading multitask model (LFM2.5) …");
|
| 591 |
+
const onnx = await loadModelFile(LOCAL.multitaskOnnx, HF(MULTITASK_REPO, "onnx/lfm2_multitask_fp16_v2.onnx"), "LFM2.5 multitask model");
|
| 592 |
+
const data = await loadModelFile(LOCAL.multitaskData, HF(MULTITASK_REPO, "onnx/lfm2_multitask_fp16_v2.onnx_data"), "LFM2.5 multitask weights");
|
| 593 |
+
const s = await createLlmSession(onnx, data, "lfm2_multitask_fp16_v2.onnx_data", "multitask model");
|
| 594 |
+
log("multitask model ready", "ok");
|
| 595 |
+
return s;
|
| 596 |
+
}
|
| 597 |
+
|
| 598 |
+
const ready = init().catch((e) => {
|
| 599 |
+
const msg = (e && (e.message || e.name)) || String(e) || "unknown error";
|
| 600 |
+
setStatus("Error: " + msg);
|
| 601 |
+
setLoaderStatus("Error");
|
| 602 |
+
log("Error: " + msg, "warn");
|
| 603 |
+
log("details: " + (e?.stack || JSON.stringify(e) || "n/a"), "warn");
|
| 604 |
+
console.error(e);
|
| 605 |
+
enableLoaderButton();
|
| 606 |
+
return null;
|
| 607 |
+
});
|
| 608 |
+
|
| 609 |
+
document.getElementById("loader-cta")?.addEventListener("click", () => {
|
| 610 |
+
hideLoader();
|
| 611 |
+
});
|
| 612 |
+
|
| 613 |
+
runBtn.addEventListener("click", async () => {
|
| 614 |
+
const ctx = await ready;
|
| 615 |
+
if (!ctx) return;
|
| 616 |
+
const text = textEl.value.trim();
|
| 617 |
+
if (!text) return;
|
| 618 |
+
resultsPretty.innerHTML = "";
|
| 619 |
+
resultsJson.innerHTML = "";
|
| 620 |
+
resultsTrace.innerHTML = "";
|
| 621 |
+
lastResult = null;
|
| 622 |
+
[segJson, segTrace].forEach((s) => { if (s) s.disabled = true; });
|
| 623 |
+
runBtn.disabled = true;
|
| 624 |
+
|
| 625 |
+
try {
|
| 626 |
+
const tTotal0 = performance.now();
|
| 627 |
+
|
| 628 |
+
setStatus("Running span model (GLiNER)…");
|
| 629 |
+
log("extracting data mentions (GLiNER) …");
|
| 630 |
+
const tSpan0 = performance.now();
|
| 631 |
+
const mentions = await runSpan(ctx.spanSession, ctx.spanTokenizer, text);
|
| 632 |
+
const spanMs = performance.now() - tSpan0;
|
| 633 |
+
const named = mentions.filter((m) => m.label !== "VAGUE_DATA");
|
| 634 |
+
log(`span: ${spanMs.toFixed(0)} ms — ${mentions.length} mentions (${named.length} named/descriptive)`, "ok");
|
| 635 |
+
|
| 636 |
+
const labelCounts = {};
|
| 637 |
+
for (const m of mentions) labelCounts[m.label] = (labelCounts[m.label] || 0) + 1;
|
| 638 |
+
log(`labels: ${SPAN_LABELS.map(l => `${l}=${labelCounts[l] || 0}`).join(", ")}`, "ok");
|
| 639 |
+
|
| 640 |
+
// Attribution: LFM2.5 multitask (provenance + usage/impact).
|
| 641 |
+
const attribLabel = "Multitask";
|
| 642 |
+
|
| 643 |
+
// Render all mentions immediately; attribution fills in afterwards.
|
| 644 |
+
const perfDiv = document.createElement("div");
|
| 645 |
+
perfDiv.className = "perf";
|
| 646 |
+
perfDiv.innerHTML =
|
| 647 |
+
`<span class="stat">span <b>${spanMs.toFixed(0)} ms</b></span>` +
|
| 648 |
+
`<span class="stat">mentions <b>${named.length}</b></span>` +
|
| 649 |
+
`<span class="stat">${attribLabel.toLowerCase()} <b>…</b></span>`;
|
| 650 |
+
resultsPretty.prepend(perfDiv);
|
| 651 |
+
const perfAttrib = perfDiv.querySelector(".stat:last-child b");
|
| 652 |
+
|
| 653 |
+
const cards = new Map();
|
| 654 |
+
for (const m of mentions) {
|
| 655 |
+
const wrapper = document.createElement("div");
|
| 656 |
+
wrapper.innerHTML = mentionTreeHtml(m);
|
| 657 |
+
const el = wrapper.firstElementChild;
|
| 658 |
+
resultsPretty.appendChild(el);
|
| 659 |
+
cards.set(m, {
|
| 660 |
+
msEl: el.querySelector(".tree-ms"),
|
| 661 |
+
provSlot: el.querySelector('[data-slot="prov"]'),
|
| 662 |
+
uiSlot: el.querySelector('[data-slot="ui"]'),
|
| 663 |
+
attrs: null, ui: null, ms: null,
|
| 664 |
+
});
|
| 665 |
+
}
|
| 666 |
+
|
| 667 |
+
// Attribution per mention, streaming tokens into each tree as they arrive.
|
| 668 |
+
let attribTotalMs = 0;
|
| 669 |
+
for (const m of named) {
|
| 670 |
+
setStatus(`Attributing "${m.text}" (${attribLabel})…`);
|
| 671 |
+
const t0 = performance.now();
|
| 672 |
+
const card = cards.get(m);
|
| 673 |
+
|
| 674 |
+
const attrs = await runProvenance(ctx.multitaskSession, ctx.multitaskTokenizer, text, m.text, (partial) => {
|
| 675 |
+
if (card && card.provSlot) card.provSlot.innerHTML = `<div class="tree-stream streaming">${escapeHtml(partial)}</div>`;
|
| 676 |
+
});
|
| 677 |
+
if (card && card.provSlot) {
|
| 678 |
+
card.attrs = attrs;
|
| 679 |
+
card.provSlot.innerHTML = leavesHtml(attrs, PROV_KEYS);
|
| 680 |
+
}
|
| 681 |
+
|
| 682 |
+
const ui = await runUsageImpact(ctx.multitaskSession, ctx.multitaskTokenizer, text, m.text, (partial) => {
|
| 683 |
+
if (card && card.uiSlot) card.uiSlot.innerHTML = `<div class="tree-stream streaming">${escapeHtml(partial)}</div>`;
|
| 684 |
+
});
|
| 685 |
+
if (card && card.uiSlot) {
|
| 686 |
+
card.ui = ui;
|
| 687 |
+
card.uiSlot.innerHTML = leavesHtml(ui, UI_KEYS);
|
| 688 |
+
}
|
| 689 |
+
|
| 690 |
+
const ms = performance.now() - t0;
|
| 691 |
+
attribTotalMs += ms;
|
| 692 |
+
log(`attribution "${m.text}": ${ms.toFixed(0)} ms`);
|
| 693 |
+
if (card) {
|
| 694 |
+
card.ms = ms;
|
| 695 |
+
if (card.msEl) card.msEl.textContent = `${ms.toFixed(0)} ms`;
|
| 696 |
+
}
|
| 697 |
+
perfAttrib.textContent = `${attribTotalMs.toFixed(0)} ms`;
|
| 698 |
+
}
|
| 699 |
+
|
| 700 |
+
const totalMs = performance.now() - tTotal0;
|
| 701 |
+
log(`done: total ${totalMs.toFixed(0)} ms · span ${spanMs.toFixed(0)} ms · ${attribLabel.toLowerCase()} ${attribTotalMs.toFixed(0)} ms`, "ok");
|
| 702 |
+
if (!mentions.length) resultsPretty.innerHTML = "<div class=\"empty\">No mentions found.</div>";
|
| 703 |
+
setStatus("Done");
|
| 704 |
+
|
| 705 |
+
lastResult = {
|
| 706 |
+
input: { text, length: text.length },
|
| 707 |
+
timings: {
|
| 708 |
+
span_ms: Math.round(spanMs),
|
| 709 |
+
attribution_ms: Math.round(attribTotalMs),
|
| 710 |
+
total_ms: Math.round(totalMs),
|
| 711 |
+
},
|
| 712 |
+
label_counts: labelCounts,
|
| 713 |
+
mentions: mentions.map((m) => {
|
| 714 |
+
const c = cards.get(m) || {};
|
| 715 |
+
return {
|
| 716 |
+
text: m.text,
|
| 717 |
+
label: m.label,
|
| 718 |
+
provenance: c.attrs || null,
|
| 719 |
+
usage_impact: c.ui || null,
|
| 720 |
+
attribution_ms: c.ms != null ? Math.round(c.ms) : null,
|
| 721 |
+
};
|
| 722 |
+
}),
|
| 723 |
+
};
|
| 724 |
+
[segJson, segTrace].forEach((s) => { if (s) s.disabled = false; });
|
| 725 |
+
const activeMode = document.querySelector(".seg-opt.active")?.dataset.mode || "pretty";
|
| 726 |
+
if (activeMode === "json") renderJson();
|
| 727 |
+
else if (activeMode === "trace") renderTrace();
|
| 728 |
+
} catch (e) {
|
| 729 |
+
const msg = (e && (e.message || e.name)) || String(e) || "unknown error";
|
| 730 |
+
setStatus("Error: " + msg);
|
| 731 |
+
log("Error: " + msg, "warn");
|
| 732 |
+
log("details: " + (e?.stack || JSON.stringify(e) || "n/a"), "warn");
|
| 733 |
+
console.error(e);
|
| 734 |
+
} finally {
|
| 735 |
+
runBtn.disabled = false;
|
| 736 |
+
}
|
| 737 |
+
});
|
| 738 |
+
|
| 739 |
+
function colorizeJson(json) {
|
| 740 |
+
return escapeHtml(json)
|
| 741 |
+
.replace(/("[^&]*?")(\s*:)/g, '<span class="jk">$1</span>$2')
|
| 742 |
+
.replace(/:\s*("[^&]*?")/g, ': <span class="js">$1</span>')
|
| 743 |
+
.replace(/:\s*(-?\d+\.?\d*)/g, ': <span class="jn">$1</span>')
|
| 744 |
+
.replace(/:\s*(true|false|null)\b/g, ': <span class="jb">$1</span>');
|
| 745 |
+
}
|
| 746 |
+
|
| 747 |
+
function cleanResult() {
|
| 748 |
+
if (!lastResult) return null;
|
| 749 |
+
return {
|
| 750 |
+
input: lastResult.input,
|
| 751 |
+
mentions: lastResult.mentions.map((m) => ({
|
| 752 |
+
text: m.text,
|
| 753 |
+
label: m.label,
|
| 754 |
+
provenance: m.provenance,
|
| 755 |
+
usage_impact: m.usage_impact,
|
| 756 |
+
})),
|
| 757 |
+
};
|
| 758 |
+
}
|
| 759 |
+
|
| 760 |
+
function renderJson() {
|
| 761 |
+
if (!lastResult) return;
|
| 762 |
+
const json = JSON.stringify(cleanResult(), null, 2);
|
| 763 |
+
resultsJson.innerHTML = `<pre>${colorizeJson(json)}</pre>`;
|
| 764 |
+
}
|
| 765 |
+
|
| 766 |
+
function renderTrace() {
|
| 767 |
+
if (!lastResult) return;
|
| 768 |
+
const t = lastResult.timings;
|
| 769 |
+
const meta =
|
| 770 |
+
`<div class="json-meta">` +
|
| 771 |
+
`<span>input <b>${lastResult.input.length}</b> chars</span>` +
|
| 772 |
+
`<span>span <b>${t.span_ms} ms</b></span>` +
|
| 773 |
+
`<span>attribution <b>${t.attribution_ms} ms</b></span>` +
|
| 774 |
+
`<span>total <b>${t.total_ms} ms</b></span>` +
|
| 775 |
+
`<span>mentions <b>${lastResult.mentions.length}</b></span>` +
|
| 776 |
+
`</div>`;
|
| 777 |
+
const json = JSON.stringify(lastResult, null, 2);
|
| 778 |
+
resultsTrace.innerHTML = meta + `<pre>${colorizeJson(json)}</pre>`;
|
| 779 |
+
}
|
| 780 |
+
|
| 781 |
+
const PANES = [
|
| 782 |
+
["pretty", resultsPretty],
|
| 783 |
+
["json", resultsJson],
|
| 784 |
+
["trace", resultsTrace],
|
| 785 |
+
];
|
| 786 |
+
|
| 787 |
+
function setMode(mode) {
|
| 788 |
+
if (mode !== "pretty" && !lastResult) return;
|
| 789 |
+
segOpts.forEach((o) => {
|
| 790 |
+
const active = o.dataset.mode === mode;
|
| 791 |
+
o.classList.toggle("active", active);
|
| 792 |
+
o.setAttribute("aria-selected", String(active));
|
| 793 |
+
});
|
| 794 |
+
for (const [m, pane] of PANES) {
|
| 795 |
+
pane.hidden = m !== mode;
|
| 796 |
+
pane.setAttribute("aria-live", m === mode ? "polite" : "off");
|
| 797 |
+
}
|
| 798 |
+
if (mode === "json") renderJson();
|
| 799 |
+
else if (mode === "trace") renderTrace();
|
| 800 |
+
}
|
| 801 |
+
|
| 802 |
+
segOpts.forEach((o) => o.addEventListener("click", () => setMode(o.dataset.mode)));
|
| 803 |
+
|
| 804 |
+
// Sample category tabs & chips
|
| 805 |
+
const sampleSegBtns = document.querySelectorAll(".sample-seg-btn");
|
| 806 |
+
const sampleGroups = document.querySelectorAll(".samples-group");
|
| 807 |
+
const sampleChips = document.querySelectorAll(".sample-chip");
|
| 808 |
+
const shuffleBtn = document.getElementById("sample-shuffle");
|
| 809 |
+
|
| 810 |
+
function selectSample(btn) {
|
| 811 |
+
if (!btn) return;
|
| 812 |
+
const idx = Number(btn.dataset.sample);
|
| 813 |
+
if (isNaN(idx) || !SAMPLES[idx]) return;
|
| 814 |
+
textEl.value = SAMPLES[idx];
|
| 815 |
+
sampleChips.forEach((c) => c.classList.toggle("active", c === btn));
|
| 816 |
+
}
|
| 817 |
+
|
| 818 |
+
sampleSegBtns.forEach((btn) => {
|
| 819 |
+
btn.addEventListener("click", () => {
|
| 820 |
+
const cat = btn.dataset.category;
|
| 821 |
+
sampleSegBtns.forEach((b) => {
|
| 822 |
+
const active = b === btn;
|
| 823 |
+
b.classList.toggle("active", active);
|
| 824 |
+
b.setAttribute("aria-selected", String(active));
|
| 825 |
+
});
|
| 826 |
+
sampleGroups.forEach((g) => {
|
| 827 |
+
g.hidden = g.dataset.group !== cat;
|
| 828 |
+
});
|
| 829 |
+
});
|
| 830 |
+
});
|
| 831 |
+
|
| 832 |
+
sampleChips.forEach((btn) => {
|
| 833 |
+
btn.addEventListener("click", () => selectSample(btn));
|
| 834 |
+
});
|
| 835 |
+
|
| 836 |
+
shuffleBtn?.addEventListener("click", () => {
|
| 837 |
+
const activeGroup = document.querySelector(".samples-group:not([hidden])");
|
| 838 |
+
if (!activeGroup) return;
|
| 839 |
+
const visibleChips = Array.from(activeGroup.querySelectorAll(".sample-chip"));
|
| 840 |
+
if (!visibleChips.length) return;
|
| 841 |
+
const currentActive = visibleChips.find((c) => c.classList.contains("active"));
|
| 842 |
+
const pool = visibleChips.filter((c) => c !== currentActive);
|
| 843 |
+
const target = (pool.length ? pool : visibleChips)[Math.floor(Math.random() * (pool.length || visibleChips.length))];
|
| 844 |
+
selectSample(target);
|
| 845 |
+
});
|
| 846 |
+
|
| 847 |
+
document.getElementById("force-redownload").addEventListener("click", async () => {
|
| 848 |
+
log("clearing model cache…", "warn");
|
| 849 |
+
try {
|
| 850 |
+
await new Promise((resolve) => {
|
| 851 |
+
const req = indexedDB.deleteDatabase("datause-models");
|
| 852 |
+
req.onsuccess = req.onerror = req.onblocked = () => resolve();
|
| 853 |
+
});
|
| 854 |
+
} catch { /* ignore */ }
|
| 855 |
+
location.reload();
|
| 856 |
+
});
|
| 857 |
+
|
| 858 |
+
// Fetch model READMEs (metrics + training details) for the "Models & tasks" panel.
|
| 859 |
+
async function loadReadme(repo, elId) {
|
| 860 |
+
const el = document.getElementById(elId);
|
| 861 |
+
if (!el) return;
|
| 862 |
+
try {
|
| 863 |
+
const resp = await fetch(`https://huggingface.co/${repo}/resolve/main/README.md`);
|
| 864 |
+
if (!resp.ok) throw new Error(String(resp.status));
|
| 865 |
+
const md = await resp.text();
|
| 866 |
+
const metrics = md
|
| 867 |
+
.split("\n")
|
| 868 |
+
.filter((l) => l.includes("|") && (/\d/.test(l) || l.startsWith("|")))
|
| 869 |
+
.join("\n");
|
| 870 |
+
el.textContent = metrics || md.slice(0, 1500);
|
| 871 |
+
} catch {
|
| 872 |
+
el.textContent = "README unavailable offline.";
|
| 873 |
+
}
|
| 874 |
+
}
|
| 875 |
+
loadReadme("rafmacalaba/gliner_datause_extended", "meta-gliner");
|
| 876 |
+
loadReadme("rafmacalaba/lfm2.5-350M-datause-multitask", "meta-multitask");
|