const ORGS = { bananamind: { name: "BananaMind", chartColor: "rgba(250, 204, 21, 0.70)", chartBorder: "#facc15", url: "https://huggingface.co/BananaMind" }, }; const MODELS = [ // Add models here. { name: "MicroBananaMind-v1", org: "bananamind", params: 902272, paramsDisplay: "902K", arc: 31.40, hellaswag: 26.53, piqa: 53.86, arcChall: 20.99, links: { card: "https://huggingface.co/BananaMind/MicroBananaMind-v1" } }, ]; const BENCHMARKS = [ { key: "avg", label: "Avg" }, { key: "arc", label: "ARC Easy" }, { key: "piqa", label: "PIQA" }, { key: "arcChall", label: "ARC Challenge" }, { key: "hellaswag", label: "HellaSwag" }, ]; const SIZE_FILTERS = [ ["all", "All"], [150, "<150M"], [100, "<100M"], [80, "<80M"], [50, "<50M"], [25, "<25M"], [10, "<10M"], [5, "<5M"], [3, "<3M"], [1, "<1M"], ]; const leaderboardHead = document.querySelector("#leaderboard-head"); const leaderboardBody = document.querySelector("#leaderboard-body"); const summaryStrip = document.querySelector("#summary-strip"); const sizeFilters = document.querySelector("#size-filters"); const orgFilter = document.querySelector("#org-filter"); const searchInput = document.querySelector("#search-input"); let activeSize = "all"; let activeOrg = "all"; let searchTerm = ""; let sortKey = "avg"; let sortDirection = "descending"; const rows = MODELS.map((model) => ({ ...model, avg: average([model.arc, model.piqa, model.arcChall, model.hellaswag]), })); function average(values) { const valid = values.filter((value) => Number.isFinite(value)); return valid.length ? valid.reduce((sum, value) => sum + value, 0) / valid.length : 0; } function escapeHtml(value) { return String(value) .replaceAll("&", "&") .replaceAll("<", "<") .replaceAll(">", ">") .replaceAll('"', """); } function orgFor(key) { return ORGS[key] || { name: key, chartBorder: "#9ca3af", chartColor: "rgba(156, 163, 175, 0.35)", url: "" }; } function renderHead() { leaderboardHead.innerHTML = ` # Model Org Params ${BENCHMARKS.map((metric) => `${metric.label}`).join("")} Card `; document.querySelectorAll(".sortable").forEach((header) => { header.addEventListener("click", () => { const nextKey = header.dataset.sort; sortDirection = sortKey === nextKey && sortDirection === "descending" ? "ascending" : "descending"; sortKey = nextKey; renderRows(); updateSortMarks(); }); }); updateSortMarks(); } function renderFilters() { sizeFilters.innerHTML = SIZE_FILTERS.map(([value, label]) => ` `).join(""); sizeFilters.querySelectorAll(".filter-button").forEach((button) => { button.addEventListener("click", () => { activeSize = button.dataset.size; renderFilters(); renderRows(); }); }); const usedOrgs = Object.entries(ORGS) .filter(([key]) => rows.some((row) => row.org === key)) .sort((first, second) => first[1].name.localeCompare(second[1].name)); orgFilter.innerHTML = `${usedOrgs .map(([key, org]) => ``) .join("")}`; orgFilter.value = activeOrg; } function filteredRows() { return rows.filter((row) => { const org = orgFor(row.org); const matchesSize = activeSize === "all" || row.params < Number(activeSize) * 1_000_000; const matchesOrg = activeOrg === "all" || row.org === activeOrg; const text = `${row.name} ${org.name} ${row.org}`.toLowerCase(); return matchesSize && matchesOrg && (!searchTerm || text.includes(searchTerm)); }); } function sortedRows() { const ranked = [...filteredRows()] .sort((first, second) => second.avg - first.avg) .map((row, index) => ({ ...row, rank: index + 1, orgName: orgFor(row.org).name })); return ranked.sort((first, second) => { const firstValue = first[sortKey]; const secondValue = second[sortKey]; const result = typeof firstValue === "string" ? firstValue.localeCompare(secondValue) : firstValue - secondValue; return sortDirection === "descending" ? -result : result; }); } function scoreCell(row, key) { const value = row[key]; const width = Math.max(0, Math.min(100, value)); return ` ${value.toFixed(2)} `; } function renderRows() { const visibleRows = sortedRows(); if (!visibleRows.length) { leaderboardBody.innerHTML = `

No matching models

Clear search or change filters.

`; renderSummary([]); return; } leaderboardBody.innerHTML = visibleRows.map((row) => { const org = orgFor(row.org); const cardUrl = row.links?.card || org.url || "#"; return ` ${row.rank} ${escapeHtml(row.name)} ${escapeHtml(org.name)} / ${escapeHtml(row.paramsDisplay)} ${escapeHtml(org.name)} ${escapeHtml(row.paramsDisplay)} ${BENCHMARKS.map((metric) => scoreCell(row, metric.key)).join("")} Open `; }).join(""); renderSummary(visibleRows); } function renderSummary(visibleRows) { const top = [...visibleRows].sort((first, second) => second.avg - first.avg)[0]; summaryStrip.innerHTML = `
${MODELS.length}models
${new Set(MODELS.map((model) => model.org)).size}orgs
${top ? top.avg.toFixed(2) : "--"}top avg
`; } function updateSortMarks() { document.querySelectorAll(".sortable").forEach((header) => { const mark = header.querySelector(".sort-mark"); const active = header.dataset.sort === sortKey; header.classList.toggle("is-sorted", active); header.setAttribute("aria-sort", active ? sortDirection : "none"); mark.textContent = active ? (sortDirection === "descending" ? "↓" : "↑") : ""; }); } orgFilter.addEventListener("change", () => { activeOrg = orgFilter.value; renderRows(); }); searchInput.addEventListener("input", () => { searchTerm = searchInput.value.trim().toLowerCase(); renderRows(); }); renderHead(); renderFilters(); renderRows();