Spaces:
Running
Running
Decima Playground: the model runs in your browser
Browse filesFiles changed (12)
- README.md+39-5
- app.jsAdded+678
- decima.jsAdded+234
- examples/banking77_intents.txtAdded+77
- examples/business_cases.jsonAdded+1179
- examples/clinc150_intents.txtAdded+150
- examples/gallery.jsonAdded+643
- examples/massive60_intents.txtAdded+60
- examples/tickets.jsonAdded+102
- index.html+182-17
- style.css+421-18
- worker.jsAdded+42
12345678910---title: Decima Playgroundemoji: 🌍colorFrom: redcolorTo: bluesdk: staticpinned: false---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference1234567891011121314151617181920212223242526272829303132333435363738394041424344---title: Decima Playgroundemoji: ⚖️colorFrom: bluecolorTo: graysdk: staticapp_file: index.htmlpinned: truelicense: apache-2.0short_description: A 122M decision model running in your browsermodels:- amyrmahdy/decima-smalltags: [decision-model, calibration, multilingual, onnx, onnxruntime-web, webassembly, in-browser, zero-shot-classification]---# Decima PlaygroundInteractive demo of **[Decima-small](https://huggingface.co/amyrmahdy/decima-small)**: give it a situation, aquestion and your own options (free text, any number, any order) and it returns calibrated probabilities.**The model runs in your browser.** The page downloads the int8 ONNX export once (about 140 MB, then cached on yourdevice) and runs it with [ONNX Runtime Web](https://onnxruntime.ai/docs/tutorials/web/) on WebAssembly. There is noserver behind this Space: nothing you type leaves your device.- **Try it** — your own inputs, plus curated examples (multilingual routing, 150 intents, urgency levels,help-article relevance, yes/no, news topic). Every example was run before it was added; its recordedoutput is in `examples/gallery.json`.- **Business cases** — long synthetic cases the model never trained on. Decima answers every question live; the26B teacher's recorded answer sits next to it, disagreements included.- **Shuffle test** — reorder the options and watch the probabilities stay put.- **Auto-route** — your browser scores 20 tickets once; then move a confidence threshold and see what gets automated.- **Speed** — a latency sweep on your own device, next to our x86 reference numbers.How it is built: `decima.js` is a line-for-line port of the Python runtime (`DecimaOnnx`: script normalisation,prompt construction, encoder → scorer, temperature, softmax / ordinal / sigmoid heads), `worker.js` runs it in a WebWorker, and the tokenizer is [tokenizers.js](https://github.com/huggingface/tokenizers.js) — the tokenizer insideTransformers.js — reading the exported `tokenizer.json`. Token ids match the Python tokenizer on 200 of 200 test stringsin 20 languages. ONNX Runtime Web computes the int8 layers with float activations; the Python runtime doing thesame on the same weights gives probabilities within 3 × 10⁻⁴ of this page. (Native ONNX Runtime on a server CPUuses int8 activations and can differ by up to a few hundredths on close calls.)Examples are curated; see the model card for benchmark accuracy and limitations. Business cases in`examples/business_cases.json` are synthetic (generated and labelled by Gemma-4-26B-A4B for the Decima project) andreleased under **CC BY 4.0**.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678// Decima Playground — static version. The model runs in this browser tab (ONNX Runtime Web, WebAssembly);// the page talks to it through a Web Worker (worker.js) so the interface stays responsive.
// Where the int8 export lives: encoder.onnx, scorer.onnx, decima.json, tokenizer/{tokenizer.json, tokenizer_config.json}.// Override for local testing with ?model=<url>.const MODEL_URL = "https://huggingface.co/amyrmahdy/decima-small/resolve/main/onnx/int8/";
import { detectLang } from "./decima.js";
const $ = (s, el = document) => el.querySelector(s);const $$ = (s, el = document) => [...el.querySelectorAll(s)];const params = new URLSearchParams(location.search);const modelUrl = params.get("model") || MODEL_URL;
// ───────────────────────────── the model, in a worker ─────────────────────────────
const worker = new Worker(new URL("./worker.js", import.meta.url), { type: "module" });let seq = 0;const pending = new Map();worker.onmessage = ({ data }) => { const p = pending.get(data.id); if (!p) return; if (data.progress) return p.onProgress?.(data.progress); pending.delete(data.id); data.error ? p.reject(new Error(data.error)) : p.resolve(data.result);};worker.onerror = (e) => { for (const p of pending.values()) p.reject(new Error(e.message || "worker failed")); pending.clear(); };const call = (op, args = {}, onProgress) => new Promise((resolve, reject) => { const id = ++seq; pending.set(id, { resolve, reject, onProgress }); worker.postMessage({ id, op, ...args });});
const mb = (b) => (b / 1e6).toFixed(1);let loadStats = null;let fromCache = false;const tLoad0 = performance.now();
const ready = call("load", { url: modelUrl }, (p) => { fromCache = p.cached; const bar = $("#load-bar"), txt = $("#load-text"), num = $("#load-num"); if (p.cached || (p.total && p.loaded >= p.total)) { bar.classList.add("is-indeterminate"); bar.firstElementChild.style.width = ""; bar.removeAttribute("aria-valuenow"); } if (p.cached) { txt.innerHTML = "<b>Loading the model from this device</b> — it was saved on your first visit."; num.textContent = `${mb(p.total)} MB`; return; } const frac = p.total ? Math.min(1, p.loaded / p.total) : 0; if (frac >= 1) { txt.innerHTML = "<b>Preparing the model</b> — compiling it for this browser."; num.textContent = `${mb(p.total)} MB`; return; } bar.classList.remove("is-indeterminate"); bar.firstElementChild.style.width = `${(frac * 100).toFixed(1)}%`; bar.setAttribute("aria-valuenow", Math.round(frac * 100)); txt.innerHTML = "<b>Downloading the model</b> — once; after that it is cached on this device."; num.textContent = `${mb(p.loaded)} / ${mb(p.total)} MB · ${Math.round(frac * 100)}%`;}).then((s) => { loadStats = { ...s, fromCache, total_ms: performance.now() - tLoad0 }; const L = $("#loader"); L.classList.add("is-ready"); const secs = (loadStats.total_ms / 1000).toFixed(1); $("#load-text").innerHTML = fromCache ? `<b>Model ready</b> in ${secs} s · loaded from this device, running in this tab` : `<b>Model ready</b> in ${secs} s · downloaded ${mb(s.bytes)} MB once, now cached on this device`; $("#load-num").textContent = s.threads > 1 ? `${s.threads} threads` : ""; $("#load-foot").textContent = `This visit: model ready in ${(loadStats.total_ms / 1000).toFixed(1)} s.`; return s;}).catch((e) => { const L = $("#loader"); L.classList.add("is-error"); $("#load-bar").hidden = true; $("#load-text").innerHTML = `<b>The model could not be loaded.</b> ${esc(e.message)} — try reloading, or a recent Chrome, Edge, Firefox or Safari.`; throw e;});ready.catch(() => {});
async function decide(state, q) { await ready; return call("decide", { state, q });}
// ───────────────────────────── data ─────────────────────────────
const TEAMS = ["billing", "technical support", "sales", "account security"];const TEAM_Q = "Which team should handle this request?";const FEATURED = ["route-fa-informal", "route-ar", "route-zh", "route-ru", "route-es", "route-de", "clinc-reminder", "massive-fa", "urgency", "rank", "verify", "news"];const MAX_OPTIONS = 200;const X86_SCALING = { 4: 16, 20: 26, 77: 75, 150: 130 }; // docs/BENCH-x86.md, short labels, p50 ms, one P-coreconst LANG_NAME = { auto: "auto", latn: "Latin script", en: "English", fa: "Persian", ar: "Arabic", ru: "Russian", zh: "Chinese", es: "Spanish", de: "German", fr: "French", tr: "Turkish", hi: "Hindi", ja: "Japanese", ko: "Korean", ur: "Urdu", xx: "other", el: "Greek", th: "Thai" };const DOMAIN_NAME = { ecommerce: "E-commerce", legal_contract: "Legal · contracts", compliance_privacy: "Privacy & compliance", it_ops: "IT operations", product_feedback: "Product feedback", rag_relevance: "Search relevance", invoice_ap: "Accounts payable", procurement: "Procurement", fraud: "Fraud review", sales_crm: "Sales CRM", insurance: "Insurance", real_estate: "Real estate", code_review: "Code review", it_helpdesk: "IT helpdesk", email_ops: "Email operations", travel_expense: "Travel & expenses", banking: "Banking", support_triage: "Support triage", citation_support: "Citation check", logistics: "Logistics", hr: "HR", data_quality: "Data quality", public_services: "Public services", education: "Education" };const LN = { en: "English", fa: "Persian", ar: "Arabic", ru: "Russian" };
const getJSON = (p) => fetch(p).then((r) => r.json());const getLines = (p) => fetch(p).then((r) => r.text()).then((t) => { const l = t.split(/\r\n|\n|\r/); if (l.at(-1) === "") l.pop(); return l; });
const dataReady = (async () => { const [gallery, business, tickets, clinc, massive, banking] = await Promise.all([ getJSON("examples/gallery.json"), getJSON("examples/business_cases.json"), getJSON("examples/tickets.json"), getLines("examples/clinc150_intents.txt"), getLines("examples/massive60_intents.txt"), getLines("examples/banking77_intents.txt")]); const labels = { "clinc150_intents.txt": clinc, "massive60_intents.txt": massive, "banking77_intents.txt": banking }; for (const g of gallery.gallery) if (g.choices == null) g.choices = labels[g.choices_file]; const byId = Object.fromEntries(gallery.gallery.map((g) => [g.id, g])); return { gallery, business, tickets, labels, byId, cards: FEATURED.map((id) => byId[id]).filter(Boolean), speedSets: { 4: TEAMS, 20: clinc.slice(0, 20), 77: banking, 150: clinc } };})();
// ───────────────────────────── HTML builders (ported from app.py) ─────────────────────────────
function esc(s) { return String(s).replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[c]));}function pct(p) { if (p >= 0.9995) return p < 1 ? "99.9%+" : "100%"; return p >= 0.001 ? `${(p * 100).toFixed(1)}%` : "<0.1%";}const argmax = (p) => p.reduce((b, v, i) => (v > p[b] ? i : b), 0);const top = (r) => r.choices[argmax(r.probs)];const confidence = (r) => Math.max(...r.probs);
function confBadge(p, kind) { if (kind === "rank") return '<span class="dz-badge dz-b-info">independent scores</span>'; const [c, t] = p >= 0.8 ? ["high", "High"] : p >= 0.5 ? ["mid", "Medium"] : ["low", "Low"]; return `<span class="dz-badge dz-b-${c}">${t} confidence · ${pct(p)}</span>`;}function scaleHtml() { const ticks = [0, 25, 50, 75, 100].map((t) => `<span style="left:${t}%">${t}</span>`).join(""); return `<div class="dz-row dz-scale" aria-hidden="true"><div></div><div class="dz-ticks">${ticks}</div><div></div></div>`;}function row(c, p, isTop) { const w = Math.max(p * 100, 0.35); return `<div class="dz-row${isTop ? " is-top" : ""}"><div class="dz-label" dir="auto" title="${esc(c)}">${esc(c)}</div>` + `<div class="dz-track"><div class="dz-fill" style="width:${w.toFixed(2)}%"></div></div>` + `<div class="dz-pct">${pct(p)}</div></div>`;}function rowsHtml(pairs, topC, limit) { const out = []; for (let i = 0; i < pairs.length; i++) { const [c, p] = pairs[i]; if (limit && i === limit) { const tail = pairs.slice(limit).map(([c2, p2]) => row(c2, p2, false)).join(""); out.push(`<details class="dz-more"><summary>Show the other ${pairs.length - limit} options (all ≤ ${pct(pairs[limit][1])})</summary>${tail}</details>`); break; } out.push(row(c, p, c === topC)); } return out.join("");}function resultHtml(r, kind, lang, detected) { let pairs = r.choices.map((c, i) => [c, r.probs[i]]); if (kind !== "score") pairs = pairs.sort((a, b) => b[1] - a[1]); const n = pairs.length, t = top(r); const orderNote = { score: "levels in the order you gave them (low → high)", rank: "each option scored on its own — they need not add up to 100%" }[kind] || "sorted by probability"; const langNote = `${LANG_NAME[lang] || lang}${detected ? " (detected)" : ""}`; const coldNote = r.cold ? ' <span class="dz-dim">— includes encoding this new option set once; it is cached now, run it again to see the steady-state time</span>' : ""; return `<div class="dz-card dz-result"> <div class="dz-eyebrow">Decision · ${esc(kind)} · ${n} option${n !== 1 ? "s" : ""} · ${esc(langNote)}</div> <div class="dz-answer" dir="auto">${esc(t)}</div> <div class="dz-meta">${confBadge(confidence(r), kind)} <span class="dz-time">decided in <b>${Math.round(r.latency_ms)} ms</b> in your browser${coldNote}</span></div> <div class="dz-ledger">${scaleHtml()}${rowsHtml(pairs, t, n > 15 ? 12 : 0)}</div> <div class="dz-foot">${esc(orderNote)}</div></div>`;}const messageHtml = (title, body) => `<div class="dz-card dz-result dz-msg"><div class="dz-eyebrow">${esc(title)}</div><p>${esc(body)}</p></div>`;const busyHtml = (text) => `<div class="dz-card dz-result dz-msg"><span class="dz-busy">${esc(text)}</span></div>`;const waitText = () => (loadStats ? "Deciding…" : "Waiting for the model to finish loading…");
// ───────────────────────────── tab 1 · try it ─────────────────────────────
let tryToken = 0;
async function decideUi() { const state = $("#in-state").value.trim(), question = $("#in-question").value.trim(); const kind = $('input[name="kind"]:checked').value, langSel = $("#in-lang").value; const choices = [...new Set($("#in-options").value.split(/\r\n|\n|\r/).map((c) => c.trim()).filter(Boolean))]; const out = $("#out"); if (!state) return (out.innerHTML = messageHtml("Missing situation", "Describe the situation: a message, a ticket, a document excerpt.")); if (!question) return (out.innerHTML = messageHtml("Missing question", "Ask a question about the situation, e.g. “Which team should handle this?”.")); if (choices.length < 2) return (out.innerHTML = messageHtml("Need options", "Give at least two options, one per line.")); if (choices.length > MAX_OPTIONS) return (out.innerHTML = messageHtml("Too many options", `This demo takes up to ${MAX_OPTIONS} options (cost grows with every option).`)); if (kind === "verify" && choices.length !== 2) return (out.innerHTML = messageHtml("verify takes exactly two options", "Use two options such as “yes” and “no”, or switch to choose.")); const detected = langSel === "auto"; const lang = detected ? detectLang(state) : langSel; const token = ++tryToken; const go = $("#go"); go.setAttribute("aria-busy", "true"); if (!out.querySelector(".dz-result") || !loadStats) out.innerHTML = busyHtml(waitText()); try { const r = await decide(state, { text: question, choices, kind, lang }); if (token === tryToken) out.innerHTML = resultHtml(r, kind, lang, detected); } catch (e) { if (token === tryToken) out.innerHTML = messageHtml("Could not decide", e.message); } finally { if (token === tryToken) go.removeAttribute("aria-busy"); }}
function galleryHtml(cards) { return cards.map((g) => { const rec = g.recorded; return `<button class="dz-ex" data-id="${esc(g.id)}" type="button"> <span class="dz-ex-tag">${esc(g.tag)}</span> <span class="dz-ex-title">${esc(g.title)}</span> <span class="dz-ex-state" dir="auto">${esc(g.state)}</span> <span class="dz-ex-out"><span dir="auto">→ <b>${esc(rec.top)}</b> · ${pct(rec.confidence)}</span><span class="dz-ex-n">${g.choices.length} options · recorded answer</span></span></button>`; }).join("");}
function loadCard(g) { $("#in-state").value = g.state; $("#in-question").value = g.question; $("#in-options").value = g.choices.join("\n"); $(`input[name="kind"][value="${g.kind}"]`).checked = true; $("#in-lang").value = g.lang; $$(".dz-ex").forEach((c) => c.classList.toggle("is-active", c.dataset.id === g.id)); const out = $("#try-form"); if (out.getBoundingClientRect().top < 0) out.scrollIntoView({ behavior: matchMedia("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth", block: "start" }); return decideUi();}
// ───────────────────────────── tab 2 · business cases ─────────────────────────────
function caseLabel(c) { const dom = DOMAIN_NAME[c.domain] || c.domain.replace(/_/g, " ").replace(/\b\w/g, (m) => m.toUpperCase()); const langs = LN[c.state_lang] + (c.choice_lang === c.state_lang ? "" : ` → ${LN[c.choice_lang]} options`); return [dom, langs];}function casesHtml(cases) { return cases.map((c, i) => { const [dom, langs] = caseLabel(c); return `<button class="dz-case${i === 0 ? " is-active" : ""}" data-id="${i}" type="button"> <span class="dz-ex-tag">${esc(dom)} · ${esc(langs)}</span> <span class="dz-case-title">${esc(c.scenario[0].toUpperCase() + c.scenario.slice(1))}</span> <span class="dz-case-agree"><b>${c.agree}/${c.n}</b> answers match the teacher</span></button>`; }).join("");}const lines = (text, cls = "") => text.split("\n").map((l) => `<div dir="auto"${cls ? ` class="${cls}"` : ""}>${esc(l) || " "}</div>`).join("");function docHtml(state, cut) { if (!cut || cut >= state.length) return lines(state); return lines(state.slice(0, cut)) + '<div class="dz-cut" role="separator"><span>Decima’s 512-token window ends about here — the teacher read the rest too</span></div>' + lines(state.slice(cut), "dz-unread");}function questionHtml(q, k, dec) { const td = argmax(q.teacher), dd = dec ? argmax(dec) : -1; const idx = q.choices.map((_, j) => j); const order = q.kind === "score" ? idx : idx.sort((a, b) => q.teacher[b] - q.teacher[a]); const rows = order.map((j) => { const pt = q.teacher[j], pd = dec ? dec[j] : 0; return `<div class="dz-crow${j === dd ? " is-top" : ""}${j === td ? " is-ttop" : ""}${dec ? "" : " is-pending"}"> <div class="dz-label" dir="auto">${esc(q.choices[j])}</div> <div class="dz-pair"> <div class="dz-track">${dec ? `<div class="dz-fill" style="width:${Math.max(pd * 100, 0.35).toFixed(2)}%"></div>` : ""}</div> <div class="dz-track dz-teacher"><div class="dz-fill" style="width:${Math.max(pt * 100, 0.35).toFixed(2)}%"></div></div> </div> <div class="dz-pct2"><span>${dec ? pct(pd) : "…"}</span><span class="dz-dim">${pct(pt)}</span></div></div>`; }).join(""); const mark = !dec ? '<span class="dz-busy">Decima is reading…</span>' : dd === td ? '<span class="dz-badge dz-b-agree">✓ same answer</span>' : '<span class="dz-badge dz-b-disagree">✗ different answer</span>'; const kindNote = q.kind === "score" ? " · levels in order" : ""; return `<div class="dz-q" data-q="${k}"> <div class="dz-q-head"><span class="dz-q-n">Q${k + 1}</span><span class="dz-q-kind">${q.kind}${kindNote}</span>${mark}</div> <div class="dz-q-text" dir="auto">${esc(q.question)}</div> <div class="dz-cledger">${rows}</div></div>`;}function caseDetailHtml(c) { const [dom, langs] = caseLabel(c); return `<div class="dz-case-detail"> <div class="dz-case-meta"><span class="dz-eyebrow">${esc(dom)} · ${esc(langs)} · ${esc(c.format)}</span></div> <div class="dz-doc" aria-label="The situation">${docHtml(c.state, c.window_end_char)}</div> <div class="dz-legend"><span><i class="dz-sw dz-sw-d"></i>Decima-small · 122M · int8, live in your browser</span> <span><i class="dz-sw dz-sw-t"></i>Teacher · Gemma-4-26B-A4B (recorded)</span> <span class="dz-dim">rows sorted by the teacher; bold = Decima’s pick</span></div> ${c.questions.map((q, k) => questionHtml(q, k, null)).join("")}</div>`;}let caseToken = 0;const caseResults = new Map(); // "case:question" → live Decima probabilitiesasync function showCase(D, i) { const c = D.business.cases[i]; const token = ++caseToken; $$(".dz-case").forEach((b) => b.classList.toggle("is-active", Number(b.dataset.id) === i)); $("#case-view").innerHTML = caseDetailHtml(c); for (let k = 0; k < c.questions.length; k++) { const q = c.questions[k]; const key = `${i}:${k}`; let probs = caseResults.get(key); if (!probs) { try { probs = (await decide(c.state, { text: q.question, choices: q.choices, kind: q.kind, lang: c.state_lang })).probs; caseResults.set(key, probs); } catch (e) { return; } } if (token !== caseToken) return; $(`.dz-q[data-q="${k}"]`).outerHTML = questionHtml(q, k, probs); } // The card counts were recorded with native ONNX Runtime; show the count from this browser's run instead. // (WebAssembly computes the int8 layers with float activations, so a near-tie can land the other way.) const agree = c.questions.filter((q, k) => argmax(caseResults.get(`${i}:${k}`)) === argmax(q.teacher)).length; const b = $(`.dz-case[data-id="${i}"] .dz-case-agree b`); if (b) b.textContent = `${agree}/${c.questions.length}`;}function businessSummaryHtml(B) { const s = B.shown, p = B.pool; return `<div class="dz-note"> <p><b>${s.cases} long cases, every question shown: Decima gives the teacher’s answer on ${s.agree} of ${s.questions}.</b> We picked these cases <i>because</i> Decima mostly agrees on them. Across <b>all ${p.cases.toLocaleString("en")}</b> held-out cases it agrees on only <b>${p.agree.toLocaleString("en")} of ${p.questions.toLocaleString("en")}</b> questions (${Math.round(p.agree / p.questions * 100)}%) — most of those documents are longer than the 512 tokens Decima reads. Long, multi-fact decisions are this model’s weakest area; the teacher, a 26B model, is not always right either.</p> <p class="dz-dim">The model never trained on these cases: they come from rows of the synthetic set that were generated after the training snapshot. ${esc(B.attribution)}</p></div>`;}
// ───────────────────────────── tab 3 · shuffle ─────────────────────────────
const shuf = { preset: null, order: [], tally: { n: 0, flips: 0, max: 0 }, token: 0 };function orderedLedger(title, choices, probs, topC, permFrom) { const rows = choices.map((c, i) => { const p = probs[c]; let moved = ""; if (permFrom) { const j = permFrom.indexOf(c) + 1; moved = j !== i + 1 ? `<span class="dz-pos">was #${j}</span>` : '<span class="dz-pos">same place</span>'; } return `<div class="dz-row${c === topC ? " is-top" : ""}"><div class="dz-label" dir="auto"><span class="dz-idx">${i + 1}</span>${esc(c)} ${moved}</div><div class="dz-track"><div class="dz-fill" style="width:${Math.max(p * 100, 0.35).toFixed(2)}%"></div></div><div class="dz-pct">${pct(p)}</div></div>`; }).join(""); return `<div class="dz-card dz-shuf"><div class="dz-eyebrow">${esc(title)}</div><div class="dz-ledger">${rows}</div></div>`;}function fmtDelta(x) { if (x === 0) return "0 (identical)"; const [m, e] = x.toExponential(1).split("e"); return `${m} × 10<sup>${Number(e)}</sup>`;}const asDict = (r) => Object.fromEntries(r.choices.map((c, i) => [c, r.probs[i]]));const same = (a, b) => a.length === b.length && a.every((v, i) => v === b[i]);
async function shuffleRender(p, state, order, bump) { const token = ++shuf.token; const out = $("#shuf-out"); if (!out.firstElementChild || !loadStats) out.innerHTML = busyHtml(waitText()); const q = { text: p.question, kind: p.kind, lang: p.lang }; let r0, r1; try { r0 = await decide(state, { ...q, choices: p.choices }); r1 = await decide(state, { ...q, choices: order }); } catch (e) { out.innerHTML = messageHtml("Could not decide", e.message); return; } if (token !== shuf.token) return; const a = asDict(r0), b = asDict(r1); const delta = Math.max(...p.choices.map((c) => Math.abs(a[c] - b[c]))); const t0 = top(r0), t1 = top(r1), changed = t0 !== t1; if (bump) shuf.tally = { n: shuf.tally.n + 1, flips: shuf.tally.flips + (changed ? 1 : 0), max: Math.max(shuf.tally.max, delta) }; const t = shuf.tally; out.innerHTML = `<div class="dz-shuf-grid">${orderedLedger("Options as listed", p.choices, a, t0)}${orderedLedger("Same options, shuffled", order, b, t1, p.choices)}</div><div class="dz-verdict"> <div><div class="dz-eyebrow">Answer</div><div class="dz-big" dir="auto">${changed ? "changed" : "unchanged"} — ${esc(t1)}</div></div> <div><div class="dz-eyebrow">Largest probability change</div><div class="dz-big dz-mono">${fmtDelta(delta)}</div></div> <div><div class="dz-eyebrow">This session</div><div class="dz-big">${t.n} shuffle${t.n !== 1 ? "s" : ""} · ${t.flips} answer change${t.flips !== 1 ? "s" : ""}</div> <div class="dz-dim">largest change seen: ${fmtDelta(t.max)}</div></div></div>`;}function shuffleReset(D) { const p = D.gallery.shuffle[Number($("#shuf-preset").value)]; shuf.preset = p; shuf.order = [...p.choices]; shuf.tally = { n: 0, flips: 0, max: 0 }; $("#shuf-state").value = p.state; return shuffleRender(p, p.state, shuf.order, false);}function shuffleClick() { const p = shuf.preset; const state = $("#shuf-state").value.trim() || p.state; let next = [...p.choices]; const shuffleArr = (a) => { for (let i = a.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [a[i], a[j]] = [a[j], a[i]]; } }; if (next.length > 1) while (same(next, p.choices) || same(next, shuf.order)) shuffleArr(next); shuf.order = next; return shuffleRender(p, state, next, true);}
// ───────────────────────────── charts (inline SVG) ─────────────────────────────
const tip = document.createElement("div");tip.className = "dz-tip"; tip.hidden = true; tip.setAttribute("role", "tooltip");document.body.appendChild(tip);function bindTips(svg) { svg.addEventListener("pointermove", (e) => { const t = e.target.closest("[data-tip]"); if (!t) { tip.hidden = true; return; } tip.innerHTML = t.dataset.tip; tip.hidden = false; const w = tip.offsetWidth, h = tip.offsetHeight; tip.style.left = `${Math.min(innerWidth - w - 8, e.clientX + 12)}px`; tip.style.top = `${Math.max(8, e.clientY - h - 12)}px`; }); svg.addEventListener("pointerleave", () => (tip.hidden = true));}
function routeChart(rs, th, width) { const W = Math.max(300, width), H = 250, L = 14, R = 14, T = 14, B = 44; const x = (v) => L + ((Math.max(0.3, Math.min(1, v)) - 0.3) / 0.7) * (W - L - R); const y = (v) => T + ((0.62 - v) / 1.24) * (H - T - B); const ticks = [0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]; let g = ticks.map((t) => `<line class="grid" x1="${x(t)}" x2="${x(t)}" y1="${T}" y2="${H - B}"/><text class="axis-t" x="${x(t)}" y="${H - B + 16}" text-anchor="middle">${t.toFixed(1)}</text>`).join(""); g += `<rect class="band" x="${x(0.3)}" y="${T}" width="${x(th) - x(0.3)}" height="${H - B - T}"/>`; g += `<text class="zone" x="${(x(0.3) + x(th)) / 2}" y="${y(-0.52)}" text-anchor="middle">escalate to a person</text>`; g += `<text class="zone" x="${(x(th) + x(1)) / 2}" y="${y(-0.52)}" text-anchor="middle">route automatically</text>`; g += `<line class="th" x1="${x(th)}" x2="${x(th)}" y1="${T}" y2="${H - B}"/>`; const anchorEnd = th > 0.85; g += `<text class="th-t" x="${x(th) + (anchorEnd ? -6 : 6)}" y="${y(0.52)}" text-anchor="${anchorEnd ? "end" : "start"}">threshold ${th.toFixed(2)}</text>`; // spread marks over five rows by confidence rank, so neighbours on the x axis never share a row const rank = new Map([...rs].sort((a, b) => a.conf - b.conf).map((r, i) => [r, i])); rs.forEach((r) => { const cx = x(r.conf), cy = y(((rank.get(r) % 5) - 2) * 0.16); const tipText = `${esc(r.text.slice(0, 70))}${r.text.length > 70 ? "…" : ""}<br>→ <b>${esc(r.top)}</b> (${r.conf.toFixed(3)})<br>expected: ${esc(r.gold)}`; g += r.ok ? `<circle class="ok" cx="${cx}" cy="${cy}" r="5.5"/>` : `<path class="bad" d="M${cx - 5} ${cy - 5}L${cx + 5} ${cy + 5}M${cx - 5} ${cy + 5}L${cx + 5} ${cy - 5}"/>`; g += `<circle class="hit" cx="${cx}" cy="${cy}" r="11" data-tip="${esc(tipText)}"/>`; }); g += `<text class="axis-l" x="${(L + W - R) / 2}" y="${H - 6}" text-anchor="middle">model confidence (top probability)</text>`; return `<svg class="dz-chart" viewBox="0 0 ${W} ${H}" width="${W}" height="${H}" role="img" aria-label="Twenty tickets placed by model confidence; the threshold line splits automatic routing from escalation. The table below lists the same data.">${g}</svg>`;}
function speedChart(live, width) { const W = Math.max(300, width), H = 300, L = 48, R = 96, T = 14, B = 46; const xs = [4, 20, 77, 150]; const ymax = Math.max(140, ...Object.values(live || {}).map((v) => v * 1.12)); const step = ymax > 600 ? 200 : ymax > 300 ? 100 : 50; const x = (v) => L + (v / 150) * (W - L - R); const y = (v) => T + (1 - v / ymax) * (H - T - B); let g = ""; for (let t = 0; t <= ymax; t += step) g += `<line class="grid" x1="${L}" x2="${W - R}" y1="${y(t)}" y2="${y(t)}"/><text class="axis-t" x="${L - 8}" y="${y(t) + 4}" text-anchor="end">${t}</text>`; g += xs.map((v) => `<text class="axis-t" x="${x(v)}" y="${H - B + 17}" text-anchor="middle">${v}</text>`).join(""); g += `<text class="axis-l" x="${(L + W - R) / 2}" y="${H - 6}" text-anchor="middle">number of options</text>`; g += `<text class="axis-l" transform="translate(13 ${(T + H - B) / 2}) rotate(-90)" text-anchor="middle">ms per decision</text>`; const series = (vals, cls, name) => { const pts = xs.filter((v) => vals[v] != null).map((v) => [x(v), y(vals[v]), v, vals[v]]); let s = `<path class="${cls}" d="${pts.map((p, i) => `${i ? "L" : "M"}${p[0]} ${p[1]}`).join("")}"/>`; for (const [px, py, v, ms] of pts) { s += `<circle class="${cls}-dot" cx="${px}" cy="${py}" r="4.5"/>`; s += `<circle class="hit" cx="${px}" cy="${py}" r="12" data-tip="${esc(`<b>${name}</b><br>${v} options: ${ms.toFixed(1)} ms`)}"/>`; } const last = pts.at(-1); if (last) s += `<text class="lbl" x="${last[0] + 10}" y="${last[1] + 4}">${Math.round(last[3])} ms</text>`; return s; }; g += series(X86_SCALING, "ref", "x86 laptop core, reference"); if (live) g += series(live, "live", "your browser, live (p50)"); return `<svg class="dz-chart" viewBox="0 0 ${W} ${H}" width="${W}" height="${H}" role="img" aria-label="Milliseconds per decision against the number of options: x86 reference${live ? " and your browser" : ""}. The table lists the same numbers.">${g}</svg>`;}
// ───────────────────────────── tab 4 · auto-route ─────────────────────────────
let routeResults = null;async function scoreTickets(D) { if (routeResults) return routeResults; const out = $("#route-out"); out.innerHTML = busyHtml(loadStats ? `Scoring ${D.tickets.length} tickets in your browser…` : waitText()); await ready; out.innerHTML = busyHtml(`Scoring ${D.tickets.length} tickets in your browser…`); const items = D.tickets.map((t) => ({ state: t.text, q: { text: TEAM_Q, choices: TEAMS, kind: "choose", lang: t.lang } })); const t0 = performance.now(); const rs = await call("decideMany", { items }); const ms = performance.now() - t0; routeResults = D.tickets.map((t, i) => ({ ...t, top: top(rs[i]), conf: confidence(rs[i]), ok: top(rs[i]) === t.gold, probs: rs[i].probs })); routeResults.ms = ms; return routeResults;}function routeUpdate() { const rs = routeResults; if (!rs) return; const th = Number($("#th").value); $("#th-val").textContent = th.toFixed(2); const auto = rs.filter((r) => r.conf >= th); const right = auto.filter((r) => r.ok).length; const escN = rs.length - auto.length; const caught = rs.filter((r) => !r.ok && r.conf < th).length; const wrong = rs.filter((r) => !r.ok).length; const tiles = `<div class="dz-tiles"> <div class="dz-tile"><div class="dz-tile-n">${auto.length}<span>/${rs.length}</span></div><div class="dz-tile-l">routed automatically</div></div> <div class="dz-tile"><div class="dz-tile-n">${right}<span>/${auto.length}</span></div><div class="dz-tile-l">of those went to the right team</div></div> <div class="dz-tile"><div class="dz-tile-n">${escN}</div><div class="dz-tile-l">escalated to a person — ${caught} of the ${wrong} wrong answer${wrong !== 1 ? "s" : ""} among them</div></div></div>`; const rows = [...rs].sort((a, b) => b.conf - a.conf).map((r) => { const a = r.conf >= th; return `<tr class="${a ? "is-auto" : "is-esc"}"><td><span class="dz-badge ${a ? "dz-b-high" : "dz-b-mid"}">${a ? "auto" : "escalate"}</span></td><td class="dz-mono">${r.conf.toFixed(3)}</td><td dir="auto">${esc(r.text)}</td><td>${esc(r.lang)}</td><td>${esc(r.top)}</td><td>${r.ok ? '<span class="dz-ok">✓</span>' : `<span class="dz-bad">✗</span> <span class="dz-dim">expected ${esc(r.gold)}</span>`}</td></tr>`; }).join(""); const out = $("#route-out"); const width = out.clientWidth - 26; out.innerHTML = `${tiles}<div class="dz-plot"><div class="dz-legend-row"><span><i class="dz-k-ok"></i>right team</span><span><i class="dz-k-bad"></i>wrong team</span><span class="dz-dim">scored in your browser in ${(rs.ms / 1000).toFixed(1)} s · hover a mark for the ticket</span></div>${routeChart(rs, th, width)}</div><div class="dz-table-wrap"><table class="dz-table"><thead><tr><th>decision</th><th>confidence</th><th>ticket</th><th>lang</th><th>model’s team</th><th>right?</th></tr></thead><tbody>${rows}</tbody></table></div>`; bindTips($("#route-out svg"));}
// ───────────────────────────── tab 5 · speed ─────────────────────────────
let speedLive = null;function drawSpeed() { const el = $("#sp-plot"); const legend = `<div class="dz-legend-row"><span><i class="dz-k-ref"></i>x86 laptop core, reference (BENCH-x86)</span>${speedLive ? '<span><i class="dz-k-live"></i>your browser, live (p50)</span>' : ""}</div>`; el.innerHTML = legend + speedChart(speedLive, el.clientWidth - 26); bindTips($("svg", el));}async function speedRun(D) { const btn = $("#sp-go"); if (btn.getAttribute("aria-busy")) return; btn.setAttribute("aria-busy", "true"); const reps = 12; const rows = []; const live = {}; const table = $("#sp-table"); try { table.innerHTML = busyHtml(waitText()); await ready; for (const n of [4, 20, 77, 150]) { table.innerHTML = busyHtml(`Timing ${n} options… (${reps + 1} decisions)`); const q = { text: "What is the customer asking about?", choices: D.speedSets[n], kind: "choose", lang: "en" }; const { first, lat } = await call("bench", { state: "I was charged twice for my subscription this month.", q, reps }); lat.sort((a, b) => a - b); const p50 = lat.length % 2 ? lat[(lat.length - 1) / 2] : (lat[lat.length / 2 - 1] + lat[lat.length / 2]) / 2; const p95 = lat[Math.min(lat.length - 1, Math.round(0.95 * (lat.length - 1)))]; live[n] = p50; speedLive = { ...live }; drawSpeed(); rows.push(`<tr><td class='dz-mono'>${n}</td><td class='dz-mono'><b>${p50.toFixed(1)}</b></td><td class='dz-mono'>${p95.toFixed(1)}</td>` + `<td class='dz-mono'>${X86_SCALING[n]}</td><td class='dz-mono'>${Math.round(first)}</td></tr>`); } const ua = navigator.userAgentData?.brands?.filter((b) => !/Not.A.Brand/i.test(b.brand)).map((b) => b.brand).at(-1) || ""; table.innerHTML = `<div class="dz-table-wrap"><table class="dz-table dz-num"><thead><tr><th>options</th><th>p50 ms · your browser</th><th>p95 ms · your browser</th><th>p50 ms · x86 reference</th><th>first call ms · your browser</th></tr></thead><tbody>${rows.join("")}</tbody></table></div><p class="dz-dim dz-small">Live: this tab${ua ? ` (${esc(ua)})` : ""}, ${navigator.hardwareConcurrency || "?"} logical cores reported, ${loadStats.threads} WebAssembly thread${loadStats.threads > 1 ? "s" : ""},int8 ONNX on ONNX Runtime Web, batch 1, ${reps} timed calls per size after the first, short state. The first call also encodes the optionset (once per set). Background tabs and battery saving slow it down — run it twice. Reference: Intel Core Ultra 7 155H, one P-core,native ONNX Runtime, 40 calls per size (docs/BENCH-x86.md).</p>`; } catch (e) { table.innerHTML = messageHtml("The sweep stopped", e.message); } finally { btn.removeAttribute("aria-busy"); }}
// ───────────────────────────── page wiring ─────────────────────────────
const TABS = ["try", "cases", "shuffle", "route", "speed"];const opened = new Set();function selectTab(name, D, focus = false) { if (!TABS.includes(name)) name = "try"; for (const t of TABS) { const on = t === name; const b = $(`#tab-${t}`); b.setAttribute("aria-selected", on); b.tabIndex = on ? 0 : -1; $(`#p-${t}`).hidden = !on; if (on && focus) b.focus(); } if (location.hash.slice(1) !== name) history.replaceState(null, "", name === "try" ? location.pathname + location.search : `#${name}`); if (opened.has(name)) { if (name === "route") routeUpdate(); if (name === "speed") drawSpeed(); return; } opened.add(name); if (name === "cases") showCase(D, 0); if (name === "shuffle") shuffleReset(D); if (name === "route") scoreTickets(D).then(routeUpdate).catch((e) => ($("#route-out").innerHTML = messageHtml("Could not score the tickets", e.message))); if (name === "speed") drawSpeed();}
function initTheme() { const root = document.documentElement; $("#theme").addEventListener("click", () => { const dark = !root.classList.contains("dark"); root.classList.toggle("dark", dark); try { localStorage.setItem("dz-theme", dark ? "dark" : "light"); } catch {} }); matchMedia("(prefers-color-scheme: dark)").addEventListener("change", (e) => { let saved = null; try { saved = localStorage.getItem("dz-theme"); } catch {} if (!saved) root.classList.toggle("dark", e.matches); });}
async function main() { initTheme(); $("#out").innerHTML = busyHtml("Waiting for the model to finish loading…"); const D = await dataReady;
// try it $("#gallery").innerHTML = galleryHtml(D.cards); $("#gallery").addEventListener("click", (e) => { const card = e.target.closest("[data-id]"); if (card) loadCard(D.byId[card.dataset.id]); }); $("#try-form").addEventListener("submit", (e) => { e.preventDefault(); decideUi(); }); $("#in-state").addEventListener("keydown", (e) => { if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) { e.preventDefault(); decideUi(); } });
// business cases $("#cases-summary").innerHTML = businessSummaryHtml(D.business); $("#case-list").innerHTML = casesHtml(D.business.cases); $("#case-list").addEventListener("click", (e) => { const b = e.target.closest("[data-id]"); if (b) showCase(D, Number(b.dataset.id)); });
// shuffle $("#shuf-preset").innerHTML = D.gallery.shuffle.map((p, i) => `<option value="${i}">${esc(p.title)}</option>`).join(""); $("#shuf-preset").addEventListener("change", () => shuffleReset(D)); $("#shuf-go").addEventListener("click", () => shuffleClick()); $("#shuf-state").addEventListener("keydown", (e) => { if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); shuffleRender(shuf.preset, $("#shuf-state").value.trim() || shuf.preset.state, shuf.order, false); } });
// auto-route + speed $("#th").addEventListener("input", routeUpdate); $("#sp-go").addEventListener("click", () => speedRun(D)); let rt; addEventListener("resize", () => { clearTimeout(rt); rt = setTimeout(() => { if (!$("#p-route").hidden) routeUpdate(); if (!$("#p-speed").hidden) drawSpeed(); }, 150); });
// tabs $$(".dz-tab").forEach((b, i) => { b.addEventListener("click", () => selectTab(TABS[i], D)); b.addEventListener("keydown", (e) => { const d = { ArrowRight: 1, ArrowLeft: -1 }[e.key]; if (d) { e.preventDefault(); selectTab(TABS[(i + d + TABS.length) % TABS.length], D, true); } }); }); addEventListener("hashchange", () => selectTab(location.hash.slice(1), D)); selectTab(location.hash.slice(1), D);
$("#forget").addEventListener("click", async () => { const ok = await call("clearCache").catch(() => false); $("#forget").textContent = ok ? "Removed — the next visit downloads it again." : "Nothing cached on this device."; });
// first decision, like the Gradio version's on-load run ready.then(() => decideUi(), () => ($("#out").innerHTML = messageHtml("The model could not be loaded", "See the message at the top of the page.")));}
// hook for automated checks (parity tests, screenshots)window.DZ = { ready, decide: (state, q) => decide(state, q), data: dataReady, stats: () => loadStats, call };
main();123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234// Decima runtime for the browser — a line-for-line port of decima/runtime.py (DecimaOnnx) and// decima/normalize.py on ONNX Runtime Web (WASM) + tokenizers.js. No server: everything runs here.//// const d = await Decima.load(MODEL_URL, {ort, Tokenizer, onProgress});// d.decide("My card was stolen", {text: "What does the customer want?", choices: ["block card", "check balance"],// kind: "choose", lang: "en"}) // → {probs, choices, latency_ms, cold}
// ───────────────────────── normalize.py ─────────────────────────
const TASHKEEL = /[ؐ-ًؚ-ٰٟۖ-ۭ]/gu;const TATWEEL = /ـ/g;const DIGITS = {};[..."٠١٢٣٤٥٦٧٨٩"].forEach((c, i) => (DIGITS[c] = String(i)));[..."۰۱۲۳۴۵۶۷۸۹"].forEach((c, i) => (DIGITS[c] = String(i)));const TO_PERSIAN = { "ي": "ی", "ى": "ی", "ك": "ک", "ة": "ه", "ؤ": "و", "إ": "ا", "أ": "ا" };const TO_ARABIC = { "ی": "ي", "ک": "ك" };// Python's str.strip() whitespace set (differs from JS trim(): includes \x1c-\x1f and \x85, excludes )const PY_WS = "\\t\\n\\x0b\\x0c\\r\\x1c-\\x1f \\x85\\xa0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000";const PY_STRIP = new RegExp(`^[${PY_WS}]+|[${PY_WS}]+$`, "g");const pyStrip = (s) => s.replace(PY_STRIP, "");const mapChars = (s, table) => s.replace(/./gsu, (c) => table[c] ?? c);
export function normalize(text, lang = "en") { text = text.normalize("NFC"); if (lang !== "fa" && lang !== "ar") return pyStrip(text); text = text.replace(TASHKEEL, "").replace(TATWEEL, ""); text = mapChars(text, DIGITS); text = mapChars(text, lang === "fa" ? TO_PERSIAN : TO_ARABIC); return pyStrip(text.replace(/[ \t]+/g, " "));}
// Only Persian vs Arabic changes what the model sees; the rest is for display (same as app.py detect_lang).export function detectLang(text) { const n = (re) => (text.match(re) || []).length; const counts = { ar: n(/[-ۿ]/g), ru: n(/[Ѐ-ӿ]/g), zh: n(/[一-鿿]/g), ja: n(/[-ヿ]/g), ko: n(/[가-]/g), hi: n(/[ऀ-ॿ]/g), el: n(/[Ͱ-Ͽ]/g), th: n(/[-]/g), }; let best = "ar"; for (const k in counts) if (counts[k] > counts[best]) best = k; if (counts[best] === 0) return "latn"; if (best === "ar") return /[پچژگکی]/.test(text) ? "fa" : "ar"; if (best === "zh" && counts.ja) return "ja"; return best;}
// ───────────────────────── math (runtime.py helpers) ─────────────────────────
function logSoftmax(x) { const m = Math.max(...x); const y = x.map((v) => v - m); const lse = Math.log(y.reduce((a, v) => a + Math.exp(v), 0)); return y.map((v) => v - lse);}const sigmoid = (x) => 1 / (1 + Math.exp(-x));const softplus = (x) => Math.max(x, 0) + Math.log1p(Math.exp(-Math.abs(x))); // np.logaddexp(0, x)
// ───────────────────────── model download with cache ─────────────────────────
const CACHE_NAME = "decima-small-model-v1";
async function openCache() { try { return typeof caches !== "undefined" ? await caches.open(CACHE_NAME) : null; } catch { return null; }}
/** Fetch files, reporting combined progress; cached with the Cache API so the next visit skips the network. */export async function fetchFiles(files, onProgress = () => {}) { const cache = await openCache(); const state = files.map((f) => ({ loaded: 0, total: f.size || 0, cached: false })); const report = () => { const loaded = state.reduce((a, s) => a + s.loaded, 0), total = state.reduce((a, s) => a + s.total, 0); onProgress({ loaded, total, cached: state.every((s) => s.cached) }); }; return Promise.all(files.map(async (f, i) => { const s = state[i]; let res = cache ? await cache.match(f.url).catch(() => null) : null; if (res) { const buf = await res.arrayBuffer(); Object.assign(s, { loaded: buf.byteLength, total: buf.byteLength, cached: true }); report(); return buf; } res = await fetch(f.url, { mode: "cors" }); if (!res.ok) throw new Error(`${f.url}: HTTP ${res.status}`); const len = Number(res.headers.get("content-length")) || 0; if (len && !res.headers.get("content-encoding")) s.total = len; const reader = res.body.getReader(); const parts = []; for (;;) { const { done, value } = await reader.read(); if (done) break; parts.push(value); s.loaded += value.byteLength; if (s.loaded > s.total) s.total = s.loaded; report(); } const buf = new Uint8Array(s.loaded); let o = 0; for (const p of parts) { buf.set(p, o); o += p.byteLength; } s.total = s.loaded; report(); if (cache) cache.put(f.url, new Response(buf.slice().buffer, { headers: { "content-type": "application/octet-stream" } })).catch(() => {}); return buf.buffer; }));}
export async function clearCache() { try { return await caches.delete(CACHE_NAME); } catch { return false; }}
// ───────────────────────── runtime.py · DecimaOnnx ─────────────────────────
// approximate sizes of the int8 export, for the progress bar before Content-Length arrivesconst SIZES = { "encoder.onnx": 122164246, "scorer.onnx": 4915472, "decima.json": 22464, "tokenizer/tokenizer.json": 17100000, "tokenizer/tokenizer_config.json": 700 };
export class Decima { static async load(baseUrl, { ort, Tokenizer, onProgress, numThreads = 1 } = {}) { if (!baseUrl.endsWith("/")) baseUrl += "/"; const names = ["encoder.onnx", "scorer.onnx", "decima.json", "tokenizer/tokenizer.json", "tokenizer/tokenizer_config.json"]; const t0 = performance.now(); const bufs = await fetchFiles(names.map((n) => ({ url: baseUrl + n, size: SIZES[n] })), onProgress); const tDownload = performance.now() - t0; const dec = new TextDecoder(); const json = (b) => JSON.parse(dec.decode(b)); const opts = { executionProviders: ["wasm"], graphOptimizationLevel: "all" }; ort.env.wasm.numThreads = numThreads; const enc = await ort.InferenceSession.create(new Uint8Array(bufs[0]), opts); const sc = await ort.InferenceSession.create(new Uint8Array(bufs[1]), opts); const d = new Decima(ort, enc, sc, json(bufs[2]), new Tokenizer(json(bufs[3]), json(bufs[4]))); d.stats = { download_ms: tDownload, init_ms: performance.now() - t0 - tDownload, bytes: bufs.reduce((a, b) => a + b.byteLength, 0) }; return d; }
constructor(ort, enc, sc, cfg, tok) { this.ort = ort; this.enc = enc; this.sc = sc; this.cfg = cfg; this.tok = tok; const o = cfg.ordinal; this.ord = [Float64Array.from(o.ord_g_w), o.ord_g_b, Float64Array.from(o.ord_gap_w), o.ord_gap_b]; this.cache = new Map(); this.pad = tok.token_to_id("<pad>") ?? 1; this.eos = tok.token_to_id("</s>") ?? 2; }
/** Token ids with special tokens, truncated like HF `truncation=True, max_length` (right side, keep </s>). */ ids(text, maxLen) { const ids = this.tok.encode(text).ids; return ids.length <= maxLen ? ids : [...ids.slice(0, maxLen - 1), this.eos]; }
async encode(texts, maxLen) { const rows = texts.map((t) => this.ids(t, maxLen)); const L = Math.max(...rows.map((r) => r.length)); const ids = new BigInt64Array(rows.length * L).fill(BigInt(this.pad)); const mask = new BigInt64Array(rows.length * L); rows.forEach((r, i) => r.forEach((id, j) => { ids[i * L + j] = BigInt(id); mask[i * L + j] = 1n; })); const T = this.ort.Tensor; const m = new T("int64", mask, [rows.length, L]); const out = await this.enc.run({ input_ids: new T("int64", ids, [rows.length, L]), attention_mask: m }); return [out.token_states, m]; }
async choices(q) { const qt = this.cfg.question_in_choices ?? true ? q.text : ""; const key = JSON.stringify([qt, q.choices, q.lang]); if (this.cache.has(key)) return [this.cache.get(key), false]; if (this.cache.size > 256) this.cache.clear(); const pre = this.cfg.choice_prefix ?? "passage: "; const texts = q.choices.map((c) => pre + normalize(pyStrip(`${qt} ${c}`), q.lang)); const v = await this.encode(texts, this.cfg.max_choice_tokens); this.cache.set(key, v); return [v, true]; }
stateText(state, q) { const body = this.cfg.question_in_state ? `${q.text}\n${state}` : state; return (this.cfg.state_prefix ?? "query: ") + normalize(body, q.lang); }
hasChoices(q) { const qt = this.cfg.question_in_choices ?? true ? q.text : ""; return this.cache.has(JSON.stringify([qt, q.choices, q.lang])); }
ordinal(s, z, D) { const [gw, gb, pw, pb] = this.ord; const K = s.length; const sm = logSoftmax(s).map(Math.exp); const expected = sm.reduce((a, p, k) => a + p * k, 0) - (K - 1) / 2; let g = gb; for (let j = 0; j < D; j++) { let mean = 0; for (let k = 0; k < K; k++) mean += z[k * D + j]; g += (mean / K) * gw[j]; } g += expected; const gaps = []; for (let k = 0; k < K; k++) { let a = pb; for (let j = 0; j < D; j++) a += z[k * D + j] * pw[j]; gaps.push(softplus(a) + 1e-3); } const total = gaps.reduce((a, b) => a + b, 0); const theta = []; let c = 0; for (let k = 0; k < K - 1; k++) { c += gaps[k]; theta.push(c - total / 2); } const sig = theta.map((t) => sigmoid(g - t)); const p = []; for (let k = 0; k < K; k++) p.push((k === 0 ? 1 : sig[k - 1]) - (k === K - 1 ? 0 : sig[k])); return logSoftmax(p.map((v) => Math.log(Math.max(v, 1e-7)))); }
async decideLogits(state, q) { const [[ch, cm], cold] = await this.choices(q); const [h, m] = await this.encode([this.stateText(state, q)], this.cfg.max_state_tokens); const r = await this.sc.run({ state_h: h, state_mask: m, choice_h: ch, choice_mask: cm }); const s = Array.from(r.scores.data, (v) => v / this.cfg.temperature); let lp; if (q.kind === "score") lp = this.ordinal(s, r.z.data, r.z.dims[1]); else if (q.kind === "rank") lp = s.map((v) => -softplus(-v)); else lp = logSoftmax(s); return [lp, cold]; }
/** Probabilities over the question's choices (independent sigmoids for `rank`). */ async decide(state, q) { const t0 = performance.now(); const [lp, cold] = await this.decideLogits(state, q); let probs; if (q.kind === "rank") probs = lp.map(Math.exp); else { const m = Math.max(...lp); const e = lp.map((v) => Math.exp(v - m)); const z = e.reduce((a, b) => a + b, 0); probs = e.map((v) => v / z); } return { probs, choices: [...q.choices], latency_ms: performance.now() - t0, cold }; }}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677activate my cardage limitapple pay or google payatm supportautomatic top upbalance not updated after bank transferbalance not updated after cheque or cash depositbeneficiary not allowedcancel transfercard about to expirecard acceptancecard arrivalcard delivery estimatecard linkingcard not workingcard payment fee chargedcard payment not recognisedcard payment wrong exchange ratecard swallowedcash withdrawal chargecash withdrawal not recognisedchange pincompromised cardcontactless not workingcountry supportdeclined card paymentdeclined cash withdrawaldeclined transferdirect debit payment not recogniseddisposable card limitsedit personal detailsexchange chargeexchange rateexchange via appextra charge on statementfailed transferfiat currency supportget disposable virtual cardget physical cardgetting spare cardgetting virtual cardlost or stolen cardlost or stolen phoneorder physical cardpasscode forgottenpending card paymentpending cash withdrawalpending top uppending transferpin blockedreceiving moneyRefund not showing uprequest refundreverted card payment?supported cards and currenciesterminate accounttop up by bank transfer chargetop up by card chargetop up by cash or chequetop up failedtop up limitstop up revertedtopping up by cardtransaction charged twicetransfer fee chargedtransfer into accounttransfer not received by recipienttransfer timingunable to verify identityverify my identityverify source of fundsverify top upvirtual card not workingvisa or mastercardwhy verify identitywrong amount of cash receivedwrong exchange rate for cash withdrawal123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179{ "attribution": "Business cases: synthetic, generated and labelled by Gemma-4-26B-A4B for the Decima project; released under CC BY 4.0. Email addresses rewritten to reserved example domains.", "license": "CC-BY-4.0", "teacher": "Gemma-4-26B-A4B (26B, mixture of experts)", "model": "Decima-small v1i int8 ONNX", "held_out_rule": "rows of jevgen-rande-fast-local.jsonl whose id, group and state are absent from the training snapshot (lines 1–6,047); none of these cases was trained on", "pool_note": "pool = every held-out question, scored once before selection (only free-mail addresses rewritten at that point); the shown cases were re-scored on the exact published text", "pool": { "questions": 4239, "agree": 2334, "cases": 1122, "by_kind": { "choose": { "agree": 904, "n": 1850 }, "verify": { "agree": 881, "n": 1301 }, "score": { "agree": 549, "n": 1088 } } }, "shown": { "cases": 10, "questions": 40, "agree": 36 }, "cases": [ { "group": "jev-0-1807", "domain": "support_triage", "scenario": "account lockout after SSO migration", "format": "email thread with quoted replies", "state_lang": "ru", "choice_lang": "ru", "state": "From: Artyom Volkov <a.volkov@globex-solutions.example>\nTo: Support <support@cloudflow-systems.example>\nDate: 2024-01-21 09:14:22 +0300\nSubject: RE: [URGENT] Проблема с доступом к панели управления после миграции\n\nЗдравствуйте!\n\nУ нас критическая ситуация. С сегодняшнего утра (21.01.24) после планового перехода на Okta SSO у половины нашей команды (примерно 14 человек из 30) пропал доступ к CloudFlow Dashboard. \n\nПри попытке входа через корпоративный портал мы получаем ошибку:\n`Error Code: CF-AUTH-9922`\n`Message: Identity Provider mismatch. Expected SAML assertion from 'cloudflow-sso-prod', received 'legacy-auth-v2'.`\n\nЯ проверил настройки в нашем Azure AD, там всё должно быть настроено по вашему новому гайду (v.2.4.1). Но проблема сохраняется. При этом некоторые сотрудники (например, наш стажер Максим) всё еще могут заходить через старые учетные данные, хотя мы вроде как отключили локальный вход.\n\nПожалуйста, разберитесь максимально быстро. Мы не можем запускать отчетность для клиентов.\n\n---\nArtyom Volkov\nIT Infrastructure Lead | Globex Solutions\n--------------------------------------------------\n\nFrom: Support <support@cloudflow-systems.example>\nTo: Artyom Volkov <a.volkov@globex-solutions.example>\nDate: 2024-01-21 10:05:11 +0300\nSubject: RE: [URGENT] Проблема с доступом к панели управления после миграции\n\nУважаемый Артем,\n\nМеня зовут Елена, я ваш менеджер поддержки. Мне очень жаль, что вы столкнулись с этими трудностями.\n\nДля начала работы мне необходимо уточнить:\n1. Пришлите, пожалуйста, скриншот ошибки.\n2. Проверьте, не заблокированы ли учетные записи в вашей системе SSO.\n\nЯ передала ваш запрос в технический отдел.\n\nС уважением,\nElena Petrova\nCloudFlow Systems Support Team\n\n---\n[Internal Ticket Log: #CF-88291]\nTimestamp: 2024-01-21 10:12:05\nUser: Elena Petrova\nAction: Ticket escalated to Tier 2\nNote: Client reports SAML assertion mismatch. Possible misconfiguration in the SSO handshake during the migration window. Note that some users (ID: MAX-992) are still using legacy credentials, suggesting the legacy endpoint is still partially active for certain subnets or user groups.\nStatus: Open\nPriority: High\nMetadata:\n org_id: globex_772\n migration_version: 2.4.1\n error_string: \"Identity Provider mismatch\"", "source_lines": [ 6679, 6680, 6681, 6682 ], "agree": 4, "n": 4, "window_end_char": 1764, "questions": [ { "id": "4c5108cf642b5383", "kind": "verify", "question": "Все пользователи компании Globex Solutions полностью утратили возможность входа через локальные учетные данные?", "choices": [ "Да", "Нет" ], "teacher": [ 0.3, 0.7 ], "decima": [ 0.2921, 0.7079 ], "agree": true }, { "id": "182a8c5c490565db", "kind": "score", "question": "Оцените уровень критичности данного инцидента для бизнеса клиента:", "choices": [ "Низкий", "Средний", "Высокий" ], "teacher": [ 0.05, 0.15, 0.8 ], "decima": [ 0.0435, 0.21318, 0.74332 ], "agree": true }, { "id": "71cba6049e91ea4e", "kind": "verify", "question": "Проблема связана с несоответствием поставщика идентификации (Identity Provider)?", "choices": [ "Да", "Нет" ], "teacher": [ 0.85, 0.15 ], "decima": [ 0.89081, 0.10919 ], "agree": true }, { "id": "de0d7c5862f96b4e", "kind": "choose", "question": "К какой категории относится данный инцидент?", "choices": [ "Смена пароля", "Ошибка конфигурации SSO", "Физический доступ", "Проблема с биллингом", "Удаление аккаунта", "Ошибка UI", "Обновление ПО", "Проблема с API" ], "teacher": [ 0.02128, 0.90426, 0.01064, 0.01064, 0.01064, 0.01064, 0.02128, 0.01064 ], "decima": [ 0.01263, 0.41264, 0.22095, 0.20311, 0.01997, 0.06885, 0.0084, 0.05344 ], "agree": true } ] }, { "group": "jev-0-2292", "domain": "ecommerce", "scenario": "bulk B2B order change", "format": "seller-support ticket with order history", "state_lang": "en", "choice_lang": "en", "state": "SUPPORT TICKET #B2B-99281-X\nStatus: OPEN (Escalated)\nPriority: High\nCreated: 2024-11-21 09:14:22 UTC\nAgent: Marcus Thorne (Level 2 Support)\nCustomer: Aris Global Logistics (Account ID: AG-772-B)\nContact: Elena Vance (Procurement Lead)\n\n[INTERNAL LOG - ORDER_HISTORY_SERVICE]\n2024-11-19 14:02:11 [INFO] Order ID: ORD-44901-Z placed by AG-772-B. Total: $42,500.00. SKU count: 14.\n2024-11-20 11:30:45 [INFO] Order ID: ORD-44901-Z status changed to 'Processing'.\n2024-11-21 08:45:12 [WARN] Manual override detected on ORD-44901-Z. User: evance_aris.\n2024-11-21 08:46:01 [ERROR] Validation failed for SKU: WGT-99-B (Weight mismatch). Attempted update: +500kg. System rejected delta.\n\n---\nMESSAGE THREAD:\n\nElena Vance (09:05:12):\nHi Support, we need to adjust the shipment volume for ORD-44901-Z immediately. The previous quote for the industrial fasteners (SKU: WGT-99-B) was based on a palletized estimate, but our warehouse floor space just changed. We actually need to increase the quantity of the WGT-99-B units from 400 to 900. This is a critical component for our assembly line starting Friday. \n\nPlease note, we are aware the total order value will increase. However, the system is throwing a 'Validation failed' error when I try to push the update through the B2B portal. Can you manually push this change or bypass the weight check? We cannot wait for a full re-quote if it delays the dispatch.\n\nMarcus Thorne (09:14:22):\nElena, I've received your request. Looking at the logs, it appears the automated weight validation is blocking the SKU update because the new quantity (900 units) pushes the total pallet weight beyond the standard shipping profile set for this order type. \n\nI am checking with the fulfillment team at the Oakhaven Depot to see if they can accommodate the extra weight on the current carrier booking. I've also attached a copy of our 'Bulk Order Amendment Policy (v4.2)' which states: \"Any quantity increase exceeding 20% of the original line item volume requires a secondary freight audit before manual approval.\" Since your increase is 125%, the system is behaving as designed.\n\nPlease hold off on any further manual attempts in the portal to avoid locking the order. I will update this ticket once the freight audit is complete.\n\n[System Note: Ticket flagged for 'Manual Freight Audit' workflow.]", "source_lines": [ 8465, 8466, 8467, 8468 ], "agree": 4, "n": 4, "window_end_char": 1586, "questions": [ { "id": "dd818cca89806d2b", "kind": "verify", "question": "Does the requested increase for SKU WGT-99-B exceed the 20% threshold specified in the Bulk Order Amendment Policy?", "choices": [ "yes, it exceeds the threshold", "no, it does not exceed the threshold" ], "teacher": [ 0.99, 0.01 ], "decima": [ 0.72353, 0.27647 ], "agree": true }, { "id": "1cf82cb2b94438ee", "kind": "score", "question": "Rate the operational urgency of this request based on the customer's assembly requirements.", "choices": [ "Low", "Medium", "High", "Critical", "Extreme" ], "teacher": [ 0.05, 0.14999, 0.39996, 0.39996, 0.0001 ], "decima": [ 0.0175, 0.13722, 0.51462, 0.28557, 0.0451 ], "agree": true }, { "id": "6de63d8187c00259", "kind": "choose", "question": "What is the primary reason the system prevented the update?", "choices": [ "Payment failure", "Insufficient stock", "Weight validation error", "User permission error", "Invalid SKU format", "Shipping address mismatch", "Carrier unavailability", "Policy violation lockout" ], "teacher": [ 0.02, 0.02, 0.85, 0.05, 0.02, 0.01, 0.01, 0.02 ], "decima": [ 0.0206, 0.11761, 0.59304, 0.03239, 0.02481, 0.08238, 0.01508, 0.1141 ], "agree": true }, { "id": "be425e6d3baa47d7", "kind": "score", "question": "How certain is the support agent about the specific cause of the error?", "choices": [ "Low certainty", "Medium certainty", "High certainty" ], "teacher": [ 0.1, 0.3, 0.6 ], "decima": [ 0.26372, 0.36204, 0.37423 ], "agree": true } ] }, { "group": "jev-0-1973", "domain": "real_estate", "scenario": "maintenance request with safety implications", "format": "tenant portal message thread", "state_lang": "fa", "choice_lang": "en", "state": "[Portal Message Thread: #REQ-2025-8892]\n[Property Management System: Aras Management Services (AMS) - Version 4.2.1]\n[Unit: Apt 402, Blue Sky Towers, Tehran]\n[Tenant ID: 99283-T]\n\n2025-09-28 08:15:12 - [System] New maintenance request submitted by: Arash Mansouri.\n2025-09-28 08:15:45 - [System] Request Category: Electrical/Plumbing (Hybrid).\n\nArash Mansouri:\nسلام، من ساکن واحد 402 هستم. میخواستم گزارش بدم که از دیشب یه صدای جلز ولز خیلی عجیبی از سمت پریز برق کنار سینک آشپزخانه میاد. فکر کنم با هر بار باز شدن شیر آب، اون صدا شدیدتر میشه.\n\n2025-09-28 08:17:10 - [System] Attachment uploaded: `IMG_20250928_0812.jpg` (Size: 2.4MB)\n2025-09-28 08:17:30 - [System] Attachment uploaded: `VIDEO_0815.mp4` (Size: 15.6MB)\n\nArash Mansouri:\nبسیار مهم: همین الان وقتی داشتم ظرف میشستم، یه دود خیلی کم از اون قسمت پریز بلند شد. من فورا برق کل واحد رو قطع کردم. الان وضعیت خیلی خطرناک به نظر میرسه چون رطوبت زیر سینک هم زیاده و نزدیک به سیمکشی هست. لطفا سریعتر یه تعمیرکار بفرستید، نگران آتشسوزی هستم.\n\n2025-09-28 09:05:22 - [Admin: Leyla Rezayi]\nآقای منصوری، پیام شما رو دریافت کردیم. طبق پروتکل ایمنی AMS-POL-09 (بند 3: فوریتهای الکتریکی در محیطهای مرطوب)، این درخواست مستقیما به حالت \"Emergency Priority\" ارتقا یافت.\n\nلطفا تا رسیدن تکنسین، از لمس هیچکدام از کلیدهای برق یا محوطه مرطوب خودداری کنید. ما با شرکت \"Techno-Fix Maintenance\" هماهنگ میکنیم. هزینه اعزام در صورت تشخیص نقص در تجهیزات اصلی ساختمان، بر عهده مدیریت خواهد بود.\n\n2025-09-28 09:10:05 - [System] Task assigned to: Technician ID #442 (Techno-Fix).\n2025-09-28 09:10:05 - [System] ETA: 45-60 minutes.\n\n---\n[Internal Log - Metadata]\nRequest_Hash: 0x8821FF\nUser_Agent: Mobile/iOS/17.4\nError_Code: None\nLocation_Lat_Long: 35.7228, 51.3822\nCurrent_Status: DISPATCHED_URGENT", "source_lines": [ 7292, 7293, 7294 ], "agree": 3, "n": 3, "window_end_char": 1583, "questions": [ { "id": "e390fb27d81ac99c", "kind": "score", "question": "سطح خطر موجود در این درخواست را بر اساس توصیفات مستاجر ارزیابی کنید:", "choices": [ "Low", "Medium", "High", "Critical" ], "teacher": [ 0.05, 0.15, 0.3, 0.5 ], "decima": [ 0.01809, 0.08389, 0.31289, 0.58513 ], "agree": true }, { "id": "863df633d76043df", "kind": "verify", "question": "آیا مستاجر در حال حاضر برق کل واحد را وصل نگه داشته است؟", "choices": [ "Yes, the power is on", "No, the power has been cut" ], "teacher": [ 0.05, 0.95 ], "decima": [ 0.11869, 0.88131 ], "agree": true }, { "id": "754126c2c56dd2fe", "kind": "verify", "question": "آیا هزینه اعزام تعمیرکار قطعا بر عهده مدیریت ساختمان خواهد بود؟", "choices": [ "Yes, it is guaranteed", "No, it depends on the findings" ], "teacher": [ 0.1, 0.9 ], "decima": [ 0.19681, 0.80319 ], "agree": true } ] }, { "group": "jev-0-2015", "domain": "fraud", "scenario": "card-not-present order with mismatched addresses", "format": "transaction record with risk signals and device fingerprint", "state_lang": "ar", "choice_lang": "ar", "state": "[TRANSACTION_RECORD_V4.2.1]\nTimestamp: 2026-04-11T14:22:09.442Z\nMerchant: Arkan-Tech Solutions (ID: AT-99284)\nTerminal_ID: POS-WEB-004\nOperator: [Automated Gateway]\n\n--- TRANSACTION DETAILS ---\nTransaction_ID: TXN-88391022-Z\nCustomer_Name: سليمان بن راشد المنصور\nCard_Type: Visa Platinum\nCard_Last4: 8821\nAmount: 12,450.00 SAR\nCurrency: SAR\nStatus: PENDING_REVIEW\nAuth_Code: NULL\n\n--- SHIPPING & BILLING ---\nBilling_Address:\n Street: 442 شارع التخصصي\n District: العليا\n City: الرياض\n Postal_Code: 12211\n Country: SA\n\nShipping_Address:\n Recipient: \"S. Al-Mansour\"\n Street: 12 Block B, Al-Rawdah\n District: منطقة السكن المزدحم\n City: جدة\n Postal_Code: 23433\n Country: SA\n\n--- RISK ENGINE SIGNALS ---\n[SIGNAL_LOG]\n[14:22:09] RISK_SCORE_CALC: Initial score 42/100.\n[14:22:09] MATCH_ENGINE: [WARNING] Billing ZIP (12211) vs Shipping ZIP (23433) mismatch.\n[14:22:09] VELOCITY_CHECK: User 's.almansour88' has 0 previous transactions in last 30 days.\n[14:22:09] GEOLOCATION_CHECK: IP (178.64.12.88) resolves to Jeddah, SA.\n[14:22:09] DEVICE_FINGERPRINT: \n {\n \"os\": \"Android 14\",\n \"browser\": \"Chrome Mobile\",\n \"is_emulator\": false,\n \"proxy_detected\": true,\n \"vpn_provider\": \"Nord-Proxy-Node-7\",\n \"screen_res\": \"1080x2400\"\n }\n[14:22:10] FRAUD_PATTERN_MATCH: Pattern 'CNP_ADDR_MISMATCH_PROXY' detected (Confidence: 0.72).\n[14:22:10] POLICY_REF: \"Rule-302: Transactions exceeding 10,000 SAR with proxy usage and address discrepancies must undergo manual verification.\"\n\n--- SYSTEM NOTES ---\nNote: Transaction flagged by automated rules due to high value and technical anomalies. IP location matches shipping city but contradicts the typical billing profile of this user segment. No previous device association found for this card.\n>>>", "source_lines": [ 7451, 7452, 7453, 7454 ], "agree": 4, "n": 4, "window_end_char": 1333, "questions": [ { "id": "05b808d12fc54a8f", "kind": "score", "question": "ما هو مستوى خطر الاحتيال لهذا الطلب بناء على المعطيات التقنية؟", "choices": [ "منخفض جدا", "متوسط", "مرتفع", "مرتفع جدا" ], "teacher": [ 0.05, 0.35, 0.45, 0.15 ], "decima": [ 0.04028, 0.16213, 0.41543, 0.38216 ], "agree": true }, { "id": "54ebe9e1d671092a", "kind": "choose", "question": "ما هو الإجراء الأنسب لاتخاذ قرار فوري بشأن هذه المعاملة؟", "choices": [ "قبول المعاملة فورا", "رفض المعاملة تلقائيا", "تجميد الطلب للمراجعة اليدوية", "طلب التحقق الثنائي من العميل" ], "teacher": [ 0.02, 0.08, 0.85, 0.05 ], "decima": [ 0.07168, 0.17687, 0.49094, 0.26051 ], "agree": true }, { "id": "94726f24b929cd8e", "kind": "verify", "question": "هل تم اكتشاف استخدام لخدمة بروكسي أو VPN أثناء عملية الدفع؟", "choices": [ "نعم، تم اكتشاف ذلك", "لا، لم يتم اكتشاف ذلك" ], "teacher": [ 0.98, 0.02 ], "decima": [ 0.85919, 0.14081 ], "agree": true }, { "id": "6dc38826e3b3bd23", "kind": "choose", "question": "ما هو السبب الرئيسي وراء رفع حالة المعاملة للمراجعة؟", "choices": [ "مبلغ المعاملة منخفض", "عدم تطابق العنوان الجغرافي والرمز البريدي", "خطأ في بيانات بطاقة الائتمان", "فشل في عملية الاتصال بالبنك", "تكرار المحاولات من نفس الجهاز" ], "teacher": [ 0.01, 0.92, 0.02, 0.02, 0.03 ], "decima": [ 0.02061, 0.75007, 0.02372, 0.10045, 0.10515 ], "agree": true } ] }, { "group": "jev-0-1883", "domain": "compliance_privacy", "scenario": "deletion request conflicting with retention", "format": "policy excerpt plus an internal request email", "state_lang": "en", "choice_lang": "en", "state": "Data Retention & Disposal Policy (v4.2.1) - Internal Reference Only\nEffective Date: 2021-01-15 | Last Reviewed: 2022-03-10\nOwner: Compliance Dept (Compliance-Global)\n\nSection 4.3: Financial Transaction Records\nAll transactional metadata, including client identifiers, amount fields, and timestamped settlement data, shall be retained for a mandatory period of seven (7) years from the date of the transaction to satisfy local tax and anti-money laundering (AML) regulatory requirements.\n\nSection 5.1: Right to Erasure (GDPR/CCPA Compliance)\nUpon receipt of a verified 'Request for Deletion' (RfD), the Data Privacy Office (DPO) shall facilitate the removal of all personally identifiable information (PII) from active production databases. However, Section 5.1.b states: \"The obligation to delete shall not supersede statutory retention requirements for financial, tax, or legal hold data. In cases of conflict, data must be moved to a restricted-access 'Cold Archive' and shielded from general processing until the statutory period expires.\"\n\n--------------------------------------------------------------------------------\nFrom: Marcus Thorne <m.thorne@veridion-fintech.example>\nTo: Elena Rossi <e.rossi@veridion-fintech.example>\nSent: Wednesday, June 7, 2022 10:14 AM\nSubject: URGENT: Deletion Request - Client ID #AX-99281 (J. Aris)\n\nHi Elena,\n\nWe just received a formal deletion request from J. Aris (Client ID: #AX-99281). The client is demanding immediate removal of all profile data, including transaction history, citing their right to be forgotten.\n\nI’ve looked at the account in the `prod-ledger-db-04` instance. They have a series of high-value transfers from late 2021, specifically the $14,500.00 settlement on 2021-11-12. If we wipe the record now to satisfy the GDPR request, we’re going to be in a massive hole during the Q3 audit regarding AML compliance.\n\nCan we just purge the whole ID? I'm seeing a lot of pressure from the customer success side to close this ticket today.\n\nBest,\nMarcus\n\n---\n[System Log: Ticket-Tracker-v2]\n2022-06-07 10:15:02 [INFO] Ticket #88219 created by m.thorne\n2022-06-07 10:15:05 [DEBUG] Database connection to 'prod-ledger-db-04' established.\n2022-06-07 10:15:05 [WARN] User m.thorne attempted to access 'audit-logs-restricted' without elevated permissions.\n2022-06-07 10:16:12 [INFO] Ticket status changed to 'Pending Review'.", "source_lines": [ 6953, 6954, 6955 ], "agree": 3, "n": 3, "window_end_char": 1909, "questions": [ { "id": "2e3453e408ca4f26", "kind": "choose", "question": "What is the primary reason for the conflict regarding the deletion of Client ID #AX-99281?", "choices": [ "Marketing preference", "Tax/AML statutory retention", "Technical database error", "Expired user consent", "Incomplete client identification", "Internal data migration", "Security breach protocol", "System hardware failure" ], "teacher": [ 0.05, 0.85, 0.05, 0.02, 0.01, 0.01, 0.005, 0.005 ], "decima": [ 0.00632, 0.85873, 0.00414, 0.00935, 0.04539, 0.06514, 0.00919, 0.00173 ], "agree": true }, { "id": "e253e49ada541360", "kind": "verify", "question": "Does the current policy allow for the immediate, total removal of transaction history for this specific client?", "choices": [ "Yes, deletion must be absolute", "No, statutory retention takes precedence" ], "teacher": [ 0.02, 0.98 ], "decima": [ 0.16631, 0.83369 ], "agree": true }, { "id": "18e87ff60c6834e9", "kind": "score", "question": "Assess the regulatory risk associated with following Marcus's suggestion to 'just purge the whole ID'.", "choices": [ "Low Risk", "Moderate Risk", "High Risk" ], "teacher": [ 0.01, 0.09, 0.9 ], "decima": [ 0.13624, 0.30904, 0.55471 ], "agree": true } ] }, { "group": "jev-0-2073", "domain": "code_review", "scenario": "database query change without an index", "format": "pull-request description plus a unified diff and CI summary", "state_lang": "en", "choice_lang": "en", "state": "Pull Request: #8821 - Update order filtering logic for Merchant Dashboard\nAuthor: Elena Vance (evance@flux-logistics.example)\nDate: 2023-04-28 14:22 UTC\nStatus: Open\nReviewers: [ ]\n\nDescription:\nAs part of the Q2 performance tuning sprint, we are updating the `OrderRepository` to support filtering by `vendor_status` and `region_code` simultaneously in the dashboard view. This will allow our logistics partners to see pending shipments more granularly. \n\nI've updated the SQL builder to include these two fields in the WHERE clause. Note that I haven't added any new indexes yet because the DBA team (Marcus & Sarah) mentioned they are currently performing a migration on the `orders_master` cluster and requested no DDL changes until the maintenance window on Friday. We'll monitor the query latency in the staging environment.\n\nDiff:\n--- a/src/db/repositories/OrderRepository.java\n+++ b/src/db/repositories/OrderRepository.java\n@@ -142,7 +142,7 @@\n public List<Order> findActiveOrders(String vendorStatus, String region) {\n String sql = \"SELECT id, order_date, total_amount, status, region_code \" +\n \"FROM orders_master \" +\n- \"WHERE status = 'ACTIVE' \";\n+ \"WHERE status = 'ACTIVE' AND vendor_status = ? AND region_code = ?\";\n return jdbcTemplate.query(sql, new Object[]{vendorStatus, region}, mapper);\n }\n\nCI Summary:\n[2023-04-28 14:25:01] Running Unit Tests...\n[2023-04-28 14:25:12] PASSED: 42 tests executed.\n[2023-04-28 14:25:15] Running Integration Tests (Staging DB)...\n[2023-04-28 14:26:44] PASSED: 12 tests executed.\n[2023-04-28 14:26:45] Linting: OK.\n[2023-04-28 14:26:46] Build: SUCCESS.\n\nReviewer Notes:\n- (Placeholder)\n- (Placeholder)", "source_lines": [ 7666, 7667, 7668, 7669 ], "agree": 4, "n": 4, "window_end_char": 1649, "questions": [ { "id": "a2ba5a0e23e54f05", "kind": "verify", "question": "Does the proposed change include any Data Definition Language (DDL) statements such as CREATE INDEX or ALTER TABLE?", "choices": [ "yes", "no" ], "teacher": [ 0.02, 0.98 ], "decima": [ 0.19302, 0.80698 ], "agree": true }, { "id": "54e25668cc253c36", "kind": "choose", "question": "What is the primary reason provided for the absence of database indexing for the new query parameters?", "choices": [ "The staging environment lacks the necessary permissions.", "A scheduled maintenance/migration is currently being performed by the DBA team.", "The developer believes the existing status index is sufficient.", "The CI pipeline failed to validate the index requirements." ], "teacher": [ 0.05, 0.92, 0.02, 0.01 ], "decima": [ 0.04345, 0.50788, 0.28807, 0.1606 ], "agree": true }, { "id": "6ac95e22050247d0", "kind": "choose", "question": "What is the most likely risk profile for this specific code change?", "choices": [ "Immediate application crash due to syntax errors.", "Performance degradation due to full table scans on large datasets.", "Data corruption caused by incorrect WHERE clause logic." ], "teacher": [ 0.05, 0.55, 0.4 ], "decima": [ 0.08634, 0.56103, 0.35263 ], "agree": true }, { "id": "233ec11ecfe195e1", "kind": "score", "question": "How would you rate the operational risk of merging this PR in its current state?", "choices": [ "Negligible", "Low", "Moderate", "High", "Critical", "Catastrophic", "Extreme" ], "teacher": [ 0.05, 0.15, 0.65, 0.1, 0.03, 0.01, 0.01 ], "decima": [ 0.02494, 0.15312, 0.42222, 0.30629, 0.07744, 0.01378, 0.00221 ], "agree": true } ] }, { "group": "jev-0-1701", "domain": "ecommerce", "scenario": "return outside the window with a defect claim", "format": "seller-support ticket with order history", "state_lang": "ar", "choice_lang": "ar", "state": "[TICKET-ID: 99283-X]\n[TIMESTAMP: 2022-08-03 14:22:10]\n[AGENT: سامر المنصور]\n[DEPARTMENT: دعم البائعين - قسم النزاعات]\n\n--- سجل الطلب (Order History Log) ---\nOrder_ID: ORD-7721-B\nCustomer_Name: ليلى بن يوسف\nDate_Placed: 2022-07-05 10:15:44\nStatus: Delivered\nDelivery_Date: 2022-07-08 16:30:00\nSKU: TECH-AUD-992 (سماعات لاسلكية Pro-Sound)\nUnit_Price: 450.00 SAR\nTotal_Paid: 450.00 SAR\n\n--- تفاصيل التذكرة (Ticket Details) ---\nالموضوع: طلب استرجاع مع ادعاء وجود عيب مصنعي\nالحالة: قيد المراجعة\n\nنص رسالة العميل:\n\"مرحبا، لقد استلمت السماعات منذ فترة، ولكنها بدأت تصدر ضجيجا في الجهة اليسرى اليوم فقط. أريد استرجاع المبلغ بالكامل. المنتج لم يعد يعمل كما هو متوقع.\"\n\nملاحظات الوكيل (Internal Note):\nالعميلة تطلب الاسترجاع بتاريخ 2022-08-03. بالنظر إلى تاريخ الاستلام (2022-07-08)، فقد تجاوزت فترة الاسترجاع المعتادة (14 يوما) بمقدار 21 يوما تقريبا. \n\nسياسة الاسترجاع (Policy Reference v4.2):\n- \"يمكن للمشتري طلب استرجاع المنتج خلال 14 يوما من تاريخ الاستلام في حالة تغيير الرأي.\"\n- \"في حالة وجود عيب مصنعي (Defective Item)، يتم قبول الطلب خلال 30 يوما من تاريخ الاستلام، بشرط تقديم إثبات تقني أو فيديو يوضح العطل.\"\n\nسجل العمليات (Audit Trail):\n[2022-08-03 14:22:10] - تم فتح التذكرة بواسطة العميل.\n[2022-08-03 14:45:00] - تم تصنيف الطلب ك 'Defect Claim'.\n[2022-08-03 15:10:22] - فحص تاريخ التسليم عبر نظام الشحن (Log: SHIP-99-A): تم التسليم بنجاح في 08-JUL-2022.\n\nملاحظة إضافية من النظام:\nWarning: Order falls outside the 'Standard Return Window'. Escalation to Quality Control may be required if 'Defect' is verified.\n\nتوقيع:\nسامر المنصور\nSenior Support Specialist | Al-Nour E-commerce Solutions\n--------------------------------------------------", "source_lines": [ 6292, 6293, 6294, 6295 ], "agree": 4, "n": 4, "window_end_char": 1560, "questions": [ { "id": "ba9aa58892f3fdd9", "kind": "score", "question": "ما هو مستوى خطورة هذا النزاع على استقرار تقييم البائع؟", "choices": [ "منخفض جدا", "منخفض", "متوسط", "مرتفع", "مرتفع جدا" ], "teacher": [ 0.1, 0.35, 0.45, 0.05, 0.05 ], "decima": [ 0.04125, 0.23503, 0.45669, 0.21505, 0.05198 ], "agree": true }, { "id": "1bca2921c3f68d93", "kind": "verify", "question": "هل تجاوزت العميلة فترة الاسترجاع المخصصة لتغيير الرأي (14 يوما)؟", "choices": [ "نعم، تجاوزت الفترة", "لا، لم تتجاوزها" ], "teacher": [ 0.95, 0.05 ], "decima": [ 0.79378, 0.20622 ], "agree": true }, { "id": "345708dc85aa3464", "kind": "verify", "question": "هل قدمت العميلة أي إثبات تقني (فيديو أو مستند) ضمن نص الرسالة المذكور؟", "choices": [ "نعم، قدمت إثباتا", "لا، لم تقدم إثباتا" ], "teacher": [ 0.05, 0.95 ], "decima": [ 0.28962, 0.71038 ], "agree": true }, { "id": "ac05ca89f9cdbc0d", "kind": "score", "question": "ما مدى ثقة النظام في أن هذا المنتج يندرج تحت فئة 'العيب المصنعي' بناء على المعطيات الحالية فقط؟", "choices": [ "منعدمة", "ضعيفة", "متوسطة", "قوية", "مؤكدة" ], "teacher": [ 0.04762, 0.38095, 0.42857, 0.09524, 0.04762 ], "decima": [ 0.05111, 0.21914, 0.41912, 0.23526, 0.07538 ], "agree": true } ] }, { "group": "jev-0-1910", "domain": "ecommerce", "scenario": "wrong item shipped", "format": "returns-portal submission", "state_lang": "en", "choice_lang": "en", "state": "VELOCITY RETAIL SOLUTIONS | RETURNS MANAGEMENT PORTAL v4.2.1-stable\nSession ID: 88291-XJ-9920 | User: m.holloway@customer.example | Timestamp: 2022-08-06T14:22:09Z\n--------------------------------------------------------------------------------\n\n[FORM SUBMISSION: RETURN_REQUEST_ERR_04]\n\nCustomer Details:\nName: Marcus Holloway\nAccount Reference: VR-992811-M\nTier: Silver\n\nOrder History Reference:\nOrder ID: #ORD-77210-B\nOriginal Order Date: 2022-08-02\nFulfillment Center: DC-NORTH-04 (Lehigh Valley)\nTotal Order Value: $142.50 USD\nStatus: Delivered (Signature: J. Doe)\n\nItem(s) in Order:\n1. [SKU: BT-990] - AeroStream Wireless Earbuds - Black - $120.00\n2. [SKU: CS-112] - Silicone Protective Case - Clear - $22.50\n\nReturn Selection:\nSelected Item: [SKU: BT-990] - AeroStream Wireless Earbuds - Black\nReturn Reason: Wrong Item Received (Mis-pick)\nDescription of Issue: \n\"I opened the box today and instead of the AeroStream earbuds I ordered, I found a pack of heavy-duty industrial zip ties (SKU: ZT-55-IND). The packaging for the earbuds was actually stuck to the bottom of the box, but it was empty. The shipping label matches my order, but the contents are completely different. Please send the correct item ASAP. I need these for a flight on the 10th.\"\n\nAttachments:\n- photo_of_label.jpg (Verified: 2022-08-06T14:23:11Z)\n- photo_of_contents.jpg (Verified: 2022-08-06T14:23:45Z)\n\nSystem Internal Logs:\n[14:22:09] INFO: Form validation success.\n[14:22:09] WARN: SKU mismatch detected in user-provided description vs selection field.\n[14:22:09] DEBUG: Selected SKU: BT-990. User text mentions SKU: ZT-55-IND.\n[14:22:10] INFO: Triggering automated triage. Routing to: Logistics_Dispute_Queue.\n[14:22:10] TRACE: Warehouse audit log check for DC-NORTH-04... \n[14:22:10] TRACE: No immediate inventory discrepancy reported for BT-990 at DC-NORTH-04 in last 60 mins.\n\nPolicy Note: \n\"Per Policy v9.2: If the customer claims 'Wrong Item Received', the fulfillment center must be contacted for a cycle count of the reported SKU within 24 hours of the return request submission.\"\n\n--------------------------------------------------------------------------------\nEND OF SUBMISSION", "source_lines": [ 7047, 7048, 7049, 7050, 7051 ], "agree": 4, "n": 5, "window_end_char": 1605, "questions": [ { "id": "a9c99030ebea62c6", "kind": "score", "question": "Assess the urgency for resolving this specific customer's issue based on their stated deadline.", "choices": [ "Very Low", "Low", "Medium", "High", "Very High", "Critical" ], "teacher": [ 0.05, 0.1, 0.15, 0.4, 0.25, 0.05 ], "decima": [ 0.00709, 0.05532, 0.33773, 0.46704, 0.11588, 0.01694 ], "agree": true }, { "id": "5c3349336cfabe79", "kind": "verify", "question": "Was the item the customer actually received a piece of electronics?", "choices": [ "Yes, it was electronics", "No, it was not electronics" ], "teacher": [ 0.02, 0.98 ], "decima": [ 0.2257, 0.7743 ], "agree": true }, { "id": "1008dc002a2314eb", "kind": "choose", "question": "Identify the primary root cause category for this return request.", "choices": [ "Damaged in Transit", "Defective Product", "Incorrect Item Shipped", "Customer Ordered Wrong Item" ], "teacher": [ 0.05, 0.05, 0.85, 0.05 ], "decima": [ 0.18424, 0.23787, 0.29903, 0.27886 ], "agree": true }, { "id": "ccb0990eafb77cb6", "kind": "verify", "question": "Did the customer mention a specific date for their upcoming travel?", "choices": [ "Yes, they mentioned a date", "No, they did not mention a date" ], "teacher": [ 0.95, 0.05 ], "decima": [ 0.29441, 0.70559 ], "agree": false }, { "id": "c9fa0585f0498bb2", "kind": "score", "question": "What is the level of confidence in the system's ability to resolve this through standard automated workflows without manual intervention?", "choices": [ "Very Low", "Low", "Medium", "High", "Very High" ], "teacher": [ 0.05, 0.19998, 0.54995, 0.19998, 0.0001 ], "decima": [ 0.0606, 0.25347, 0.44779, 0.18718, 0.05097 ], "agree": true } ] }, { "group": "jev-0-2538", "domain": "product_feedback", "scenario": "app-store reviews after a release", "format": "bug tracker issue with comments", "state_lang": "en", "choice_lang": "en", "state": "ISSUE-4492: CRASH ON STARTUP (iOS 17.4)\nStatus: Open\nReporter: Elena Vance (evance@lumina-apps.example)\nAssignee: Marcus Thorne\nPriority: High\nCreated: 2024-02-12 09:14:22 UTC\n\n[Description]\nUsers are reporting immediate crashes on the splash screen following the v4.2.1 release. This appears to be isolated to the latest iOS builds. Several App Store reviews mention a \"black screen loop\" before the app force-closes. \n\n[Comment] 2024-02-12 10:05:44 UTC - Marcus Thorne\nInitial triage: I've pulled the crash logs from Sentry. We are seeing a massive spike in `SIGABRT` errors. \nError string: `*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[LuminaCoreSession setConfiguration:]: unrecognized selector sent to instance 0x6000034a8c20'`\nThis looks like a method signature mismatch. It might be related to the refactor of the `LuminaCore` module we pushed last Tuesday.\n\n[Comment] 2024-02-12 11:30:12 UTC - Sarah Jenkins (QA)\nChecking the App Store feedback loop... \nUser \"TechGeek99\" says: \"Update 4.2.1 broke everything. App won't even open. 1 star.\"\nUser \"AppLover_42\" says: \"Worked fine on 4.2.0, but now it just hangs on the logo. Any fix?\"\nNote: I ran this on an iPhone 13 (iOS 17.4) and it crashed in 3 seconds. However, I couldn't replicate it on my iPhone 11 (iOS 16.7). \n\n[Comment] 2024-02-12 13:45:00 UTC - Marcus Thorne\n@Sarah, the logs suggest the `LuminaCoreSession` object is being instantiated via the old factory method, but the new binary expects the configuration to be passed during the `init` call. This is a classic API contract break.\nWait, looking at the build manifest... we are using `LuminaCore v2.1.0-beta`. Did the CI/CD pipeline pull the wrong tag?\nCheck `deploy-logs-09.log`:\n`[INFO] Deploying LuminaMobile-iOS v4.2.1...`\n`[INFO] Dependency Check: LuminaCore... Found v2.1.0-beta (unstable)`\n`[WARN] WARNING: Using beta-tagged dependency in production build.`\n`[INFO] Build successful. Hash: 88af221`\n\n[Comment] 2024-02-12 14:20:10 UTC - Elena Vance\nIf it's the beta dependency, we need to roll back the build immediately. The App Store rating is already dipping. Current rating: 4.2 (down from 4.7).", "source_lines": [ 9371, 9372, 9373, 9374, 9375 ], "agree": 3, "n": 5, "window_end_char": 1686, "questions": [ { "id": "41ad92c8767e26d9", "kind": "score", "question": "How would you rate the urgency of this issue based on the current situation?", "choices": [ "negligible", "low", "moderate", "high", "critical" ], "teacher": [ 0.05, 0.05, 0.1, 0.3, 0.5 ], "decima": [ 0.01266, 0.05361, 0.22319, 0.46036, 0.25018 ], "agree": false }, { "id": "d62b2373e12be830", "kind": "choose", "question": "What is the primary classification for this reported problem?", "choices": [ "Feature Request", "UI/UX Improvement", "Regression", "Dependency Mismatch", "Documentation Error", "Performance Bottleneck" ], "teacher": [ 0.02, 0.03, 0.45, 0.4, 0.05, 0.05 ], "decima": [ 0.05486, 0.0635, 0.41714, 0.14992, 0.08544, 0.22914 ], "agree": true }, { "id": "60d94cf5a79ebc8a", "kind": "choose", "question": "What is the intended next step for the engineering team?", "choices": [ "Ignore the warning", "Roll back to previous stable version", "Update documentation", "Patch the UI code", "Increase testing on iOS 16", "Refactor the factory method", "Wait for user reports" ], "teacher": [ 0.02, 0.75, 0.03, 0.02, 0.03, 0.1, 0.05 ], "decima": [ 0.089, 0.25564, 0.0916, 0.02829, 0.2018, 0.25807, 0.07561 ], "agree": false }, { "id": "2286e365336a2e21", "kind": "score", "question": "Assess the technical severity of the crash reported in the logs.", "choices": [ "minimal", "minor", "moderate", "major", "catastrophic", "extreme", "unmeasurable" ], "teacher": [ 0.0001, 0.0001, 0.04999, 0.14997, 0.39992, 0.34993, 0.04999 ], "decima": [ 0.00424, 0.02056, 0.10899, 0.33928, 0.38225, 0.11723, 0.02745 ], "agree": true }, { "id": "1994f33ab2aba3cc", "kind": "verify", "question": "Does the issue appear to be reproducible on all iOS versions?", "choices": [ "yes, it is universal", "no, it is version-specific" ], "teacher": [ 0.15, 0.85 ], "decima": [ 0.14563, 0.85437 ], "agree": true } ] }, { "group": "jev-0-1742", "domain": "legal_contract", "scenario": "data-processing addendum gaps", "format": "legal intake request with the relevant clause pasted", "state_lang": "en", "choice_lang": "en", "state": "LEGAL INTAKE PORTAL - V4.2.1\nRequest ID: REQ-99284-X\nTimestamp: 2025-07-20T14:22:01Z\nRequester: Elena Vance (Legal Operations, NexaFlow Systems)\nPriority: High\nMatter Ref: #2025-DP-009 (Client: Meridian Logistics Group)\n\n---\n[INTERNAL NOTES - DO NOT DISCLOSE TO CLIENT]\nThe client (Meridian) is pushing back on our standard DPA template. They are claiming our current sub-processor notification period is insufficient for their compliance audit requirements. They want a 60-day window instead of the 30 days we currently provide in Section 8.2. Please review the attached clause and the specific request from their DPO, Marcus Thorne.\n\n---\n[ATTACHED DOCUMENT: MERIDIAN_LOGISTICS_DPA_REDLINE_V2.docx]\n\nClause 12.4: Data Breach Notification\nIn the event of a confirmed Personal Data Breach, Processor shall notify Controller without undue delay, and in any event within 72 hours of becoming aware of such breach. Processor shall provide a written report describing the nature of the breach, the categories of data affected, and the remediation steps taken.\n\nClause 14.1: Sub-processor Engagement\nProcessor may engage sub-processors to assist in the performance of its obligations under this Agreement. Processor shall maintain an up-to-date list of sub-processors on its website. Processor shall notify Controller of any intended changes concerning the addition or replacement of sub-processors at least thirty (30) days prior to such change taking effect. Controller shall have the right to object to such changes on reasonable grounds related to data protection.\n\n[REPLY FROM CLIENT DPO - MARCUS THORNE]\n\"Regarding the DPA version 2.0 draft, we find the notification window in Clause 14.1 to be a significant gap in our risk management framework. Under our current internal governance protocols for 2025, any change in the processing chain requires a minimum of sixty (60) calendar days for our security team to conduct a secondary impact assessment. Please amend Clause 14.1 to reflect a 60-day notice period. Additionally, we noticed that your standard template does not explicitly mention the 'right to audit' in the context of sub-processor security, though we recognize this may be covered under the general audit provisions in Section 9.\"\n\n[SYSTEM METADATA]\nSource: Web_Form_Entry\nUser_Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)\nProcessing_Node: US-EAST-1-LGL-04\nSession_ID: 882-f2-991-a\nStatus: PENDING_LEGAL_REVIEW", "source_lines": [ 6441, 6442, 6443, 6444 ], "agree": 3, "n": 4, "window_end_char": 1970, "questions": [ { "id": "5e5860c07ff346d6", "kind": "verify", "question": "Does the client request an extension to the notification period for adding or replacing sub-processors?", "choices": [ "yes, the client wants a longer window", "no, the client is satisfied with the current period" ], "teacher": [ 0.98, 0.02 ], "decima": [ 0.78102, 0.21898 ], "agree": true }, { "id": "7e7e336edc8c4cc7", "kind": "choose", "question": "What is the specific duration requested by the client for sub-processor notifications?", "choices": [ "30 days", "60 days", "72 hours" ], "teacher": [ 0.05, 0.94, 0.01 ], "decima": [ 0.35567, 0.45568, 0.18865 ], "agree": true }, { "id": "ecf95cb2b1747720", "kind": "choose", "question": "What is the primary subject of Marcus Thorne's feedback?", "choices": [ "Data breach response times", "Sub-processor notification windows", "General audit rights" ], "teacher": [ 0.15, 0.8, 0.05 ], "decima": [ 0.30351, 0.62838, 0.06811 ], "agree": true }, { "id": "abe8ec0a5ce183f2", "kind": "verify", "question": "Does the current text of Clause 12.4 specify a 60-hour window for breach notification?", "choices": [ "yes, it specifies 60 hours", "no, it does not specify 60 hours" ], "teacher": [ 0.0001, 0.9999 ], "decima": [ 0.50926, 0.49074 ], "agree": false } ] } ]}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150restaurant reviewsnutrition infoaccount blockedoil change howtimeweatherredeem rewardsinterest rategas typeaccept reservationssmart homeuser namereport lost cardrepeatwhisper modewhat are your hobbiesorderjump startschedule meetingmeeting schedulefreeze accountwhat songmeaning of liferestaurant reservationtrafficmake calltextbill balanceimprove credit scorechange languagenomeasurement conversiontimerflip coindo you have petsbalancetell jokelast maintenanceexchange rateubercar rentalcredit limitshopping listexpiration dateroutingmeal suggestiontire changetodo listcard declinedrewards balancechange accentvaccinesreminder updatefood lastchange ai namebill duewho do you work forshare locationinternational visacalendartranslatecarry onbook flightinsurance changetodo list updatetimezonecancel reservationtransactionscredit scorereport fraudspending historydirectionsspellinginsurancewhat is your namereminderwhere are you fromdistancepaydayflight statusfind phonegreetingalarmorder statusconfirm reservationcook timedamaged cardreset settingspin changereplacement card durationnew cardroll diceincometaxesdatewho made youpto requesttire pressurehow old are yourollover 401kpto request statushow busyapplication statusrecipecalendar updateplay musicyesdirect depositcredit limit changegaspay billingredients listlost luggagegoodbyewhat can i ask youbook hotelare you a botnext songchange speedplug typemaybew2oil change whenthank youshopping list updatepto balanceorder checkstravel alertfun factsync deviceschedule maintenanceaprtransferingredient substitutioncaloriescurrent locationinternational feescalculatordefinitionnext holidayupdate playlistmpgmin paymentchange user namerestaurant suggestiontravel notificationcancelpto usedtravel suggestionchange volume123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643{ "model": "Decima-small v1i int8 ONNX", "note": "outputs recorded by _build/build_gallery.py; one CPU thread", "gallery": [ { "id": "route-fa", "tag": "Routing · Persian", "title": "Login from another country", "state": "یک نفر از کشور دیگری وارد حسابم شده است.", "question": "Which team should handle this request?", "choices": [ "billing", "technical support", "sales", "account security" ], "choices_file": null, "kind": "choose", "lang": "fa", "expected": "account security", "recorded": { "top": "account security", "confidence": 0.9563, "top3": [ [ "account security", 0.9563 ], [ "technical support", 0.0296 ], [ "billing", 0.0112 ] ] } }, { "id": "route-ar", "tag": "Routing · Arabic", "title": "App crashes on settings", "state": "التطبيق يُغلق فجأة كلما فتحت صفحة الإعدادات.", "question": "Which team should handle this request?", "choices": [ "billing", "technical support", "sales", "account security" ], "choices_file": null, "kind": "choose", "lang": "ar", "expected": "technical support", "recorded": { "top": "technical support", "confidence": 0.9947, "top3": [ [ "technical support", 0.9947 ], [ "billing", 0.0019 ], [ "account security", 0.0017 ] ] } }, { "id": "route-fa-informal", "tag": "Routing · Persian, informal", "title": "“…and it wasn’t me!”", "state": "یه نفر از یه کشور دیگه وارد حسابم شده، کار من نبوده!", "question": "Which team should handle this request?", "choices": [ "billing", "technical support", "sales", "account security" ], "choices_file": null, "kind": "choose", "lang": "fa", "expected": "account security", "recorded": { "top": "account security", "confidence": 0.9784, "top3": [ [ "account security", 0.9784 ], [ "technical support", 0.0145 ], [ "billing", 0.0052 ] ] } }, { "id": "route-zh", "tag": "Routing · Chinese", "title": "Discount for 200 seats", "state": "如果我们公司买200个席位,有折扣吗?", "question": "Which team should handle this request?", "choices": [ "billing", "technical support", "sales", "account security" ], "choices_file": null, "kind": "choose", "lang": "zh", "expected": "sales", "recorded": { "top": "sales", "confidence": 0.9913, "top3": [ [ "sales", 0.9913 ], [ "billing", 0.0069 ], [ "technical support", 0.001 ] ] } }, { "id": "route-ru", "tag": "Routing · Russian", "title": "Login from another country", "state": "Кто-то вошёл в мой аккаунт из другой страны.", "question": "Which team should handle this request?", "choices": [ "billing", "technical support", "sales", "account security" ], "choices_file": null, "kind": "choose", "lang": "ru", "expected": "account security", "recorded": { "top": "account security", "confidence": 0.921, "top3": [ [ "account security", 0.921 ], [ "technical support", 0.062 ], [ "billing", 0.0088 ] ] } }, { "id": "route-es", "tag": "Routing · Spanish", "title": "App crashes on settings", "state": "La aplicación se cierra sola cada vez que abro la configuración.", "question": "Which team should handle this request?", "choices": [ "billing", "technical support", "sales", "account security" ], "choices_file": null, "kind": "choose", "lang": "es", "expected": "technical support", "recorded": { "top": "technical support", "confidence": 0.9928, "top3": [ [ "technical support", 0.9928 ], [ "account security", 0.0029 ], [ "billing", 0.0024 ] ] } }, { "id": "route-de", "tag": "Routing · German", "title": "Discount for 200 seats", "state": "Gibt es Rabatt, wenn wir 200 Lizenzen für unsere Firma kaufen?", "question": "Which team should handle this request?", "choices": [ "billing", "technical support", "sales", "account security" ], "choices_file": null, "kind": "choose", "lang": "de", "expected": "sales", "recorded": { "top": "sales", "confidence": 0.9734, "top3": [ [ "sales", 0.9734 ], [ "billing", 0.0115 ], [ "technical support", 0.0088 ] ] } }, { "id": "clinc-reminder", "tag": "150 intents", "title": "Move a dentist reminder", "state": "can you move my dentist reminder to friday at 3", "question": "What is the user's intent?", "choices": null, "choices_file": "clinc150_intents.txt", "kind": "choose", "lang": "en", "expected": "reminder update", "recorded": { "top": "reminder update", "confidence": 0.9585, "top3": [ [ "reminder update", 0.9585 ], [ "calendar update", 0.0125 ], [ "reminder", 0.0029 ] ] } }, { "id": "clinc-card", "tag": "150 intents", "title": "Card declined at the store", "state": "my card got declined at the grocery store", "question": "What is the user's intent?", "choices": null, "choices_file": "clinc150_intents.txt", "kind": "choose", "lang": "en", "expected": "card declined", "recorded": { "top": "card declined", "confidence": 0.9922, "top3": [ [ "card declined", 0.9922 ], [ "shopping list update", 0.0009 ], [ "shopping list", 0.0004 ] ] } }, { "id": "massive-fa", "tag": "60 intents · Persian in, English out", "title": "Taxi to the airport", "state": "یک تاکسی برای فرودگاه بگیر", "question": "What does the user want the assistant to do?", "choices": null, "choices_file": "massive60_intents.txt", "kind": "choose", "lang": "fa", "expected": "transport taxi", "recorded": { "top": "transport taxi", "confidence": 0.9812, "top3": [ [ "transport taxi", 0.9812 ], [ "transport ticket", 0.0097 ], [ "transport query", 0.0011 ] ] } }, { "id": "urgency", "tag": "Ordered levels · score", "title": "Checkout is down", "state": "Our checkout page is down and customers can't pay. We're losing sales every minute.", "question": "How urgent is this ticket?", "choices": [ "low", "medium", "high", "critical" ], "choices_file": null, "kind": "score", "lang": "en", "expected": "critical", "recorded": { "top": "critical", "confidence": 0.6805, "top3": [ [ "critical", 0.6805 ], [ "high", 0.2923 ], [ "medium", 0.0244 ] ] } }, { "id": "urgency-low", "tag": "Ordered levels · score", "title": "A typo on the pricing page", "state": "Small typo on your pricing page: 'monthy' instead of 'monthly'.", "question": "How urgent is this ticket?", "choices": [ "low", "medium", "high", "critical" ], "choices_file": null, "kind": "score", "lang": "en", "expected": "low", "recorded": { "top": "low", "confidence": 0.7437, "top3": [ [ "low", 0.7437 ], [ "medium", 0.2243 ], [ "high", 0.0272 ] ] } }, { "id": "rank", "tag": "Independent relevance · rank", "title": "Which help articles apply?", "state": "Someone logged into my account from another country and I can't get back in.", "question": "Which of these help articles are relevant to the customer's problem?", "choices": [ "How to reset your password", "Updating your billing address", "Enabling two-factor authentication", "Exporting reports to CSV", "What to do if you see an unfamiliar login" ], "choices_file": null, "kind": "rank", "lang": "en", "expected": "What to do if you see an unfamiliar login", "recorded": { "top": "What to do if you see an unfamiliar login", "confidence": 0.9361, "top3": [ [ "What to do if you see an unfamiliar login", 0.9361 ], [ "How to reset your password", 0.7943 ], [ "Enabling two-factor authentication", 0.4237 ] ] } }, { "id": "verify", "tag": "Yes / no · verify", "title": "Does the customer want a refund?", "state": "The blender stopped working after a week. I want my money back.", "question": "Does the customer ask for a refund?", "choices": [ "yes", "no" ], "choices_file": null, "kind": "verify", "lang": "en", "expected": "yes", "recorded": { "top": "yes", "confidence": 0.9543, "top3": [ [ "yes", 0.9543 ], [ "no", 0.0457 ] ] } }, { "id": "verify-angry", "tag": "Yes / no · verify", "title": "Is the customer angry?", "state": "This is the THIRD time I'm writing. Nobody answers. Unacceptable.", "question": "Is the customer angry?", "choices": [ "yes", "no" ], "choices_file": null, "kind": "verify", "lang": "en", "expected": "yes", "recorded": { "top": "yes", "confidence": 0.9236, "top3": [ [ "yes", 0.9236 ], [ "no", 0.0764 ] ] } }, { "id": "news", "tag": "News topic", "title": "Ceasefire talks resume", "state": "Ceasefire talks resume in Geneva as both delegations arrive for a second round.", "question": "What is the topic of this news article?", "choices": [ "World", "Sports", "Business", "Sci/Tech" ], "choices_file": null, "kind": "choose", "lang": "en", "expected": "World", "recorded": { "top": "World", "confidence": 0.9767, "top3": [ [ "World", 0.9767 ], [ "Business", 0.0102 ], [ "Sports", 0.0082 ] ] } }, { "id": "news-biz", "tag": "News topic", "title": "Central bank holds rates", "state": "Central bank holds interest rates steady as inflation cools for a third month.", "question": "What is the topic of this news article?", "choices": [ "World", "Sports", "Business", "Sci/Tech" ], "choices_file": null, "kind": "choose", "lang": "en", "expected": "Business", "recorded": { "top": "Business", "confidence": 0.9344, "top3": [ [ "Business", 0.9344 ], [ "World", 0.0459 ], [ "Sci/Tech", 0.0123 ] ] } } ], "shuffle": [ { "id": "tickets-6", "title": "Support ticket · 6 teams", "state": "The API returns a 500 error whenever I upload a file larger than 10 MB.", "question": "Which team should handle this request?", "choices": [ "billing", "technical support", "sales", "account security", "shipping and delivery", "legal and compliance" ], "kind": "choose", "lang": "en", "expected": "technical support", "recorded": { "top": "technical support", "confidence": 0.9834 } }, { "id": "persian-8", "title": "Persian command · 8 intents", "state": "چراغهای آشپزخانه را خاموش کن", "question": "What does the user want the assistant to do?", "choices": [ "iot hue lightoff", "iot hue lighton", "iot wemo off", "alarm set", "weather query", "play music", "audio volume down", "transport taxi" ], "kind": "choose", "lang": "fa", "expected": "iot hue lightoff", "recorded": { "top": "iot hue lightoff", "confidence": 0.9693 } }, { "id": "card-7", "title": "Banking question · 7 intents", "state": "how long will it take for my new card to arrive", "question": "What is the user's intent?", "choices": [ "replacement card duration", "new card", "card declined", "order status", "report lost card", "damaged card", "pin change" ], "kind": "choose", "lang": "en", "expected": "replacement card duration", "recorded": { "top": "replacement card duration", "confidence": 0.9778 } } ]}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960alarm queryalarm removealarm setaudio volume downaudio volume muteaudio volume otheraudio volume upcalendar querycalendar removecalendar setcooking querycooking recipedatetime convertdatetime queryemail addcontactemail queryemail querycontactemail sendemailgeneral greetgeneral jokegeneral quirkyiot cleaningiot coffeeiot hue lightchangeiot hue lightdimiot hue lightoffiot hue lightoniot hue lightupiot wemo offiot wemo onlists createoraddlists querylists removemusic dislikenessmusic likenessmusic querymusic settingsnews queryplay audiobookplay gameplay musicplay podcastsplay radioqa currencyqa definitionqa factoidqa mathsqa stockrecommendation eventsrecommendation locationsrecommendation moviessocial postsocial querytakeaway ordertakeaway querytransport querytransport taxitransport tickettransport trafficweather query123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102[ { "lang": "en", "text": "My invoice shows the wrong VAT number, can you reissue it?", "gold": "billing" }, { "lang": "en", "text": "I got a password reset email I never asked for. Is someone trying to get in?", "gold": "account security" }, { "lang": "en", "text": "The dashboard has been loading forever since your update last night.", "gold": "technical support" }, { "lang": "en", "text": "We're a team of 40 and want to know what the enterprise plan includes.", "gold": "sales" }, { "lang": "en", "text": "Why was I charged $49 when my plan is $29?", "gold": "billing" }, { "lang": "en", "text": "The API returns a 500 error whenever I upload a file larger than 10 MB.", "gold": "technical support" }, { "lang": "en", "text": "Can I get a demo for my manager next week?", "gold": "sales" }, { "lang": "en", "text": "Please turn on two-factor authentication for my account, I think my email was hacked.", "gold": "account security" }, { "lang": "en", "text": "How do I update the credit card you charge every month?", "gold": "billing" }, { "lang": "en", "text": "Is there a nonprofit discount?", "gold": "sales" }, { "lang": "es", "text": "No puedo sincronizar mis archivos desde ayer, la app se queda cargando.", "gold": "technical support" }, { "lang": "de", "text": "Ich möchte meine Rechnung als PDF bekommen, nicht per Post.", "gold": "billing" }, { "lang": "fr", "text": "Quelqu'un a changé l'adresse e-mail de mon compte sans mon accord.", "gold": "account security" }, { "lang": "ru", "text": "Сколько будет стоить годовая подписка для 15 сотрудников?", "gold": "sales" }, { "lang": "fa", "text": "رمز عبورم را عوض نکردهام ولی دیگر نمیتوانم وارد حسابم شوم.", "gold": "account security" }, { "lang": "ar", "text": "الإشعارات لا تصل إلى هاتفي منذ التحديث الأخير.", "gold": "technical support" }, { "lang": "zh", "text": "我想把按月付费改成按年付费。", "gold": "billing" }, { "lang": "tr", "text": "Şirketimiz için özel bir fiyat teklifi alabilir miyiz?", "gold": "sales" }, { "lang": "en", "text": "I cancelled last month but you charged me again.", "gold": "billing" }, { "lang": "en", "text": "After I changed my phone, the authenticator codes stopped working and I'm locked out.", "gold": "account security" }]12345678910111213141516171819<!doctype html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width" /><title>My static Space</title><link rel="stylesheet" href="style.css" /></head><body><div class="card"><h1>Welcome to your static Space!</h1><p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p><p>Also don't forget to check the<a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.</p></div></body></html>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Decima Playground</title><meta name="description" content="Decima-small: a 122M decision model running in your browser. Situation + question + options → calibrated probabilities. Nothing you type leaves your device."><meta name="color-scheme" content="light dark"><script>// theme before first paint: saved choice, else the system setting(function () {var t = null;try { t = localStorage.getItem("dz-theme"); } catch (e) {}if (t !== "light" && t !== "dark") t = matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";if (t === "dark") document.documentElement.classList.add("dark");})();</script><link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link rel="preconnect" href="https://cdn.jsdelivr.net" crossorigin><link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans+Arabic:wght@400;500;600&family=IBM+Plex+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap" rel="stylesheet"><link rel="stylesheet" href="style.css"><script type="module" src="app.js"></script></head><body><div class="dz-page"><header class="dz-header"><div class="dz-top"><div class="dz-brand"><h1 class="dz-word">Decima<span class="dz-word-sub">small</span></h1><p class="dz-pitch">Give it a situation, a question and your options.<br>Get back calibrated probabilities — computed right here, in your browser.</p></div><button class="dz-theme" id="theme" type="button" aria-label="Switch between light and dark mode" title="Light / dark"><svg class="i-moon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 14.5A8 8 0 0 1 9.5 4a8 8 0 1 0 10.5 10.5z"/></svg><svg class="i-sun" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2.5v2M12 19.5v2M2.5 12h2M19.5 12h2M5.3 5.3l1.4 1.4M17.3 17.3l1.4 1.4M5.3 18.7l1.4-1.4M17.3 6.7l1.4-1.4"/></svg></button></div><div class="dz-side"><div class="dz-chips"><span class="dz-chip"><b>122M</b> parameters</span><span class="dz-chip"><b>0</b> servers — the model runs on your device</span><span class="dz-chip"><b>0%</b> answer changes when options are shuffled</span></div><nav class="dz-links"><a href="https://huggingface.co/amyrmahdy/decima-small" target="_blank" rel="noopener">Model card</a><a href="https://github.com/amyrmahdy/decima" target="_blank" rel="noopener">GitHub</a><a href="https://github.com/amyrmahdy/decima/blob/main/docs/TECHNICAL-REPORT.md" target="_blank" rel="noopener">Technical report</a></nav></div></header><section class="dz-loader" id="loader" aria-live="polite"><span class="dz-dot" aria-hidden="true"></span><div class="dz-load-text" id="load-text"><b>Loading the model</b> — about 140 MB the first time, then it is cached on this device.</div><div class="dz-load-num" id="load-num"></div><div class="dz-bar is-indeterminate" id="load-bar" role="progressbar" aria-label="Model download" aria-valuemin="0" aria-valuemax="100"><div></div></div><div class="dz-private"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="4" y="10.5" width="16" height="10" rx="2"/><path d="M8 10.5V7.5a4 4 0 0 1 8 0v3"/></svg>Runs locally — nothing you type leaves your device.</div></section><nav class="dz-tablist" role="tablist" aria-label="Playground sections"><button class="dz-tab" role="tab" id="tab-try" aria-controls="p-try" aria-selected="true" type="button">Try it</button><button class="dz-tab" role="tab" id="tab-cases" aria-controls="p-cases" aria-selected="false" tabindex="-1" type="button">Business cases</button><button class="dz-tab" role="tab" id="tab-shuffle" aria-controls="p-shuffle" aria-selected="false" tabindex="-1" type="button">Shuffle test</button><button class="dz-tab" role="tab" id="tab-route" aria-controls="p-route" aria-selected="false" tabindex="-1" type="button">Auto-route</button><button class="dz-tab" role="tab" id="tab-speed" aria-controls="p-speed" aria-selected="false" tabindex="-1" type="button">Speed</button></nav><main><!-- 1 · try it --><section class="dz-panel" id="p-try" role="tabpanel" aria-labelledby="tab-try"><div class="dz-try"><form class="dz-inputs" id="try-form" autocomplete="off"><div class="dz-box"><div class="dz-field"><label class="dz-lbl" for="in-state">Situation</label><textarea id="in-state" rows="4" dir="auto" placeholder="A message, a ticket, an excerpt…">Someone logged into my account from another country.</textarea></div><div class="dz-field"><label class="dz-lbl" for="in-question">Question</label><textarea id="in-question" rows="1" dir="auto">Which team should handle this request?</textarea></div><div class="dz-field"><label class="dz-lbl" for="in-options">Options — one per line, any wording, any number</label><textarea id="in-options" rows="5" dir="auto">billingtechnical supportsalesaccount security</textarea></div></div><fieldset class="dz-kind"><legend>Kind of question</legend><label><input type="radio" name="kind" value="choose" checked> choose <small>— pick one of the options</small></label><label><input type="radio" name="kind" value="score"> score <small>— ordered levels, list them low → high</small></label><label><input type="radio" name="kind" value="verify"> verify <small>— yes or no, exactly two options</small></label><label><input type="radio" name="kind" value="rank"> rank <small>— each option judged on its own</small></label></fieldset><div class="dz-actions"><div class="dz-box dz-field"><label class="dz-lbl" for="in-lang">Language of the situation</label><span class="dz-info">Only Persian and Arabic change the input (script normalization).</span><select id="in-lang"><option value="auto">auto-detect</option><option value="en">English</option><option value="fa">Persian</option><option value="ar">Arabic</option><option value="ru">Russian</option><option value="zh">Chinese</option><option value="es">Spanish</option><option value="de">German</option><option value="fr">French</option><option value="tr">Turkish</option><option value="hi">Hindi</option><option value="ja">Japanese</option><option value="ko">Korean</option><option value="ur">Urdu</option><option value="xx">Other</option></select></div><button class="dz-go" id="go" type="submit">Decide</button></div></form><div class="dz-out" id="out" aria-live="polite"></div></div><div class="dz-section"><h2>Examples</h2><p>Each one was run before we put it here; the card shows the recorded answer. Click to load it and run it live, in your browser.</p></div><div class="dz-gallery" id="gallery"></div></section><!-- 2 · business cases --><section class="dz-panel" id="p-cases" role="tabpanel" aria-labelledby="tab-cases" hidden><div class="dz-section"><h2>Long cases the model never trained on</h2><p>One situation, several questions about it. Decima answers each question live in your browser; next to it is the answer of the 26B teacher that labelled the training data — including where they disagree.</p></div><div id="cases-summary"></div><div class="dz-case-layout"><div class="dz-cases" id="case-list"></div><div id="case-view"></div></div></section><!-- 3 · shuffle --><section class="dz-panel" id="p-shuffle" role="tabpanel" aria-labelledby="tab-shuffle" hidden><div class="dz-section"><h2>Reorder the options. The answer stays put.</h2><p>Each option is scored against the situation on its own, so its position never enters the computation. Shuffle as often as you like; the numbers below count every try in this session.</p></div><div class="dz-row-ctl"><div class="dz-field"><label class="dz-lbl" for="shuf-preset">Question</label><select id="shuf-preset"></select></div><button class="dz-go" id="shuf-go" type="button">Shuffle options</button></div><div class="dz-field"><label class="dz-lbl" for="shuf-state">Situation (you can edit it — press Enter to rerun)</label><textarea id="shuf-state" rows="2" dir="auto"></textarea></div><div id="shuf-out" aria-live="polite" style="margin-top:12px"></div></section><!-- 4 · auto-route --><section class="dz-panel" id="p-route" role="tabpanel" aria-labelledby="tab-route" hidden><div class="dz-section"><h2>Automate the sure cases, hand over the rest</h2><p>Because the probabilities are calibrated, the threshold is a dependable dial: raise it and fewer tickets are automated, and fewer mistakes get through. Twenty realistic tickets in eight languages, expected team written down before the model saw them. Your browser scores them once; after that the slider is instant.</p></div><div class="dz-slider"><div class="dz-slider-head"><label class="dz-lbl" for="th">Route automatically when confidence is at least</label><output id="th-val" for="th">0.80</output></div><input type="range" id="th" min="0.5" max="0.95" step="0.01" value="0.8"></div><div id="route-out"></div><p class="dz-dim dz-small">Twenty tickets we wrote — a demonstration of the mechanism, not an automation rate. Pick your threshold on your own labelled tickets. A threshold is not an off-topic filter: a message about something else entirely can still score high on one of your options.</p></section><!-- 5 · speed --><section class="dz-panel" id="p-speed" role="tabpanel" aria-labelledby="tab-speed" hidden><div class="dz-section"><h2>Measured on your device, now</h2><p>Time one decision in this browser tab with 4, 20, 77 and 150 options (WebAssembly, option encodings cached). Cost grows with the number of options; the dotted line is our x86 laptop reference, native ONNX Runtime on one core.</p></div><button class="dz-go dz-go-inline" id="sp-go" type="button">Run the latency sweep</button><div class="dz-plot" id="sp-plot"></div><div id="sp-table"><div class="dz-note"><p><b>Reference, x86 laptop</b> (Intel Core Ultra 7 155H, one P-core, int8, native ONNX Runtime):<span class="dz-mono">20 ms</span> with 4 options, <span class="dz-mono">42 ms</span> with 20,<span class="dz-mono">83 ms</span> with 77 (model-card option sets). With short labels, as plotted:<span class="dz-mono">16 ms</span> at 4 options and about 1 ms per extra option; 1,000 options take<span class="dz-mono">1.06 s</span>. A browser tab runs the same int8 model through WebAssembly, usually on one thread, so expect it to be slower.</p></div></div></section></main><footer class="dz-footer"><p><b>Read this before you judge the model by this page.</b> The examples are curated: we kept the ones that worked andlist the ones that did not in our launch notes. For accuracy, see the benchmarks in the<a href="https://huggingface.co/amyrmahdy/decima-small" target="_blank" rel="noopener">model card</a>.Known limits: long, multi-fact business decisions and knowledge questions (facts, arithmetic) are weak at this size;adding a “none of the above” option can pull real answers into it — use the confidence instead.</p><p class="dz-dim">Decima-small · Apache-2.0 · int8 ONNX on ONNX Runtime Web (WebAssembly), in this tab — no server sees your text.<span id="load-foot"></span> Synthetic business cases: CC BY 4.0.<button class="dz-linkbtn" id="forget" type="button">Remove the cached model from this device</button></p></footer></div></body></html>
12345678910111213141516171819202122232425262728body {padding: 2rem;font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;}h1 {font-size: 16px;margin-top: 0;}p {color: rgb(107, 114, 128);font-size: 15px;margin-bottom: 10px;margin-top: 5px;}.card {max-width: 620px;margin: 0 auto;padding: 16px;border: 1px solid lightgray;border-radius: 16px;}.card p:last-child {margin-bottom: 0;}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431/* Decima Playground (static) — one accent (#2a78d6), warm-gray surfaces, IBM Plex across Latin, Cyrillic and Arabic.Same design as the Gradio Space (release/space/style.css), rebuilt for plain HTML controls. */:root {color-scheme: light;--dz-bg: #fcfcfb;--dz-panel: #ffffff;--dz-sunk: #f4f4f1;--dz-line: #e8e7e3;--dz-line-2: #d9d8d3;--dz-ink: #1c1d1f;--dz-ink-2: #56575b;--dz-ink-3: #85868a;--dz-accent: #2a78d6;--dz-accent-hover: #1f62b5;--dz-accent-ink: #1f62b5;--dz-accent-wash: #eef5fd;--dz-rest: #cfcdc7;--dz-teacher: #a3a19b;--dz-good: #2e7d4f;--dz-good-wash: #eaf5ee;--dz-warn: #9a6a00;--dz-warn-wash: #fbf3e0;--dz-bad: #b93c34;--dz-bad-wash: #fbecea;--dz-sans: "IBM Plex Sans", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;--dz-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;}:root.dark {color-scheme: dark;--dz-bg: #131415;--dz-panel: #1b1c1e;--dz-sunk: #17181a;--dz-line: #2c2d30;--dz-line-2: #38393d;--dz-ink: #ecebe8;--dz-ink-2: #b1b0ad;--dz-ink-3: #86878b;--dz-accent: #4d8fe0;--dz-accent-hover: #5f9ce5;--dz-accent-ink: #7fb0ee;--dz-accent-wash: #16263b;--dz-rest: #45464a;--dz-teacher: #77787c;--dz-good: #5fbf85;--dz-good-wash: #15291d;--dz-warn: #e0b45a;--dz-warn-wash: #2c2412;--dz-bad: #ec7d74;--dz-bad-wash: #331917;}/* ── page ─────────────────────────────────────────────── */* { box-sizing: border-box; }html { -webkit-text-size-adjust: 100%; }body {margin: 0; background: var(--dz-bg); color: var(--dz-ink); font-family: var(--dz-sans);font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;}.dz-page { max-width: 1180px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 24px) 24px; }.dz-mono, .dz-pct, .dz-pct2, .dz-tile-n, .dz-ticks, .dz-q-n { font-family: var(--dz-mono); font-variant-numeric: tabular-nums; }.dz-dim { color: var(--dz-ink-3); }.dz-small { font-size: 13px; line-height: 1.5; margin: 8px 2px 0; }[hidden] { display: none !important; }.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }/* ── header ───────────────────────────────────────────── */.dz-header { display: flex; flex-direction: column; gap: 22px; padding: 44px 0 24px; }.dz-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }.dz-word {font-size: 46px; line-height: 1; font-weight: 600; letter-spacing: -0.03em; color: var(--dz-ink);display: flex; align-items: flex-start; gap: 10px; margin: 0;}.dz-word-sub {font-family: var(--dz-mono); font-size: 13px; font-weight: 500; letter-spacing: 0; color: var(--dz-accent);border: 1px solid currentColor; border-radius: 3px; padding: 2px 6px; margin-top: 4px;}.dz-pitch { margin: 14px 0 0; font-size: 17px; line-height: 1.5; color: var(--dz-ink-2); max-width: 34em; }.dz-side { display: flex; justify-content: space-between; align-items: center; gap: 14px 24px; flex-wrap: wrap; }.dz-chips { display: flex; gap: 8px; flex-wrap: wrap; }.dz-chip {font-size: 13px; color: var(--dz-ink-2); background: var(--dz-panel); border: 1px solid var(--dz-line);border-radius: 999px; padding: 5px 12px; white-space: nowrap;}.dz-chip b { font-family: var(--dz-mono); font-weight: 500; color: var(--dz-ink); margin-right: 3px; }.dz-links { display: flex; gap: 18px; font-size: 14px; flex-wrap: wrap; }.dz-links a, .dz-footer a, .dz-note a { color: var(--dz-accent-ink); text-decoration: none; border-bottom: 1px solid transparent; }.dz-links a:hover, .dz-footer a:hover, .dz-note a:hover { border-bottom-color: currentColor; }:focus-visible { outline: 2px solid var(--dz-accent); outline-offset: 2px; }.dz-theme {all: unset; cursor: pointer; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;color: var(--dz-ink-2); border: 1px solid var(--dz-line); background: var(--dz-panel); flex: none;}.dz-theme:hover { color: var(--dz-ink); border-color: var(--dz-line-2); }.dz-theme:focus-visible { outline: 2px solid var(--dz-accent); outline-offset: 2px; }.dz-theme svg { width: 18px; height: 18px; }.dz-theme .i-sun { display: none; }:root.dark .dz-theme .i-sun { display: block; }:root.dark .dz-theme .i-moon { display: none; }/* ── model loader (first visit downloads ~140 MB, then it is cached) ─ */.dz-loader {display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px 16px;border: 1px solid var(--dz-line); background: var(--dz-panel); border-radius: 8px; padding: 12px 16px; margin-bottom: 8px;}.dz-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dz-warn); box-shadow: 0 0 0 4px var(--dz-warn-wash); }.dz-loader.is-ready .dz-dot { background: var(--dz-good); box-shadow: 0 0 0 4px var(--dz-good-wash); }.dz-loader.is-error .dz-dot { background: var(--dz-bad); box-shadow: 0 0 0 4px var(--dz-bad-wash); }.dz-load-text { font-size: 14px; color: var(--dz-ink); min-width: 0; }.dz-load-text b { font-weight: 600; }.dz-load-num { font-family: var(--dz-mono); font-size: 13px; color: var(--dz-ink-2); white-space: nowrap; }.dz-bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--dz-sunk); overflow: hidden; }.dz-bar > div { height: 100%; width: 0; background: var(--dz-accent); border-radius: 3px; transition: width 0.2s linear; }.dz-bar.is-indeterminate > div { width: 30%; animation: dz-slide 1.1s ease-in-out infinite; }.dz-loader.is-ready .dz-bar { display: none; }.dz-private { grid-column: 1 / -1; font-size: 13px; color: var(--dz-ink-3); display: flex; align-items: center; gap: 7px; }.dz-private svg { width: 14px; height: 14px; flex: none; color: var(--dz-good); }@keyframes dz-slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }/* ── tabs ─────────────────────────────────────────────── */.dz-tablist {display: flex; gap: 4px; border-bottom: 1px solid var(--dz-line); margin: 10px 0 18px;overflow-x: auto; scrollbar-width: none;}.dz-tablist::-webkit-scrollbar { display: none; }.dz-tab {all: unset; cursor: pointer; font-size: 15px; font-weight: 500; color: var(--dz-ink-3); padding: 12px 14px; white-space: nowrap;}.dz-tab[aria-selected="true"] { color: var(--dz-ink); box-shadow: inset 0 -2px 0 var(--dz-accent); }.dz-tab:hover { color: var(--dz-ink); }.dz-tab:focus-visible { outline: 2px solid var(--dz-accent); outline-offset: -2px; border-radius: 4px; }/* ── section intros ──────────────────────────────────── */.dz-section { margin: 26px 0 6px; }.dz-panel > .dz-section:first-child { margin-top: 6px; }.dz-section h2 { font-size: 21px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 6px; color: var(--dz-ink); }.dz-section p { margin: 0; color: var(--dz-ink-2); font-size: 15px; line-height: 1.55; max-width: 52em; }.dz-note {background: var(--dz-sunk); border: 1px solid var(--dz-line); border-radius: 6px; padding: 14px 18px; margin: 10px 0 14px;font-size: 14.5px; line-height: 1.55; color: var(--dz-ink-2);}.dz-note p { margin: 0 0 6px; }.dz-note p:last-child { margin: 0; }.dz-note b { color: var(--dz-ink); font-weight: 600; }/* ── inputs ──────────────────────────────────────────── */.dz-try { display: grid; grid-template-columns: 5fr 6fr; gap: 18px; align-items: start; }.dz-inputs { display: flex; flex-direction: column; gap: 14px; min-width: 0; }.dz-box { background: var(--dz-panel); border: 1px solid var(--dz-line); border-radius: 8px; padding: 12px 14px; }.dz-field { display: flex; flex-direction: column; gap: 6px; }.dz-field + .dz-field { margin-top: 12px; }.dz-lbl { font-size: 13.5px; font-weight: 500; color: var(--dz-ink-2); }.dz-info { font-size: 12.5px; color: var(--dz-ink-3); margin-top: -2px; }textarea, input[type="text"], select {font: inherit; font-size: 15px; color: var(--dz-ink); background: var(--dz-panel);border: 1px solid var(--dz-line); border-radius: 6px; padding: 9px 11px; width: 100%; line-height: 1.45;}textarea { resize: vertical; min-height: 44px; unicode-bidi: plaintext; }textarea:focus, select:focus { outline: none; border-color: var(--dz-accent); box-shadow: 0 0 0 3px var(--dz-accent-wash); }select { appearance: none; padding-right: 32px; cursor: pointer;background-image: linear-gradient(45deg, transparent 50%, var(--dz-ink-3) 50%), linear-gradient(135deg, var(--dz-ink-3) 50%, transparent 50%);background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }fieldset.dz-kind { border: 1px solid var(--dz-line); border-radius: 8px; padding: 10px 14px 12px; margin: 0; background: var(--dz-panel); }fieldset.dz-kind legend { padding: 0 4px; font-size: 13.5px; font-weight: 500; color: var(--dz-ink-2); }.dz-kind label {display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--dz-ink); cursor: pointer;border: 1px solid var(--dz-line); border-radius: 6px; padding: 7px 10px; margin-top: 5px;}.dz-kind label:has(input:checked) { border-color: var(--dz-accent); background: var(--dz-accent-wash); }.dz-kind input { accent-color: var(--dz-accent); margin: 0; }.dz-kind small { color: var(--dz-ink-3); font-size: 13px; }.dz-actions { display: grid; grid-template-columns: 3fr 2fr; gap: 12px; align-items: end; }.dz-go {all: unset; box-sizing: border-box; cursor: pointer; text-align: center; min-height: 44px; padding: 11px 22px; border-radius: 6px;background: var(--dz-accent); color: #fff; font-weight: 600; font-size: 15px; letter-spacing: 0.01em;transition: background 0.15s ease;}.dz-go:hover { background: var(--dz-accent-hover); }.dz-go:focus-visible { outline: 2px solid var(--dz-accent); outline-offset: 2px; }.dz-go[aria-busy="true"] { opacity: 0.75; cursor: progress; }.dz-go-inline { justify-self: start; }.dz-row-ctl { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; margin-bottom: 12px; }.dz-row-ctl .dz-field { flex: 1 1 320px; }.dz-slider { display: flex; flex-direction: column; gap: 8px; background: var(--dz-panel); border: 1px solid var(--dz-line); border-radius: 8px; padding: 12px 16px 14px; margin-bottom: 12px; }.dz-slider-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }.dz-slider output { font-family: var(--dz-mono); font-size: 15px; color: var(--dz-ink); font-weight: 500; }input[type="range"] { width: 100%; accent-color: var(--dz-accent); margin: 0; height: 22px; }/* ── result card + the probability ledger (signature) ─ */.dz-card { background: var(--dz-panel); border: 1px solid var(--dz-line); border-radius: 8px; padding: 22px 22px 18px; }.dz-eyebrow {font-size: 11.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dz-ink-3);}.dz-answer { font-size: 30px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.2; margin: 8px 0 12px; color: var(--dz-ink); overflow-wrap: anywhere; }.dz-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; margin-bottom: 18px; font-size: 14px; color: var(--dz-ink-2); }.dz-time b { font-family: var(--dz-mono); font-weight: 500; color: var(--dz-ink); }.dz-time .dz-dim { font-size: 12.5px; }.dz-badge {display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 500; white-space: nowrap;border-radius: 999px; padding: 3px 10px; border: 1px solid transparent;}.dz-b-high, .dz-b-agree { color: var(--dz-good); background: var(--dz-good-wash); }.dz-b-mid { color: var(--dz-warn); background: var(--dz-warn-wash); }.dz-b-low, .dz-b-disagree { color: var(--dz-bad); background: var(--dz-bad-wash); }.dz-b-info { color: var(--dz-accent-ink); background: var(--dz-accent-wash); }.dz-ledger { display: flex; flex-direction: column; gap: 2px; direction: ltr; }.dz-row {display: grid; grid-template-columns: minmax(120px, 38%) 1fr 64px; align-items: center; gap: 14px;padding: 7px 0; border-top: 1px solid var(--dz-line);}.dz-row.dz-scale { border-top: 0; padding: 0 0 2px; }.dz-ticks { position: relative; height: 16px; font-size: 10.5px; color: var(--dz-ink-3); }.dz-ticks span { position: absolute; top: 0; transform: translateX(-50%); }.dz-ticks span:first-child { transform: none; }.dz-ticks span:last-child { transform: translateX(-100%); }.dz-label { font-size: 14.5px; color: var(--dz-ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.dz-track {position: relative; height: 8px; border-radius: 4px; overflow: hidden;background: repeating-linear-gradient(to right, transparent 0 calc(25% - 1px), var(--dz-line) calc(25% - 1px) 25%), var(--dz-sunk);}.dz-fill {height: 100%; border-radius: 4px; background: var(--dz-rest);transform-origin: left center; animation: dz-grow 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;transition: width 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);}.dz-pct { font-size: 13.5px; text-align: right; color: var(--dz-ink-2); }.is-top .dz-label { color: var(--dz-ink); font-weight: 600; }.is-top .dz-fill { background: var(--dz-accent); }.is-top .dz-pct { color: var(--dz-ink); font-weight: 500; }.dz-foot { margin-top: 12px; font-size: 12.5px; color: var(--dz-ink-3); }.dz-more summary { cursor: pointer; font-size: 13px; color: var(--dz-accent-ink); padding: 8px 0 2px; border-top: 1px solid var(--dz-line); }.dz-msg p { margin: 8px 0 0; color: var(--dz-ink-2); font-size: 15px; line-height: 1.5; }@keyframes dz-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }/* ── example gallery ─────────────────────────────────── */.dz-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin-top: 12px; }.dz-ex, .dz-case {all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; gap: 6px;background: var(--dz-panel); border: 1px solid var(--dz-line); border-radius: 8px; padding: 14px 16px;transition: border-color 0.15s ease, box-shadow 0.15s ease;}.dz-ex:hover, .dz-case:hover { border-color: var(--dz-line-2); box-shadow: 0 1px 0 var(--dz-line-2); }.dz-ex.is-active, .dz-case.is-active { border-color: var(--dz-accent); box-shadow: inset 3px 0 0 var(--dz-accent); }.dz-ex-tag { font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--dz-accent-ink); }.dz-ex-title { font-size: 15px; font-weight: 600; color: var(--dz-ink); }.dz-ex-state {font-size: 14px; line-height: 1.45; color: var(--dz-ink-2);display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;}.dz-ex-out {display: flex; flex-direction: column; gap: 2px; margin-top: auto; padding-top: 8px; border-top: 1px dashed var(--dz-line);font-size: 13.5px; color: var(--dz-ink-2);}.dz-ex-out b { color: var(--dz-ink); font-weight: 600; }.dz-ex-n { font-family: var(--dz-mono); font-size: 12px; color: var(--dz-ink-3); white-space: nowrap; }/* ── business cases ──────────────────────────────────── */.dz-cases { display: flex; flex-direction: column; gap: 8px; }.dz-case { padding: 12px 14px; gap: 4px; }.dz-case-title { font-size: 14.5px; font-weight: 600; color: var(--dz-ink); line-height: 1.35; }.dz-case-agree { font-size: 12.5px; color: var(--dz-ink-3); }.dz-case-agree b { font-family: var(--dz-mono); font-weight: 500; color: var(--dz-ink-2); }.dz-case-detail { display: flex; flex-direction: column; gap: 14px; }.dz-doc {font-family: var(--dz-mono); font-size: 12.5px; line-height: 1.6; color: var(--dz-ink-2);background: var(--dz-sunk); border: 1px solid var(--dz-line); border-radius: 6px; padding: 14px 16px;max-height: 360px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;}.dz-doc div[dir="auto"] { unicode-bidi: plaintext; }.dz-doc .dz-unread { opacity: 0.45; }.dz-cut { display: flex; align-items: center; gap: 10px; margin: 10px 0; color: var(--dz-accent-ink); font-family: var(--dz-sans); font-size: 12px; font-weight: 500; }.dz-cut::before, .dz-cut::after { content: ""; flex: 1; border-top: 1px dashed var(--dz-accent); }.dz-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--dz-ink-2); align-items: center; }.dz-sw { display: inline-block; width: 18px; height: 6px; border-radius: 3px; margin-right: 7px; vertical-align: middle; }.dz-sw-d { background: var(--dz-accent); }.dz-sw-t { background: var(--dz-teacher); height: 4px; }.dz-q { background: var(--dz-panel); border: 1px solid var(--dz-line); border-radius: 8px; padding: 16px 18px 12px; }.dz-q-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }.dz-q-n { font-size: 12.5px; color: var(--dz-ink-3); }.dz-q-kind { font-size: 12px; color: var(--dz-ink-3); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; margin-right: auto; }.dz-q-text { font-size: 15.5px; font-weight: 500; color: var(--dz-ink); line-height: 1.45; margin-bottom: 8px; }.dz-cledger { display: flex; flex-direction: column; direction: ltr; }.dz-crow {display: grid; grid-template-columns: minmax(140px, 46%) 1fr 104px; gap: 14px; align-items: center;padding: 8px 0; border-top: 1px solid var(--dz-line);}.dz-crow .dz-label { white-space: normal; font-size: 14px; line-height: 1.4; }.dz-pair { display: flex; flex-direction: column; gap: 4px; }.dz-crow .dz-track { height: 7px; }.dz-crow .dz-fill { background: var(--dz-accent); opacity: 0.55; }.dz-crow.is-top .dz-fill { opacity: 1; }.dz-crow .dz-teacher { height: 4px; }.dz-crow .dz-teacher .dz-fill { background: var(--dz-teacher); opacity: 1; }.dz-pct2 { display: flex; justify-content: flex-end; gap: 10px; font-size: 12.5px; color: var(--dz-ink-2); }.dz-crow.is-top .dz-label { color: var(--dz-ink); font-weight: 600; }/* ── shuffle ─────────────────────────────────────────── */.dz-shuf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 6px; }.dz-shuf .dz-row { grid-template-columns: minmax(150px, 52%) 1fr 64px; }.dz-shuf .dz-eyebrow { margin-bottom: 10px; }.dz-idx { display: inline-block; width: 1.6em; font-family: var(--dz-mono); font-size: 12px; color: var(--dz-ink-3); }.dz-pos { font-size: 11.5px; color: var(--dz-ink-3); font-weight: 400; margin-left: 6px; }.dz-verdict {display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 14px;background: var(--dz-line); border: 1px solid var(--dz-line); border-radius: 8px; overflow: hidden;}.dz-verdict > div { background: var(--dz-panel); padding: 16px 18px; }.dz-big { font-size: 20px; font-weight: 600; color: var(--dz-ink); margin-top: 6px; letter-spacing: -0.01em; }.dz-big.dz-mono { font-weight: 500; font-size: 19px; letter-spacing: 0; }.dz-verdict .dz-dim { font-size: 13px; margin-top: 4px; }/* ── auto-route + speed ──────────────────────────────── */.dz-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 4px 0 6px; }.dz-tile { background: var(--dz-panel); border: 1px solid var(--dz-line); border-radius: 8px; padding: 16px 18px; }.dz-tile-n { font-size: 34px; font-weight: 500; color: var(--dz-ink); line-height: 1.1; }.dz-tile-n span { font-size: 18px; color: var(--dz-ink-3); }.dz-tile-l { font-size: 13.5px; color: var(--dz-ink-2); margin-top: 6px; line-height: 1.4; }.dz-plot { background: var(--dz-panel); border: 1px solid var(--dz-line); border-radius: 8px; padding: 10px 12px 6px; margin-top: 12px; }.dz-table-wrap { overflow-x: auto; border: 1px solid var(--dz-line); border-radius: 8px; background: var(--dz-panel); margin-top: 10px; }.dz-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }.dz-table th {text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--dz-ink-3);padding: 10px 12px; border-bottom: 1px solid var(--dz-line); white-space: nowrap; background: var(--dz-sunk);}.dz-table td { padding: 8px 12px; border-bottom: 1px solid var(--dz-line); color: var(--dz-ink-2); vertical-align: top; }.dz-table tr:last-child td { border-bottom: 0; }.dz-table tr.is-esc td { background: color-mix(in srgb, var(--dz-sunk) 70%, transparent); }.dz-table td[dir="auto"] { color: var(--dz-ink); min-width: 260px; }.dz-num td, .dz-num th { text-align: right; }.dz-num td:first-child, .dz-num th:first-child { text-align: left; }.dz-ok { color: var(--dz-good); font-weight: 600; }.dz-bad { color: var(--dz-bad); font-weight: 600; }/* ── charts (inline SVG) ─────────────────────────────── */.dz-chart { width: 100%; height: auto; display: block; overflow: visible; font-family: var(--dz-sans); }.dz-chart .grid { stroke: var(--dz-line); stroke-width: 1; }.dz-chart .axis-t { fill: var(--dz-ink-3); font-size: 11.5px; }.dz-chart .axis-l { fill: var(--dz-ink-3); font-size: 12px; }.dz-chart .ref { stroke: var(--dz-ink-3); stroke-width: 2; stroke-dasharray: 3 4; fill: none; }.dz-chart .ref-dot { fill: var(--dz-ink-3); stroke: var(--dz-panel); stroke-width: 2; }.dz-chart .live { stroke: var(--dz-accent); stroke-width: 2.5; fill: none; }.dz-chart .live-dot { fill: var(--dz-accent); stroke: var(--dz-panel); stroke-width: 2; }.dz-chart .band { fill: var(--dz-ink-3); opacity: 0.1; }.dz-chart .th { stroke: var(--dz-accent); stroke-width: 2; }.dz-chart .th-t { fill: var(--dz-accent-ink); font-family: var(--dz-mono); font-size: 12px; }.dz-chart .ok { fill: var(--dz-accent); stroke: var(--dz-panel); stroke-width: 1.5; }.dz-chart .bad { stroke: var(--dz-bad); stroke-width: 2.5; stroke-linecap: round; }.dz-chart .zone { fill: var(--dz-ink-3); font-size: 11.5px; }.dz-chart .hit { fill: transparent; cursor: default; }.dz-chart .lbl { fill: var(--dz-ink-2); font-size: 12px; font-family: var(--dz-mono); }.dz-legend-row { display: flex; gap: 6px 18px; flex-wrap: wrap; font-size: 13px; color: var(--dz-ink-2); margin: 2px 2px 8px; }.dz-legend-row i { display: inline-block; vertical-align: middle; margin-right: 7px; }.dz-k-ok { width: 10px; height: 10px; border-radius: 50%; background: var(--dz-accent); }.dz-k-bad { width: 10px; height: 10px; position: relative; }.dz-k-bad::before, .dz-k-bad::after { content: ""; position: absolute; left: 4px; top: -1px; width: 2.5px; height: 12px; background: var(--dz-bad); border-radius: 1px; transform: rotate(45deg); }.dz-k-bad::after { transform: rotate(-45deg); }.dz-k-ref { width: 22px; border-top: 2px dotted var(--dz-ink-3); }.dz-k-live { width: 22px; border-top: 2.5px solid var(--dz-accent); }.dz-tip {position: fixed; z-index: 10; pointer-events: none; max-width: 300px; background: var(--dz-ink); color: var(--dz-bg);font-size: 12.5px; line-height: 1.45; padding: 7px 10px; border-radius: 6px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);}.dz-tip b { font-weight: 600; }.dz-busy { display: inline-flex; align-items: center; gap: 9px; color: var(--dz-ink-2); font-size: 14px; }.dz-busy::before {content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--dz-line-2); border-top-color: var(--dz-accent);animation: dz-spin 0.8s linear infinite;}@keyframes dz-spin { to { transform: rotate(360deg); } }.dz-crow.is-pending .dz-pair .dz-track:first-child { background: var(--dz-sunk); animation: dz-pulse 1.2s ease-in-out infinite; }@keyframes dz-pulse { 50% { opacity: 0.5; } }/* ── footer ──────────────────────────────────────────── */.dz-footer { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--dz-line); font-size: 13.5px; line-height: 1.6; color: var(--dz-ink-2); }.dz-footer p { margin: 0 0 8px; max-width: 62em; }.dz-footer b { color: var(--dz-ink); font-weight: 600; }.dz-linkbtn { all: unset; cursor: pointer; color: var(--dz-accent-ink); }.dz-linkbtn:hover { text-decoration: underline; }/* ── responsive + motion ��────────────────────────────── */.dz-case-layout { display: grid; grid-template-columns: 3fr 8fr; gap: 18px; align-items: start; }@media (max-width: 860px) {.dz-try, .dz-case-layout { grid-template-columns: 1fr; }}@media (max-width: 760px) {.dz-header { padding: 24px 0 16px; gap: 18px; }.dz-word { font-size: 36px; }.dz-pitch { font-size: 15.5px; }.dz-answer { font-size: 24px; }.dz-card { padding: 18px 16px 14px; }.dz-row, .dz-shuf .dz-row { grid-template-columns: 1fr 56px; gap: 4px 10px; }.dz-row .dz-label { grid-column: 1 / -1; }.dz-row.dz-scale { display: none; }.dz-crow { grid-template-columns: 1fr 96px; }.dz-crow .dz-label { grid-column: 1 / -1; }.dz-shuf-grid, .dz-verdict, .dz-tiles { grid-template-columns: 1fr; }.dz-cases { flex-direction: row; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; }.dz-case { flex: 0 0 240px; scroll-snap-align: start; }.dz-chip { white-space: normal; }.dz-tab { padding: 10px 10px; font-size: 14px; }.dz-actions { grid-template-columns: 1fr; }.dz-loader { grid-template-columns: auto minmax(0, 1fr); }.dz-load-num { grid-column: 2; }.dz-table td[dir="auto"] { min-width: 200px; }}@media (prefers-reduced-motion: reduce) {.dz-fill { animation: none; transition: none; }.dz-ex, .dz-case { transition: none; }.dz-bar.is-indeterminate > div, .dz-busy::before, .dz-crow.is-pending .dz-track { animation: none; }}
123456789101112131415161718192021222324252627282930313233343536373839404142// Runs the model off the main thread so the page stays responsive while it loads and decides.import * as ort from "https://cdn.jsdelivr.net/npm/onnxruntime-web@1.30.0/dist/ort.wasm.min.mjs";import { Tokenizer } from "https://cdn.jsdelivr.net/npm/@huggingface/tokenizers@0.2.0/dist/tokenizers.min.mjs";import { Decima, clearCache } from "./decima.js";
ort.env.wasm.wasmPaths = "https://cdn.jsdelivr.net/npm/onnxruntime-web@1.30.0/dist/";ort.env.logLevel = "error";
let model = null;let chain = Promise.resolve(); // one operation at a time: an ORT session runs one call at a time
async function handle({ id, op, ...a }) { const reply = (msg) => postMessage({ id, ...msg }); try { if (op === "load") { // Threads need cross-origin isolation (COOP/COEP), which static hosting usually lacks: then one thread. const numThreads = self.crossOriginIsolated ? Math.min(4, navigator.hardwareConcurrency || 1) : 1; model = await Decima.load(a.url, { ort, Tokenizer, numThreads, onProgress: (p) => reply({ progress: p }) }); reply({ result: { ...model.stats, threads: numThreads, cfg: { max_state_tokens: model.cfg.max_state_tokens } } }); } else if (op === "decide") { reply({ result: await model.decide(a.state, a.q) }); } else if (op === "decideMany") { const out = []; for (const it of a.items) out.push(await model.decide(it.state, it.q)); reply({ result: out }); } else if (op === "bench") { // first call (may encode the option set), then `reps` timed calls with the option encodings cached const t0 = performance.now(); await model.decide(a.state, a.q); const first = performance.now() - t0; const lat = []; for (let i = 0; i < a.reps; i++) lat.push((await model.decide(a.state, a.q)).latency_ms); reply({ result: { first, lat } }); } else if (op === "clearCache") { reply({ result: await clearCache() }); } else throw new Error(`unknown op ${op}`); } catch (e) { reply({ error: String((e && e.message) || e) }); }}
onmessage = (e) => { chain = chain.then(() => handle(e.data)); };README.md+39-5
app.jsAdded+678
decima.jsAdded+234
examples/banking77_intents.txtAdded+77
examples/business_cases.jsonAdded+1179
examples/clinc150_intents.txtAdded+150
examples/gallery.jsonAdded+643
examples/massive60_intents.txtAdded+60
examples/tickets.jsonAdded+102
index.html+182-17
style.css+421-18
worker.jsAdded+42