config.rope_theta. Higher = more long-range capacity. Typical: 10000 early models, 500000 Llama-3, 1000000 Qwen2.5.",
T_train: "Max context the model was trained on. From max_position_embeddings. The model has never seen positions beyond this; extrapolating much further usually fails.",
T_eval: "Your target inference context length. The key knob. The whole question is: will the model behave well at this length?",
n_attention_heads: "Number of query heads. From num_attention_heads.",
n_kv_heads: "Number of K/V heads. If < n_attention_heads → model uses GQA (Grouped Query Attention). Smaller = more memory-efficient KV cache but pushes γ toward Hagedorn boundary.",
d_head: "Per-head dimension. Typically hidden_size / n_attention_heads. Common: 64, 80, 128.",
n_layers: "Number of transformer layers. From num_hidden_layers.",
n_params: "Total parameter count. Use scientific notation: 8e9 for 8B. Threshold ~400M is the induction-head emergence boundary (sign-flip in Δγ).",
has_SWA: "Sliding Window Attention. true for Mistral, gemma-2, phi-3. SWA lowers γ_decomposition by ~0.21.",
N_params: "Same as n_params. Total parameter count, scientific notation (e.g. 8e9).",
D_tokens: "Number of training tokens. Leave empty to use Chinchilla 20:1 default (D = 20·N).",
gpu: "GPU model from the catalog. Options: H100 SXM, H100 PCIe, H200, B200, A100 80GB, A100 40GB, L40S, MI300X, RTX 4090, RTX 5090, RTX 5060Ti.",
n_gpus: "Number of GPUs in your training/serving cluster.",
mfu: "Model FLOPs Utilization. Realistic fraction of peak FLOPs achieved. Typical: 0.4-0.5 for well-tuned. Default 0.45.",
api_model: "Frontier API to compare against. Options: GPT-4o, GPT-4o-mini, Claude-Opus-4, Claude-Sonnet-4, Claude-Haiku-4, Gemini-1.5-Pro, DeepSeek-V3, Llama-3.3-70B (Together).",
monthly_tokens_M: "Expected monthly token volume in millions. e.g. 10 = 10 million tokens/month.",
USD_budget: "Your training budget in US dollars (no symbol). e.g. 5000 for $5K.",
bytes_per_weight: "Memory per parameter. BF16/FP16 = 2, INT8 = 1, INT4 = 0.5.",
target_tokens_per_day: "How many tokens/day you need to serve. e.g. 10000000 = 10M tokens/day.",
concurrent_users: "Simultaneous concurrent requests. Affects KV cache memory needed.",
};
function getRecipeDefaults(recipeId) {
const D = {
"X-1": { N_params: "8e9", D_tokens: "", gpu: "H100 SXM", n_gpus: 8, mfu: 0.45,
api_model: "GPT-4o", monthly_tokens_M: 10.0 },
"X-2": { theta: 500000, T_train: 8192, T_eval: 32000,
n_attention_heads: 32, n_kv_heads: 8, d_head: 128,
n_layers: 32, n_params: "8e9", has_SWA: false },
"X-3": { USD_budget: 5000, gpu: "H100 SXM", mfu: 0.45, n_gpus: 1 },
"X-5": { N_params: "8e9", T_eval: 4096, n_layers: 32, n_kv_heads: 8, d_head: 128,
bytes_per_weight: 2.0, target_tokens_per_day: 10000000, concurrent_users: 1 },
"X-19": { theta: 500000, T_train: 8192, T_eval: 8192,
n_attention_heads: 32, n_kv_heads: 8, d_head: 128,
n_layers: 32, n_params: "8e9", has_SWA: false },
};
return D[recipeId] || {};
}
// ════════════════════════════════════════════════════════════════════
// Preset autofill (works in recipe mode)
// ════════════════════════════════════════════════════════════════════
$("preset").addEventListener("change", (e) => {
if (!e.target.value) return;
const modelId = e.target.value;
state.lastModelId = modelId; // remember for filename/hash
// Mirror behavior with profile-preset: also fill HF id input if present.
if ($("hf-id")) {
$("hf-id").value = modelId;
if ($("hf-status")) $("hf-status").textContent = tFmt("profile.preset_loaded", { id: modelId });
}
const proxy = state.pyodide.runPython(`get_preset(${JSON.stringify(modelId)})`);
const preset = proxy.toJs ? proxy.toJs({ dict_converter: Object.fromEntries }) : proxy;
if (!preset || Object.keys(preset).length === 0) return;
fillRecipeForm(preset);
});
function fillRecipeForm(p) {
// Fill any matching field in dynamic form
Object.entries(p).forEach(([k, v]) => {
const map = {
theta: "theta", T_train: "T_train",
n_attention_heads: "n_attention_heads", n_kv_heads: "n_kv_heads",
d_head: "d_head", n_layers: "n_layers", n_params: "n_params",
has_SWA: "has_SWA",
};
const formId = "param_" + (map[k] || k);
const el = $(formId);
if (el) el.value = (typeof v === "number" && (k === "n_params" || v > 1e6))
? v.toExponential(2) : String(v);
// Also fill N_params for cost recipes
if (k === "n_params") {
const np = $("param_N_params");
if (np) np.value = (typeof v === "number" ? v.toExponential(2) : String(v));
}
});
}
// ════════════════════════════════════════════════════════════════════
// HF Hub fetch (any model)
// ════════════════════════════════════════════════════════════════════
async function fetchHfConfig(modelId) {
const url = `https://huggingface.co/${modelId}/raw/main/config.json`;
const resp = await fetch(url);
if (!resp.ok) {
if (resp.status === 401 || resp.status === 403) {
throw new Error(`Model is gated (${resp.status}). Accept license on HF Hub first, or fill manually.`);
}
throw new Error(`HTTP ${resp.status} — config.json not found at ${url}`);
}
return await resp.json();
}
$("hf-fetch-btn").addEventListener("click", async () => {
const modelId = $("hf-id").value.trim();
if (!modelId) {
$("hf-status").textContent = "⚠ Enter a model id like 'Qwen/Qwen2.5-32B-Instruct'";
return;
}
$("hf-status").textContent = `⏳ Fetching config.json from HF Hub for ${modelId}...`;
$("hf-fetch-btn").disabled = true;
state.lastModelId = modelId; // remember for filename/hash
try {
const cfg = await fetchHfConfig(modelId);
const preset = configToPreset(cfg, modelId);
fillRecipeForm(preset);
$("hf-status").innerHTML = `✅ Config loaded for ${modelId} (family: ${preset._family}). Verify values, click Analyze.`;
} catch (err) {
$("hf-status").textContent = `❌ ${err.message}`;
} finally {
$("hf-fetch-btn").disabled = false;
}
});
// ════════════════════════════════════════════════════════════════════
// 🪟 Unmask mode (v0.7.0 anti-bullshit pack #1)
// ════════════════════════════════════════════════════════════════════
// Tiny string-template helper: t(key) with {placeholder} substitution.
// Falls back to the raw key when the i18n entry is missing so dev sees the gap.
function tFmt(key, params = {}) {
let s = t(key) || key;
for (const [k, v] of Object.entries(params)) {
const fmtVal = v === null || v === undefined ? "—"
: (typeof v === "number" ? v.toLocaleString() : String(v));
s = s.replace(new RegExp(`\\{${k}\\}`, "g"), fmtVal);
}
return s;
}
const VERDICT_COLOR = {
honest: "#3fb950",
inflated: "#f1c40f",
severely_inflated: "#f85149",
yarn_extended: "#f1c40f",
unknown: "#8b949e",
};
function renderUnmaskCard(result, modelId = "") {
const color = VERDICT_COLOR[result.verdict] || VERDICT_COLOR.unknown;
const ratioPct = (result.ratio * 100).toFixed(1);
const f = result.flags;
const fmtN = (x) => x === null || x === undefined ? "—" : Number(x).toLocaleString();
const escapeHtml = (s) => String(s).replace(/[&<>"']/g, c =>
({"&":"&","<":"<",">":">",'"':""","'":"'"}[c]));
const verdictLabel = t(`unmask.verdict.${result.verdict}`) || result.verdict;
const labelDeclared = t("unmask.label.declared") || "Declared context";
const labelEffective = t("unmask.label.effective") || "Effective (estimate)";
const labelRatio = t("unmask.label.ratio") || "Ratio";
const sectionFlags = t("unmask.section.flags") || "Architecture flags";
const sectionWarn = t("unmask.section.warnings")|| "Warnings";
const sectionReco = t("unmask.section.reco") || "Recommendation";
// Architecture flags row labels
const flagSwa = t("unmask.flag.swa") || "SWA";
const flagRope = t("unmask.flag.rope") || "RoPE scaling";
const flagGqa = t("unmask.flag.gqa") || "GQA";
const flagLayers = t("unmask.flag.layers") || "Layers";
const flagDhead = t("unmask.flag.dhead") || "d_head";
const flagTheta = t("unmask.flag.theta") || "RoPE θ";
const flagYes = t("unmask.flag.yes") || "yes";
const flagNo = t("unmask.flag.no") || "no";
const swaText = f.hasSWA
? `${flagYes} (window = ${fmtN(f.swaWindow)})`
: flagNo;
const ropeText = f.hasYaRN
? `${f.ropeScalingType} (factor = ${f.yarnFactor}, original = ${fmtN(f.yarnOriginal)})`
: flagNo;
const gqaText = f.hasGQA
? `${flagYes} (${f.n_kv_heads} kv / ${f.n_attn_heads} attn heads)`
: (t("unmask.flag.full_mha") || "no (full MHA, {n} heads)").replace("{n}", f.n_attn_heads ?? "?");
const warningsHtml = result.warnings.length
? `${sectionWarn}
- ${result.warnings.map(w =>
`
- ${tFmt("unmask.warn." + w.code, w.params)} `).join("")}
${sectionReco}
${tFmt("unmask.reco." + result.recoCode, result.recoParams)}
${escapeHtml(modelId)}${sectionFlags}
- ${flagSwa}: ${swaText}
- ${flagRope}: ${ropeText}
- ${flagGqa}: ${gqaText}
- ${flagLayers}: ${fmtN(f.n_layers)} · ${flagDhead}: ${fmtN(f.d_head)} · ${flagTheta}: ${fmtN(f.rope_theta)}
${sectionWarn}
- ${result.warnings.map(w => `
- ${tFmt("template.warn." + w.code, w.params)} `).join("")}
${sectionCmd}
${escapeHtml(lmEvalCmd)}
${escapeHtml(vllmCmd)}
${escapeHtml(transformersCmd)}
${sectionRaw}
${escapeHtml(result.rawTemplate)}
${escapeHtml(modelId)}${escapeHtml(r.model)}${noTies}
`; } else { tiesHtml = `| ${t("arena.col.tie_pair") || "Pair"} | ${t("arena.col.tie_diff") || "Elo gap"} | ${t("arena.col.tie_overlap") || "CI overlap"} |
|---|---|---|
#${tieEntry.rank_a} ${escapeHtml(tieEntry.model_a)} vs #${tieEntry.rank_b} ${escapeHtml(tieEntry.model_b)} |
${fmtN(Math.round(tieEntry.elo_diff * 10) / 10)} Elo | ${fmtN(Math.round(tieEntry.overlap_elo * 10) / 10)} Elo |
- ${t("arena.summary.votes") || "Total votes"}: ${fmtN(s.total_votes)}
- ${t("arena.summary.models") || "Models"}: ${fmtN(s.n_models)}
- ${t("arena.summary.ties") || "Statistical ties"}: ${fmtN(s.n_ties)}
- ${t("arena.summary.bootstrap") || "Bootstrap iters"}: ${fmtN(s.bootstrap_iters)}
- ${t("arena.summary.ci_level") || "CI level"}: ${(s.ci_level * 100).toFixed(0)}%
${titleRanked}
| ${colRank} | ${colModel} | ${colElo} | ${colCi} | ${colSpread} | ${colMatches} | ${colWins} |
|---|
${titleTies} (${result.ties.length})
${tiesHtml}${titleSummary}
${summaryHtml}${t("contam.no_entries") || "(none in this category)"}
`; let body = ""; for (const r of group) { body += `| ${colBench} | ${colReleased} | ${colGap} | ${colPrior} | ${colCorpora} | ${colCategory} |
|---|
${titleHigh} (${high.length})
${adviceHigh}
${tableFor(high)}${titleMed} (${medium.length})
${adviceMedium}
${tableFor(medium)}${titleLow} (${low.length})
${adviceLow}
${tableFor(low)}${escapeHtml(err.message)}
Try the Recipe mode for full manual control.`; } finally { $("ask-btn").disabled = false; } }); $("example-btn").addEventListener("click", () => { const ex = EXAMPLES[Math.floor(Math.random() * EXAMPLES.length)]; $("question").value = ex; }); async function routeQuestion(question) { const engine = await loadWebLLM(); const recipesDesc = state.recipes.map(r => ` ${r.id}: ${r.name} — ${r.description}\n params: ${r.params.join(", ")}` ).join("\n"); const systemPrompt = `You are a routing function. Given a user's free-form question about transformer LLM viability, you MUST output a single JSON object with two fields: - recipe_id: one of [${state.recipes.map(r => r.id).join(", ")}] - params: an object with parameter values inferred from the question Available recipes: ${recipesDesc} Common model facts you may use: Meta-Llama-3-8B: theta=500000, T_train=8192, n_attention_heads=32, n_kv_heads=8, d_head=128, n_layers=32, n_params=8e9 Mistral-7B-v0.1: theta=10000, T_train=8192, n_attention_heads=32, n_kv_heads=8, d_head=128, n_layers=32, n_params=7e9, has_SWA=true Qwen2.5-7B: theta=1000000, T_train=32768, n_attention_heads=28, n_kv_heads=4, d_head=128, n_layers=28, n_params=7.6e9 Llama-3.3-70B-Instruct: theta=500000, T_train=131072, n_attention_heads=64, n_kv_heads=8, d_head=128, n_layers=80, n_params=70e9 Respond with ONLY the JSON object. No prose, no markdown fences, no explanation.`; const reply = await engine.chat.completions.create({ messages: [ { role: "system", content: systemPrompt }, { role: "user", content: question }, ], max_tokens: 400, temperature: 0.0, response_format: { type: "json_object" }, }); const raw = reply.choices[0].message.content.trim(); let parsed; try { parsed = JSON.parse(raw); } catch (e) { // Try extracting JSON from markdown fences const m = raw.match(/\{[\s\S]*\}/); if (!m) throw new Error(`LLM returned non-JSON: ${raw.slice(0, 200)}`); parsed = JSON.parse(m[0]); } if (!parsed.recipe_id || !state.recipesById[parsed.recipe_id]) { throw new Error(`Unknown recipe: ${parsed.recipe_id}`); } return parsed; } // ════════════════════════════════════════════════════════════════════ // Run + display + synthesize // ════════════════════════════════════════════════════════════════════ async function runAndDisplay(recipeId, params, originalQuestion=null) { setStatus("🧮 Computing TAF chain..."); state.pyodide.globals.set("__rid", recipeId); state.pyodide.globals.set("__params", state.pyodide.toPy(params)); const resultJSON = state.pyodide.runPython(` import json result = run_recipe(__rid, **__params) json.dumps(result) `); const result = JSON.parse(resultJSON); result._original_question = originalQuestion; renderResult(result); $("output-section").style.display = "block"; $("profile-output").style.display = "none"; $("compare-output").style.display = "none"; state.lastResult = { type: "recipe", recipeId, params }; state.lastFullResult = result; setStatus("✅ Done. Numbers below."); if (ENABLE_WEBLLM) { await synthesizeAnswer(result); } } function renderResult(r) { console.log("[TAF] renderResult called with:", r); if (r.error) { $("verdict-box").className = "verdict-no"; $("verdict-box").innerHTML = `Error: ${escapeHtml(r.error)}`; $("chain-box").innerHTML = ""; return; } const vBox = $("verdict-box"); if (!vBox) { console.error("[TAF] verdict-box element not found!"); return; } const verdictStr = String(r.verdict || "UNKNOWN"); let vClass = ""; if (verdictStr.startsWith("YES") || verdictStr === "GO" || verdictStr.startsWith("USE SOFT")) vClass = "verdict-yes"; else if (verdictStr.startsWith("NO") || verdictStr.startsWith("MEMORY") || verdictStr === "TINY-MODEL") vClass = "verdict-no"; else vClass = "verdict-degraded"; vBox.className = vClass; const verdictEmoji = vClass === "verdict-yes" ? "✅" : (vClass === "verdict-no" ? "❌" : "⚠"); vBox.innerHTML = `
${escapeHtml(JSON.stringify(r, null, 2))}`;
return String(r);
}
function escapeHtml(s) {
return String(s)
.replace(/&/g, "&").replace(//g, ">")
.replace(/"/g, """).replace(/'/g, "'");
}
// ════════════════════════════════════════════════════════════════════
// WebLLM (synthesis + router)
// ════════════════════════════════════════════════════════════════════
async function loadWebLLM() {
if (state.webllm) return state.webllm;
// Request persistent storage to avoid quota issues with cached model weights
if (navigator.storage && navigator.storage.persist) {
try {
const persistent = await navigator.storage.persist();
console.log(persistent ? "Persistent storage granted" : "Persistent storage denied");
} catch (e) {
console.warn("storage.persist() failed:", e);
}
}
setStatus(`⏳ Loading WebLLM library + ${WEBLLM_MODEL.split("-")[0]} (~350MB first time, cached after)...`);
const { CreateMLCEngine } = await import("https://esm.run/@mlc-ai/web-llm");
const tryLoad = async (modelId) => {
return await CreateMLCEngine(modelId, {
initProgressCallback: (info) => setStatus(`⏳ ${info.text || "Loading model..."}`),
});
};
try {
state.webllm = await tryLoad(WEBLLM_MODEL);
} catch (err) {
if (String(err).includes("QuotaExceeded") || String(err).includes("storage")) {
setStatus(`⚠ Quota exceeded for ${WEBLLM_MODEL}. Trying smaller fallback ${WEBLLM_FALLBACK}...`);
try {
state.webllm = await tryLoad(WEBLLM_FALLBACK);
} catch (err2) {
throw new Error(
`Both models failed. Browser storage too constrained. ` +
`Try: (1) Settings → Privacy → Site settings → allow more storage for this site, ` +
`(2) clear browser cache, (3) use Chrome/Edge in non-incognito mode. ` +
`Original error: ${err2.message || err2}`
);
}
} else {
throw err;
}
}
return state.webllm;
}
async function synthesizeAnswer(result) {
$("answer-header").style.display = "block";
$("answer-box").style.display = "block";
$("answer-box").innerHTML = 'Generating plain-English summary...';
let engine;
try {
engine = await loadWebLLM();
} catch (err) {
$("answer-box").innerHTML = `⚠ WebLLM failed: ${escapeHtml(String(err))}Numbers above are still correct.`; return; } const prompt = buildSynthesisPrompt(result); let answer = ""; try { const reply = await engine.chat.completions.create({ messages: [ { role: "system", content: t("synthesis.system") }, { role: "user", content: prompt }, ], max_tokens: 400, temperature: 0.2, }); answer = reply.choices[0].message.content; } catch (err) { $("answer-box").innerHTML = `⚠ Synthesis failed: ${escapeHtml(String(err))}`; return; } $("answer-box").innerHTML = `
🎚 What-if: drag T_eval to see γ change live
Pure JS recompute (no Pyodide call). Shows the geometric γ_Padé and d_horizon as you slide. The full chain re-runs on click.
✅ ${counts.confirmed} confirmed · ⚠ ${counts.partial} partial · ❌ ${counts.refuted} refuted · ⏳ ${counts.untested} untested (out of ${FALSIFICATION_STATUS.length} total predictions)
`; let table = `| ID | Claim | Status | Evidence |
|---|---|---|---|
${f.id} |
${escapeHtml(f.claim)} | ${icon} ${f.status} | ${escapeHtml(f.evidence)} |
${REGISTRY_REPO} exists with submissions, they'll appear here live.`;
return;
}
throw new Error(`HTTP ${resp.status}`);
}
const issues = await resp.json();
if (!issues || issues.length === 0) {
target.innerHTML = `No submissions yet. Be the first — generate a Profile and click 📤 Submit to registry.`;
return;
}
const html = issues.map(issue => {
const verdict = extractVerdictFromTitle(issue.title);
const vClass = verdictClass(verdict);
const time = relativeTime(new Date(issue.created_at));
return ``;
}).join("");
target.innerHTML = html;
} catch (err) {
target.innerHTML = `⚠ Couldn't load community feed: ${escapeHtml(err.message)}`;
}
}
function extractVerdictFromTitle(title) {
const m = title.match(/→\s*(\S+)/);
if (m) return m[1];
if (title.includes("YES")) return "YES";
if (title.includes("NO")) return "NO";
if (title.includes("DEGRADED")) return "DEG";
if (title.includes("Profile")) return "📇";
if (title.includes("Compare")) return "🆚";
return "?";
}
function verdictClass(v) {
if (v.startsWith("YES") || v === "GO") return "yes";
if (v.startsWith("NO")) return "no";
if (v === "DEG" || v === "DEGRADED") return "deg";
return "";
}
function relativeTime(d) {
const sec = Math.floor((Date.now() - d.getTime()) / 1000);
if (sec < 60) return `${sec}s ago`;
if (sec < 3600) return `${Math.floor(sec / 60)}m ago`;
if (sec < 86400) return `${Math.floor(sec / 3600)}h ago`;
return `${Math.floor(sec / 86400)}d ago`;
}
// ════════════════════════════════════════════════════════════════════
// PROFILE mode
// ════════════════════════════════════════════════════════════════════
$("profile-preset").addEventListener("change", (e) => {
if (!e.target.value) return;
const modelId = e.target.value;
state.lastModelId = modelId; // remember for filename/hash
// Preset keys ARE valid HF model ids (e.g. "meta-llama/Llama-3.2-1B"). Auto-fill
// the HF id input so the user can also click 📥 Fetch to refresh from HF Hub
// without retyping. Status hint clarifies the dual source of truth.
if ($("profile-hf-id")) {
$("profile-hf-id").value = modelId;
if ($("profile-hf-status")) {
$("profile-hf-status").textContent = tFmt("profile.preset_loaded", { id: modelId });
}
}
const proxy = state.pyodide.runPython(`get_preset(${JSON.stringify(modelId)})`);
const p = proxy.toJs ? proxy.toJs({ dict_converter: Object.fromEntries }) : proxy;
if (!p || Object.keys(p).length === 0) return;
$("profile-theta").value = p.theta;
$("profile-T_train").value = p.T_train;
$("profile-n_attn").value = p.n_attention_heads;
$("profile-n_kv").value = p.n_kv_heads;
$("profile-d_head").value = p.d_head;
$("profile-n_layers").value = p.n_layers;
$("profile-n_params").value = p.n_params.toExponential(2);
$("profile-has_swa").value = String(p.has_SWA);
});
$("profile-fetch-btn").addEventListener("click", async () => {
const id = $("profile-hf-id").value.trim();
if (!id) { $("profile-hf-status").textContent = "⚠ Enter a model id"; return; }
$("profile-hf-status").textContent = `⏳ Fetching ${id}...`;
$("profile-fetch-btn").disabled = true;
state.lastModelId = id; // remember for filename/hash
try {
const cfg = await fetchHfConfig(id);
const p = configToPreset(cfg, id);
$("profile-theta").value = p.theta;
$("profile-T_train").value = p.T_train;
$("profile-n_attn").value = p.n_attention_heads;
$("profile-n_kv").value = p.n_kv_heads;
$("profile-d_head").value = p.d_head;
$("profile-n_layers").value = p.n_layers;
$("profile-n_params").value = p.n_params.toExponential(2);
$("profile-has_swa").value = String(p.has_SWA);
$("profile-hf-status").innerHTML = `✅ ${id} (${p._family})`;
} catch (err) {
$("profile-hf-status").textContent = `❌ ${err.message}`;
} finally {
$("profile-fetch-btn").disabled = false;
}
});
$("profile-btn").addEventListener("click", async () => {
const params = {
theta: parseFloat($("profile-theta").value),
T_train: parseInt($("profile-T_train").value),
T_eval: parseInt($("profile-T_eval").value),
n_attention_heads: parseInt($("profile-n_attn").value),
n_kv_heads: parseInt($("profile-n_kv").value),
d_head: parseInt($("profile-d_head").value),
n_layers: parseInt($("profile-n_layers").value),
n_params: parseFloat($("profile-n_params").value),
has_SWA: $("profile-has_swa").value === "true",
};
setStatus("🧮 Profiling — running all 5 recipes...");
$("profile-btn").disabled = true;
try {
state.pyodide.globals.set("__pp", state.pyodide.toPy(params));
const json = state.pyodide.runPython(`
import json
result = profile_model(**__pp)
json.dumps(result)
`);
const profile = JSON.parse(json);
renderProfile(profile, params);
state.lastResult = { type: "profile", params };
state.lastFullResult = profile;
setStatus("✅ Profile ready.");
} catch (err) {
setStatus(`❌ ${err.message}`);
console.error(err);
} finally {
$("profile-btn").disabled = false;
}
});
function renderProfile(p, params) {
$("profile-output").style.display = "block";
// Hide other outputs
$("output-section").style.display = "none";
$("compare-output").style.display = "none";
const verdictClass = (v) => {
if (v.startsWith("YES") || v === "GO" || v.startsWith("USE SOFT")) return "v-yes";
if (v.startsWith("NO") || v.startsWith("MEMORY") || v === "TINY-MODEL") return "v-no";
return "v-deg";
};
const verdictEmoji = (v) => verdictClass(v) === "v-yes" ? "✅"
: verdictClass(v) === "v-no" ? "❌" : "⚠";
const ms = p.model_summary;
const kn = p.key_numbers;
const formatN = (x) => x === null || x === undefined ? "n/a"
: (typeof x === "number" ? x.toLocaleString(undefined, { maximumFractionDigits: 4 }) : String(x));
const recipesHtml = Object.entries(p.recipes).map(([rid, r]) => `
📋 Recipes — verdict per dimension ${recipeCount} ${t("tafcard.recipes_count_label", "dimensions")}
🔬 Diagnostics — numbers + γ check + what-if
🔢 Key numbers (paper §26)
🔍 γ predicted vs observed
🎚️ What-if explorer
✓ Verification — Lean + Sage + falsification
📑 Lean+Mathlib theorem table
🔬 Algebraic consistency (Sage + Lean v0.5)
🔬 Falsification status (F1-F23)
${falsHtml || '📂 Provenance & share
🔬 v0.5.3 — Calibration audit (2026-05-02)
ⓘ What do these mean?
🔍 Per-identity details (${total} checks)
Recipe: ${escapeHtml(cmp.recipe_id)} — ${escapeHtml(cmp.recipe_name)}
Shared params: ${escapeHtml(JSON.stringify(cmp.shared_params))}
| Model | Verdict | Reason | `; allKeys.forEach(k => html += `${escapeHtml(k)} | `); html += "
|---|---|---|---|
| ${escapeHtml(r.label)} | `; html += `${escapeHtml(r.verdict)} | `; html += `${escapeHtml(r.reason)} | `; allKeys.forEach(k => { const v = r.key_numbers ? r.key_numbers[k] : null; html += `${v === undefined || v === null ? "—" : (typeof v === "number" ? v.toLocaleString(undefined, { maximumFractionDigits: 2 }) : escapeHtml(String(v)))} | `; }); html += "