/* Human pass rates and separately identified automatic likeness scores. */ const D = window.BUFO_BENCH || {}; const $ = id => document.getElementById(id); const esc = value => String(value ?? '').replace(/[&<>"']/g, char => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[char])); const models = Array.isArray(D.models) ? D.models : []; const tasks = Array.isArray(D.tasks) ? D.tasks : []; const attemptTotal = 10; const ratings = new Set(['bufo', 'close', 'not_bufo']); const modelById = id => models.find(model => model.id === id); const taskFor = (model, id) => (model?.tasks || []).find(task => task.id === id); const specFor = id => tasks.find(task => task.id === id) || {}; const hasImage = task => typeof task?.img === 'string' && task.img.length > 0; const isRating = rating => ratings.has(rating); function numberField(value) { return typeof value === 'number' && Number.isFinite(value) ? value : null; } function taskPendingCount(model) { const field = numberField(model?.pending_count); if (field !== null) return field; return (model?.tasks || []).filter(task => !isRating(task.rating) && task.status !== 'recorded_failure' && task.status !== 'unattempted').length; } function taskUnattemptedCount(model) { const field = numberField(model?.unattempted_count); if (field !== null) return field; return (model?.tasks || []).filter(task => task.status === 'unattempted').length; } function taskReviewedCount(model) { const field = numberField(model?.reviewed); if (field !== null) return field; return (model?.tasks || []).filter(task => isRating(task.rating)).length; } function scoreFor(model) { const score = model?.score; return Number.isInteger(score) && score >= 0 && score <= attemptTotal ? score : null; } function attemptsVerified(model) { return model?.attempts_verified === true || model?.attempts_verified === attemptTotal; } function isRanked(model) { return scoreFor(model) !== null && attemptsVerified(model) && taskPendingCount(model) === 0 && taskUnattemptedCount(model) === 0; } function defaultModel() { return models.find(model => (model.tasks || []).some(hasImage)) || models[0]; } function rankedModels() { return models.filter(isRanked).sort((a, b) => scoreFor(b) - scoreFor(a) || String(a.id).localeCompare(String(b.id))); } function rankOf(model) { const score = scoreFor(model); return 1 + rankedModels().filter(candidate => scoreFor(candidate) > score).length; } function isTied(model) { const score = scoreFor(model); return rankedModels().some(candidate => candidate.id !== model.id && scoreFor(candidate) === score); } function scoreText(model) { const score = scoreFor(model); if (!isRanked(model) || score === null) return '—Coverage pending'; const ability = score > 0 ? 'Demonstrated' : 'No passing samples'; return `${score} / 10${score * 10}% pass rate · recognizes Bufo${ability}`; } function automaticScoreText(item, compact = false) { const score = numberField(item?.automatic_score); if (score === null) return ''; return `

Auto likeness: ${score.toFixed(1)} / 100${compact ? '' : '
Experimental · Bufo Score v1'}

`; } function usd(value) { return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(value); } function finiteCost(model, field = 'cost_per_image_usd') { const cost = numberField(model?.[field]); return cost !== null && cost >= 0 ? cost : null; } function costSource(model) { if (model?.cost_basis) return model.cost_basis; if (model?.cost_estimated) return 'Estimated'; if (finiteCost(model, 'generation_cost_usd') !== null) return 'Measured run'; return 'Cost not recorded'; } function costMarkup(model) { const cost = finiteCost(model); if (cost === null) { const label = typeof model?.cost_rate_label === 'string' && model.cost_rate_label.trim() ? model.cost_rate_label : 'Not recorded'; return `${esc(label)}${esc(costSource(model))}`; } const prefix = model.cost_estimated ? '≈ ' : ''; return `${prefix}${usd(cost)} / image${esc(costSource(model))}`; } function costPerPass(model) { for (const field of ['cost_per_passing_bufo_usd', 'cost_per_bufo_usd', 'cost_per_pass_usd']) { const cost = finiteCost(model, field); if (cost !== null) return cost; } return null; } function costPerPassRange(model) { const range = model?.cost_per_bufo_range_usd; if (!Array.isArray(range) || range.length !== 2) return null; const values = range.map(value => numberField(value)); if (values.some(value => value === null || value < 0) || values[0] > values[1]) return null; return values; } function acceptedCostMarkup(model) { const cost = costPerPass(model); const range = costPerPassRange(model); if (!isRanked(model) || scoreFor(model) === 0 || (cost === null && range === null)) return ''; const value = cost === null ? `${usd(range[0])}–${usd(range[1])}` : `${model.cost_estimated ? '≈ ' : ''}${usd(cost)}`; const rangeText = range && cost !== null ? `range ${usd(range[0])}–${usd(range[1])}` : ''; const basis = typeof model?.cost_per_bufo_basis === 'string' && model.cost_per_bufo_basis.trim() ? model.cost_per_bufo_basis : ''; return `Cost / passing Bufo${value}${rangeText}${basis ? `${esc(basis)}` : ''}`; } function statusText(model) { const pending = taskPendingCount(model); const unattempted = taskUnattemptedCount(model); const reviewed = taskReviewedCount(model); const errors = numberField(model?.error_count) ?? (model?.tasks || []).filter(task => task.status === 'recorded_failure').length; if (isRanked(model)) { return `${attemptTotal} attempts verified${errors ? ` · ${errors} generation failure${errors === 1 ? '' : 's'} count as zero points` : ''}`; } if (unattempted) return `${reviewed} labeled · ${unattempted} unattempted · no rank`; if (pending) return `${reviewed} / ${attemptTotal} labels reviewed · ${pending} awaiting human review`; return 'Human coverage is incomplete · no rank'; } function ratingChip(rating) { if (rating === 'bufo') return 'Bufo'; if (rating === 'close') return 'Close'; if (rating === 'not_bufo') return 'Not Bufo'; return 'Awaiting human label'; } function taskLabel(task) { if (isRating(task?.rating)) return ratingChip(task.rating); if (task?.status === 'recorded_failure') return 'Generation failed'; if (task?.status === 'unattempted') return 'Unattempted'; return ratingChip(null); } function taskStatus(task) { if (isRating(task?.rating)) return 'Human label recorded'; if (task?.status === 'recorded_failure') return 'Verified generation failure · zero points'; if (task?.status === 'unattempted') return 'No attempt recorded · this model stays unranked'; return 'The image is here; its human label is still pending'; } function taskTitle(task) { return task?.title || specFor(task?.id).title || task?.id || 'Untitled task'; } function taskPrompt(task) { return task?.prompt || specFor(task?.id).prompt || 'Prompt not supplied.'; } function valueFrontier() { const comparable = rankedModels().filter(model => finiteCost(model) !== null); return new Set(comparable.filter(candidate => !comparable.some(other => { if (other.id === candidate.id) return false; const cheaperOrEqual = finiteCost(other) <= finiteCost(candidate); const atLeastAsSuccessful = scoreFor(other) >= scoreFor(candidate); const strictlyBetter = finiteCost(other) < finiteCost(candidate) || scoreFor(other) > scoreFor(candidate); return cheaperOrEqual && atLeastAsSuccessful && strictlyBetter; })).map(model => model.id)); } function updateCoverage() { const ranked = rankedModels(); const reviewed = models.reduce((sum, model) => sum + taskReviewedCount(model), 0); const pending = models.reduce((sum, model) => sum + taskPendingCount(model), 0); const unattempted = models.reduce((sum, model) => sum + taskUnattemptedCount(model), 0); const possible = models.length * attemptTotal; const rankedText = String(ranked.length); $('your-picks').textContent = $('your-picks').textContent || 'No votes saved yet'; const coverage = models.length ? `${ranked.length} of ${models.length} model${models.length === 1 ? '' : 's'} have a verified human pass rate.${pending ? ` ${pending} attempt${pending === 1 ? '' : 's'} await human review.` : ''}${unattempted ? ` ${unattempted} unattempted attempt${unattempted === 1 ? '' : 's'} stay unranked.` : ''}` : 'No model runs are available yet.'; if ($('coverage-summary')) $('coverage-summary').textContent = coverage; if ($('reviewed-count')) $('reviewed-count').textContent = possible ? `${reviewed} / ${possible}` : '0'; if ($('pending-count')) $('pending-count').textContent = String(pending); if ($('ranked-count')) $('ranked-count').textContent = rankedText; if ($('hero-reviewed')) $('hero-reviewed').textContent = String(reviewed); if ($('hero-attempts')) $('hero-attempts').textContent = String(attemptTotal); if ($('hero-ranked')) $('hero-ranked').textContent = rankedText; } function boardRow(model, frontier) { const ranked = isRanked(model); const rank = ranked ? `${rankOf(model)}${isTied(model) ? '=' : ''}` : '—'; const name = model.name || String(model.id || 'Unnamed model').split('/').pop(); return `${scoreText(model)}${automaticScoreText(model)}${costMarkup(model)}${acceptedCostMarkup(model)}${frontier.has(model.id) ? 'Good value' : ''}`; } function comparePassCost(a, b) { const leftRank = passCostOrder(a); const rightRank = passCostOrder(b); return leftRank - rightRank || scoreFor(b) - scoreFor(a) || String(a.id).localeCompare(String(b.id)); } function passCostOrder(model) { const cost = costPerPass(model); return cost !== null && cost >= 0 ? cost : Infinity; } function renderBoard() { const minimum = Number($('min-score')?.value) || 0; if ($('min-score-value')) $('min-score-value').textContent = `${minimum} / ${attemptTotal}`; const frontier = valueFrontier(); let ranked = rankedModels().filter(model => scoreFor(model) >= minimum); const waiting = models.filter(model => !isRanked(model)); if ($('board-sort')?.value === 'pass-cost') { ranked.sort(comparePassCost); waiting.sort((a, b) => passCostOrder(a) - passCostOrder(b) || String(a.id).localeCompare(String(b.id))); } else if ($('board-sort')?.value === 'image-cost') { ranked.sort((a, b) => (finiteCost(a) ?? Infinity) - (finiteCost(b) ?? Infinity) || scoreFor(b) - scoreFor(a) || String(a.id).localeCompare(String(b.id))); waiting.sort((a, b) => taskPendingCount(a) - taskPendingCount(b) || String(a.id).localeCompare(String(b.id))); } const shown = [...ranked, ...waiting]; $('board').innerHTML = shown.length ? shown.map(model => boardRow(model, frontier)).join('') : 'No model runs are on the board yet. The frogs will be here when they arrive.'; const pricedByPass = ranked.filter(model => costPerPass(model) !== null && costPerPass(model) >= 0).sort(comparePassCost); const measured = ranked.filter(model => finiteCost(model) !== null).sort((a, b) => finiteCost(a) - finiteCost(b)); $('cost-summary').textContent = $('board-sort')?.value === 'pass-cost' ? (pricedByPass.length ? `Lowest listed cost per passing Bufo among models meeting ${minimum} / ${attemptTotal}: ${pricedByPass[0].name || pricedByPass[0].id}, ${modelPassCostText(pricedByPass[0])}. ≈ means estimated.` : `No listed cost per passing Bufo meets ${minimum} / ${attemptTotal}.`) : (measured.length ? `Lowest listed cost among models meeting ${minimum} / ${attemptTotal}: ${measured[0].name || measured[0].id}, ${modelCostText(measured[0])}. ≈ means estimated.` : `No listed prices meet ${minimum} / ${attemptTotal}.`); const unranked = models.filter(model => !isRanked(model)); $('unranked').innerHTML = unranked.length ? `

${unranked.length} model${unranked.length === 1 ? '' : 's'} remain visible without a rank. Missing review is not a zero. Open a row to inspect its images.

` : ''; } function modelCostText(model) { const cost = finiteCost(model); if (cost !== null) return `${model.cost_estimated ? '≈ ' : ''}${usd(cost)} / image`; return typeof model?.cost_rate_label === 'string' && model.cost_rate_label.trim() ? model.cost_rate_label : 'not recorded'; } function modelPassCostText(model) { const cost = costPerPass(model); return cost === null ? 'not recorded' : `${model.cost_estimated ? '≈ ' : ''}${usd(cost)} / passing Bufo`; } function pageUrl(kind, params) { const url = new URL(location.href); url.search = ''; url.hash = kind; Object.entries(params).forEach(([key, value]) => { if (value !== undefined && value !== null && value !== '') url.searchParams.set(key, value); }); return url; } function setUrl(url) { history.pushState({}, '', url); } function showModel(id, update = true) { const model = modelById(id) || defaultModel(); if (!model) return; $('model-select').value = model.id; renderGallery(); if (update) { setUrl(pageUrl('gallery', { model: model.id, g_task: $('task-select').value })); $('gallery').scrollIntoView({ behavior: 'smooth', block: 'start' }); } } function renderGallery() { const model = modelById($('model-select').value) || defaultModel(); if (!model) { $('model-heading').innerHTML = '

No model run has arrived yet.

'; $('gallery-images').innerHTML = '

There are no images to inspect yet.

'; return; } const rate = isRanked(model) ? `Human pass rate: ${scoreFor(model)} / ${attemptTotal} · ${scoreFor(model) * 10}% · recognizes Bufo` : 'Human pass rate: coverage pending'; const configuration = typeof model.configuration_note === 'string' && model.configuration_note.trim() ? `

${esc(model.configuration_note)}

` : ''; $('model-heading').innerHTML = `

${esc(model.name || model.id)}

${automaticScoreText(model)}

${rate}

${esc(statusText(model))}

${configuration}
`; $('share-model').onclick = () => share(pageUrl('gallery', { model: model.id }), `${model.name || model.id} on BufoBench. ${numberField(model.automatic_score) !== null ? `Automatic likeness: ${model.automatic_score.toFixed(1)} / 100 (experimental). ` : ''}${isRanked(model) ? `Human pass rate: ${scoreFor(model)} / ${attemptTotal}.` : 'Human review is still pending.'}`); const filter = $('task-select').value; const modelTasks = (model.tasks || []).filter(task => !filter || task.id === filter); $('gallery-images').innerHTML = modelTasks.length ? modelTasks.map(task => ``).join('') : '

No task matches that filter.

'; } function openImage(id) { const model = modelById($('model-select').value); const task = taskFor(model, id); if (!hasImage(task)) return; $('full-image').src = task.img; $('full-image').alt = taskTitle(task); $('image-caption').innerHTML = `${esc(model.name || model.id)} · ${esc(taskTitle(task))} · ${taskLabel(task)}`; $('image-dialog').showModal(); } function requestedMatch() { const query = new URL(location.href).searchParams; const a = modelById(query.get('a')); const b = modelById(query.get('b')); const task = query.get('task'); if (a && b && a !== b && hasImage(taskFor(a, task)) && hasImage(taskFor(b, task))) return { a, b, task }; return null; } function eligibleTasks() { return tasks.filter(spec => models.filter(model => hasImage(taskFor(model, spec.id))).length >= 2); } function recordKey(a, b, task) { return JSON.stringify([[a.id, b.id].sort(), task]); } let votes = {}; let storageAvailable = true; let match = null; let revealed = false; let choice = null; let lastMatch = ''; const storageKey = `bufo-picks-${D.method?.version || 'human-benchmark-v1'}`; try { const saved = JSON.parse(localStorage.getItem(storageKey) || '{}'); if (saved && typeof saved === 'object' && !Array.isArray(saved)) votes = saved; } catch { storageAvailable = false; } function updatePickCount() { $('your-picks').textContent = storageAvailable ? `${Object.keys(votes).length} vote${Object.keys(votes).length === 1 ? '' : 's'} saved in this browser` : 'Votes are not saved in this browser'; } function renderEmptyBattle() { $('battle-task').textContent = 'No image pair yet'; $('battle-options').innerHTML = '

We need two returned images for the same task before a blind matchup can begin.

'; $('battle-coverage').textContent = ''; $('tie').hidden = true; $('share-battle').hidden = true; $('next-battle').textContent = 'Try again →'; } function deal(initial = false) { const requested = initial ? requestedMatch() : null; if (requested) match = requested; else { const choices = eligibleTasks(); if (!choices.length) { match = null; renderEmptyBattle(); return; } for (let attempt = 0; attempt < 10; attempt += 1) { const task = choices[Math.floor(Math.random() * choices.length)].id; const candidates = models.filter(model => hasImage(taskFor(model, task))); const a = candidates[Math.floor(Math.random() * candidates.length)]; const remaining = candidates.filter(model => model !== a); const b = remaining[Math.floor(Math.random() * remaining.length)]; const candidate = { a, b, task }; match = candidate; if (recordKey(a, b, task) !== lastMatch || candidates.length < 3) break; } } lastMatch = recordKey(match.a, match.b, match.task); revealed = false; choice = null; renderMatch(); if (!initial) setUrl(pageUrl('battle', { a: match.a.id, b: match.b.id, task: match.task })); } function renderMatch() { if (!match) return; const a = taskFor(match.a, match.task); const b = taskFor(match.b, match.task); $('battle-task').textContent = taskTitle(a); $('battle-coverage').textContent = revealed ? 'Names and labels revealed' : 'Same prompt · names hidden'; $('battle-options').innerHTML = [a, b].map((task, index) => { const model = index ? match.b : match.a; const label = revealed ? taskLabel(task) : ''; const name = revealed ? `${esc(model.name || model.id)}` : `Pick frog ${index ? 'B' : 'A'} →`; const status = revealed ? `${esc(taskStatus(task))}` : ''; return ``; }).join(''); $('tie').hidden = revealed; $('share-battle').hidden = !revealed; $('next-battle').textContent = 'Another pair →'; $('battle-result').textContent = revealed ? choice === 'tie' ? 'A tie. Your vote stays local and does not affect the benchmark.' : `You picked ${choice === 0 ? match.a.name || match.a.id : match.b.name || match.b.id}. Your vote stays local and does not affect the benchmark.` : ''; } function pick(value) { if (!match || revealed) return; choice = value; revealed = true; votes[lastMatch] = { pick: value === 'tie' ? 'tie' : value === 0 ? match.a.id : match.b.id }; try { localStorage.setItem(storageKey, JSON.stringify(votes)); } catch { storageAvailable = false; } updatePickCount(); renderMatch(); $('next-battle').focus(); } async function share(url, text) { $('share-status').textContent = ''; $('share-fallback').hidden = true; if (typeof navigator !== 'undefined' && navigator.share) { try { await navigator.share({ title: 'Bufo Benchmark', text, url: String(url) }); $('share-status').textContent = 'Shared.'; return; } catch (error) { if (error?.name === 'AbortError') return; } } try { if (!navigator.clipboard?.writeText) throw new Error('Clipboard unavailable'); await navigator.clipboard.writeText(String(url)); $('share-status').textContent = 'Link copied. Send it to someone with frog opinions.'; } catch { $('share-fallback').hidden = false; $('share-fallback').value = String(url); $('share-fallback').focus(); $('share-fallback').select(); $('share-status').textContent = 'Copy this link to share.'; } } $('board-sort').onchange = renderBoard; $('min-score').oninput = renderBoard; $('clear-filter').onclick = () => { $('min-score').value = '0'; renderBoard(); }; $('board').onclick = $('unranked').onclick = event => { const button = event.target.closest('[data-model]'); if (button) showModel(button.dataset.model); }; $('model-select').innerHTML = models.length ? models.map(model => ``).join('') : ''; $('task-select').innerHTML = '' + tasks.map(task => ``).join(''); $('model-select').onchange = () => showModel($('model-select').value); $('task-select').onchange = () => { renderGallery(); setUrl(pageUrl('gallery', { model: $('model-select').value, g_task: $('task-select').value })); }; $('gallery-images').onclick = event => { const button = event.target.closest('[data-image]'); if (button) openImage(button.dataset.image); }; $('close-image').onclick = () => $('image-dialog').close(); $('battle-options').onclick = event => { const button = event.target.closest('[data-choice]'); if (button) pick(Number(button.dataset.choice)); }; $('tie').onclick = () => pick('tie'); $('next-battle').onclick = () => deal(); $('share-battle').onclick = () => { if (match) share(pageUrl('battle', { a: match.a.id, b: match.b.id, task: match.task }), 'Which frog looks more like Bufo? Compare this blind matchup.'); }; function readLocation() { const query = new URL(location.href).searchParams; $('model-select').value = modelById(query.get('model'))?.id || defaultModel()?.id || ''; $('task-select').value = tasks.some(task => task.id === query.get('g_task')) ? query.get('g_task') : ''; renderGallery(); deal(true); } window.addEventListener('popstate', readLocation); $('method-text').textContent = 'Every model gets ten fixed prompts. People label each returned image as Bufo, Close, or Not Bufo. The public pass rate is Bufo labels divided by ten: it measures how often this run recognizes Bufo. These human labels are the source of truth here and can help calibrate future judging.'; $('method-version').textContent = 'Human benchmark v1 · ten samples per model, a useful snapshot rather than a definitive claim about every generation · visitor votes never affect the result.'; if (D.automatic_judging) { $('method-text').textContent += ' Automatic likeness is a separate 0–100 score: ' + D.automatic_judging.description; $('method-version').textContent += ' Automatic judge: ' + D.automatic_judging.version + ' (experimental).'; } updateCoverage(); updatePickCount(); renderBoard(); readLocation();