Spaces:
Running
Running
toolkit index
Browse files- README.md +51 -4
- app.js +78 -0
- assert-logo.png +0 -0
- index.html +131 -17
- tools.js +124 -0
README.md
CHANGED
|
@@ -1,10 +1,57 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: blue
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
|
|
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Serving a model on your own GPU
|
| 3 |
+
emoji: 🧭
|
| 4 |
colorFrom: blue
|
| 5 |
+
colorTo: gray
|
| 6 |
sdk: static
|
| 7 |
+
app_file: index.html
|
| 8 |
pinned: false
|
| 9 |
+
license: apache-2.0
|
| 10 |
+
short_description: Five questions between a model page and a model that runs
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# Serving a model on your own GPU
|
| 14 |
+
|
| 15 |
+
Five questions stand between a model page and a model that runs, and
|
| 16 |
+
every one of them has an answer already sitting in the repo's metadata.
|
| 17 |
+
This page is the index of the tools that read it — in the visitor's
|
| 18 |
+
browser, without downloading weights and without running anything.
|
| 19 |
+
|
| 20 |
+
| The question | The tool |
|
| 21 |
+
|---|---|
|
| 22 |
+
| Which model should I even try? | [Find a model that fits](https://huggingface.co/spaces/aleada/model-search-that-answers) |
|
| 23 |
+
| How much context can I actually serve? | [What context will actually fit?](https://huggingface.co/spaces/aleada/what-context-fits) |
|
| 24 |
+
| How do I run it correctly? | [Does this model need a reasoning parser?](https://huggingface.co/spaces/aleada/reasoning-parser-advisor) |
|
| 25 |
+
| What did this quantized pack really compress? | [How much of this pack is actually 4-bit?](https://huggingface.co/spaces/aleada/pack-precision-map) |
|
| 26 |
+
| Is the pack what it claims to be? | [Does this pack keep what it claims?](https://huggingface.co/spaces/aleada/pack-integrity-check) |
|
| 27 |
+
|
| 28 |
+
Put a model in the box and every step opens with it already filled in —
|
| 29 |
+
`?repo=owner/model` is read by each tool, so a model travels with you
|
| 30 |
+
through the chain instead of being retyped five times.
|
| 31 |
+
|
| 32 |
+
## Why metadata is enough
|
| 33 |
+
|
| 34 |
+
A model repo publishes its architecture, its attention topology, its
|
| 35 |
+
tensor index and its chat template before you download a byte of
|
| 36 |
+
weights. Almost every serving failure — it will not fit, the context is
|
| 37 |
+
too long, the answers come back empty, the pack is not what its name
|
| 38 |
+
says — is decidable from that alone.
|
| 39 |
+
|
| 40 |
+
None of these tools loads a model, so none of them can tell you how
|
| 41 |
+
*good* it is. They tell you whether it will work, and what it will cost.
|
| 42 |
+
|
| 43 |
+
## Development
|
| 44 |
+
|
| 45 |
+
The list of tools lives once, in `space-shared/tools.js`, and is copied
|
| 46 |
+
into each Space at deploy time. This page renders from that same
|
| 47 |
+
registry rather than from its own copy — a landing page listing tools
|
| 48 |
+
from a private list is the first place a rename goes stale, and the one
|
| 49 |
+
page where a dead link costs the most.
|
| 50 |
+
|
| 51 |
+
```bash
|
| 52 |
+
./stage-shared.sh
|
| 53 |
+
./deploy.sh aleada/start-here
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
Built from the tooling behind the
|
| 57 |
+
[aleada](https://huggingface.co/aleada) W4A16 packs.
|
app.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The index page: the five questions, in the order they come up.
|
| 3 |
+
*
|
| 4 |
+
* The list is rendered from the shared registry in `tools.js` rather
|
| 5 |
+
* than written out here — the same registry the five tools link each
|
| 6 |
+
* other with. A landing page that lists the tools from its own copy is
|
| 7 |
+
* the first place a rename goes stale, and it is the one page where a
|
| 8 |
+
* dead link costs the most.
|
| 9 |
+
*/
|
| 10 |
+
import { ORDER, TOOLS, url } from './tools.js';
|
| 11 |
+
|
| 12 |
+
const $ = (id) => document.getElementById(id);
|
| 13 |
+
const esc = (s) => String(s).replace(/[&<>"]/g, (c) =>
|
| 14 |
+
({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
| 15 |
+
|
| 16 |
+
/** What each step is for, in the words somebody arrives with. */
|
| 17 |
+
const SAYS = {
|
| 18 |
+
search: 'Filter the Hub by what decides usability rather than by task and '
|
| 19 |
+
+ 'licence: real size, how much of a pack is genuinely quantized, mixture '
|
| 20 |
+
+ 'of experts or dense, and whether serving it needs a reasoning parser.',
|
| 21 |
+
context: 'Weights fitting is not the same as the model running. The KV cache '
|
| 22 |
+
+ 'grows with context, and how fast depends on an attention topology most '
|
| 23 |
+
+ 'estimates assume rather than read. This gives you a starting '
|
| 24 |
+
+ '--max-model-len.',
|
| 25 |
+
parser: 'A model that thinks needs vLLM to split that thinking out of the '
|
| 26 |
+
+ 'answer. Guess wrong in one direction and users see the thinking; wrong '
|
| 27 |
+
+ 'in the other and the reply comes back empty with no error at all.',
|
| 28 |
+
precision: 'A pack named 4-bit is never 4-bit throughout — embeddings, the '
|
| 29 |
+
+ 'output head and the norms are usually kept whole. This says how much '
|
| 30 |
+
+ 'was really compressed and, more usefully, what was not.',
|
| 31 |
+
integrity: 'Quantization can drop or disable part of a model without '
|
| 32 |
+
+ 'failing: the pack loads, serves, answers correctly, and something its '
|
| 33 |
+
+ 'card promises is missing. This compares what it claims against what is '
|
| 34 |
+
+ 'in it.',
|
| 35 |
+
};
|
| 36 |
+
|
| 37 |
+
/** The question each step answers, phrased as the visitor would ask it. */
|
| 38 |
+
const ASKS = {
|
| 39 |
+
search: 'Which model should I even try?',
|
| 40 |
+
context: 'How much context can I actually serve?',
|
| 41 |
+
parser: 'How do I run it correctly?',
|
| 42 |
+
precision: 'What did this quantized pack really compress?',
|
| 43 |
+
integrity: 'Is the pack what it claims to be?',
|
| 44 |
+
};
|
| 45 |
+
|
| 46 |
+
function render(repo) {
|
| 47 |
+
$('steps').innerHTML = ORDER.map((key) => {
|
| 48 |
+
const t = TOOLS[key];
|
| 49 |
+
const href = url(key, repo);
|
| 50 |
+
const label = repo && t.takes === 'repo'
|
| 51 |
+
? `open for ${repo}`
|
| 52 |
+
: repo && t.takes === 'query' ? `search for ${repo}` : 'open';
|
| 53 |
+
return `<li>
|
| 54 |
+
<span class="q">${esc(ASKS[key])}</span>
|
| 55 |
+
<a href="${href}" target="_blank" rel="noopener">${esc(t.title)}</a>
|
| 56 |
+
<p>${esc(SAYS[key])}</p>
|
| 57 |
+
<a class="go" href="${href}" target="_blank" rel="noopener">${esc(label)} →</a>
|
| 58 |
+
</li>`;
|
| 59 |
+
}).join('');
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
// Every link re-renders as the box is typed in, so the page never offers
|
| 63 |
+
// a link that carries a model the visitor has since changed.
|
| 64 |
+
$('repo').addEventListener('input', () => render($('repo').value.trim()));
|
| 65 |
+
$('form').addEventListener('submit', (e) => e.preventDefault());
|
| 66 |
+
document.querySelectorAll('[data-fill]').forEach((a) =>
|
| 67 |
+
a.addEventListener('click', (e) => {
|
| 68 |
+
e.preventDefault();
|
| 69 |
+
$('repo').value = a.dataset.fill;
|
| 70 |
+
render(a.dataset.fill);
|
| 71 |
+
}));
|
| 72 |
+
|
| 73 |
+
// A model can be handed to this page too, so a link into the toolkit
|
| 74 |
+
// from anywhere lands with it already set.
|
| 75 |
+
const params = new URLSearchParams(window.location.search);
|
| 76 |
+
const initial = (params.get('repo') || '').trim();
|
| 77 |
+
if (initial) $('repo').value = initial;
|
| 78 |
+
render(initial || null);
|
assert-logo.png
ADDED
|
index.html
CHANGED
|
@@ -1,19 +1,133 @@
|
|
| 1 |
<!doctype html>
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</html>
|
|
|
|
| 1 |
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 6 |
+
<title>Serving a model on your own GPU</title>
|
| 7 |
+
<!-- The Space renders inside an iframe and huggingface.co sends
|
| 8 |
+
x-frame-options: DENY, so any link without a target tries to load a
|
| 9 |
+
refused page in the frame and reads as broken. -->
|
| 10 |
+
<base target="_blank">
|
| 11 |
+
<style>
|
| 12 |
+
:root {
|
| 13 |
+
--bg: #fbfbfa; --panel: #ffffff; --ink: #1a1a19; --muted: #6b6b66;
|
| 14 |
+
--line: #e4e3df; --accent: #3d5a80;
|
| 15 |
+
--mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;
|
| 16 |
+
}
|
| 17 |
+
@media (prefers-color-scheme: dark) {
|
| 18 |
+
:root {
|
| 19 |
+
--bg: #16171a; --panel: #1d1f23; --ink: #e8e6e3; --muted: #9a978f;
|
| 20 |
+
--line: #2e3137; --accent: #8ab0d9;
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
* { box-sizing: border-box; }
|
| 24 |
+
body {
|
| 25 |
+
margin: 0; background: var(--bg); color: var(--ink);
|
| 26 |
+
font: 16px/1.65 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
|
| 27 |
+
-webkit-font-smoothing: antialiased;
|
| 28 |
+
}
|
| 29 |
+
.wrap { max-width: 46rem; margin: 0 auto; padding: 3.5rem 1.25rem 5rem; }
|
| 30 |
+
.brand { display: inline-block; margin-bottom: 1.75rem; }
|
| 31 |
+
.brand img { height: 1.5rem; width: auto; display: block; filter: invert(1); opacity: .78; }
|
| 32 |
+
@media (prefers-color-scheme: dark) { .brand img { filter: none; opacity: .9; } }
|
| 33 |
+
|
| 34 |
+
h1 { font-size: clamp(1.6rem, 4.5vw, 2.2rem); line-height: 1.2;
|
| 35 |
+
letter-spacing: -0.02em; margin: 0 0 .75rem; font-weight: 620; }
|
| 36 |
+
header p { color: var(--muted); margin: 0 0 .6rem; }
|
| 37 |
+
|
| 38 |
+
form { display: flex; gap: .5rem; margin: 2rem 0 .5rem; }
|
| 39 |
+
input {
|
| 40 |
+
flex: 1 1 auto; min-width: 0; height: 2.7rem; padding: 0 .8rem;
|
| 41 |
+
border: 1px solid var(--line); border-radius: .5rem;
|
| 42 |
+
background: var(--panel); color: var(--ink);
|
| 43 |
+
font: inherit; font-family: var(--mono); font-size: .92rem;
|
| 44 |
+
}
|
| 45 |
+
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
|
| 46 |
+
.hint { font-size: .84rem; color: var(--muted); margin: 0 0 2.5rem; }
|
| 47 |
+
|
| 48 |
+
ol.steps { list-style: none; counter-reset: s; margin: 0; padding: 0; }
|
| 49 |
+
ol.steps > li {
|
| 50 |
+
counter-increment: s; position: relative;
|
| 51 |
+
padding: 1.1rem 0 1.1rem 3rem; border-top: 1px solid var(--line);
|
| 52 |
+
}
|
| 53 |
+
ol.steps > li::before {
|
| 54 |
+
content: counter(s); position: absolute; left: 0; top: 1.15rem;
|
| 55 |
+
width: 1.9rem; height: 1.9rem; border-radius: 50%;
|
| 56 |
+
border: 1px solid var(--line); background: var(--panel);
|
| 57 |
+
display: grid; place-items: center;
|
| 58 |
+
font-family: var(--mono); font-size: .82rem; color: var(--muted);
|
| 59 |
+
}
|
| 60 |
+
.q { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .15rem; }
|
| 61 |
+
.steps a { font-size: 1.03rem; font-weight: 600; color: var(--accent); text-decoration: none; }
|
| 62 |
+
.steps a:hover { text-decoration: underline; }
|
| 63 |
+
.steps p { margin: .35rem 0 0; color: var(--muted); font-size: .92rem; }
|
| 64 |
+
.steps .go {
|
| 65 |
+
display: inline-block; margin-top: .5rem; font-size: .84rem;
|
| 66 |
+
font-family: var(--mono); color: var(--accent); text-decoration: none;
|
| 67 |
+
border: 1px solid var(--line); border-radius: .4rem; padding: .25rem .6rem;
|
| 68 |
+
font-weight: 400;
|
| 69 |
+
}
|
| 70 |
+
.steps .go:hover { border-color: var(--accent); text-decoration: none; }
|
| 71 |
+
|
| 72 |
+
h2 { font-size: 1.02rem; font-weight: 600; margin: 3rem 0 .6rem; }
|
| 73 |
+
code { font-family: var(--mono); font-size: .86em; }
|
| 74 |
+
footer { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--line);
|
| 75 |
+
font-size: .87rem; color: var(--muted); }
|
| 76 |
+
footer a { color: var(--accent); }
|
| 77 |
+
</style>
|
| 78 |
+
</head>
|
| 79 |
+
<body>
|
| 80 |
+
<div class="wrap">
|
| 81 |
+
|
| 82 |
+
<header>
|
| 83 |
+
<a class="brand" href="https://assert.gr" rel="noopener">
|
| 84 |
+
<img src="./assert-logo.png" alt="ASSERT" width="420" height="87">
|
| 85 |
+
</a>
|
| 86 |
+
<h1>Serving a model on your own GPU</h1>
|
| 87 |
+
<p>
|
| 88 |
+
Five questions stand between a model page and a model that runs, and every
|
| 89 |
+
one of them has an answer already sitting in the repo's metadata. These
|
| 90 |
+
tools read it — in your browser, without downloading weights and without
|
| 91 |
+
running anything.
|
| 92 |
+
</p>
|
| 93 |
+
<p>
|
| 94 |
+
Put a model in the box and each step below opens with it already filled in.
|
| 95 |
+
</p>
|
| 96 |
+
</header>
|
| 97 |
+
|
| 98 |
+
<form id="form">
|
| 99 |
+
<input type="text" id="repo" placeholder="owner/model — optional"
|
| 100 |
+
autocomplete="off" spellcheck="false" aria-label="Model repo id">
|
| 101 |
+
</form>
|
| 102 |
+
<p class="hint" id="hint">
|
| 103 |
+
Leave it empty to browse, or try
|
| 104 |
+
<a href="#" data-fill="google/gemma-4-12B-it">google/gemma-4-12B-it</a> ·
|
| 105 |
+
<a href="#" data-fill="aleada/Nemotron-3.5-Lightning-30B-A3B-W4A16">aleada/Nemotron-3.5-…-W4A16</a>
|
| 106 |
+
</p>
|
| 107 |
+
|
| 108 |
+
<ol class="steps" id="steps"></ol>
|
| 109 |
+
|
| 110 |
+
<h2>Why metadata is enough</h2>
|
| 111 |
+
<p style="color:var(--muted)">
|
| 112 |
+
A model repo publishes its architecture, its attention topology, its tensor
|
| 113 |
+
index and its chat template before you download a byte of weights. Almost
|
| 114 |
+
every serving failure — it will not fit, the context is too long, the answers
|
| 115 |
+
come back empty, the pack is not what its name says — is decidable from that
|
| 116 |
+
alone. None of these tools loads a model, so none of them can tell you how
|
| 117 |
+
<em>good</em> it is. They tell you whether it will work, and what it will
|
| 118 |
+
cost.
|
| 119 |
+
</p>
|
| 120 |
+
|
| 121 |
+
<footer>
|
| 122 |
+
<p>
|
| 123 |
+
Built from the tooling behind the
|
| 124 |
+
<a href="https://huggingface.co/aleada" rel="noopener">aleada</a> W4A16
|
| 125 |
+
packs — quantized models whose cards report what quantization actually cost
|
| 126 |
+
them, measured against the original.
|
| 127 |
+
</p>
|
| 128 |
+
</footer>
|
| 129 |
+
|
| 130 |
+
</div>
|
| 131 |
+
<script type="module" src="./app.js"></script>
|
| 132 |
+
</body>
|
| 133 |
</html>
|
tools.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The five tools, declared once.
|
| 3 |
+
*
|
| 4 |
+
* Each Space linked to the others from its own footer, which meant the
|
| 5 |
+
* same five URLs written out in five files — twenty-five places for a
|
| 6 |
+
* rename to break, and a Space rename is invisible from the linking
|
| 7 |
+
* side: the link keeps returning a page, and the page is a 404.
|
| 8 |
+
*
|
| 9 |
+
* So the registry lives here and is copied into each Space at deploy
|
| 10 |
+
* time, next to `progress.js`. One file to change when a tool moves.
|
| 11 |
+
*
|
| 12 |
+
* The order is the order somebody actually needs them: find a model,
|
| 13 |
+
* see how much context it can serve, learn how to run it, then check
|
| 14 |
+
* what the pack really contains before spending the download.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
export const TOOLS = {
|
| 18 |
+
search: {
|
| 19 |
+
space: 'model-search-that-answers',
|
| 20 |
+
title: 'Find a model that fits',
|
| 21 |
+
asks: 'which models fit my card at all',
|
| 22 |
+
// What the visitor has just learned, and why the next tool follows.
|
| 23 |
+
leadsTo: 'context',
|
| 24 |
+
takes: 'query',
|
| 25 |
+
},
|
| 26 |
+
context: {
|
| 27 |
+
space: 'what-context-fits',
|
| 28 |
+
title: 'What context will actually fit?',
|
| 29 |
+
asks: 'how long a conversation this one can serve',
|
| 30 |
+
leadsTo: 'parser',
|
| 31 |
+
takes: 'repo',
|
| 32 |
+
},
|
| 33 |
+
parser: {
|
| 34 |
+
space: 'reasoning-parser-advisor',
|
| 35 |
+
title: 'Does this model need a reasoning parser?',
|
| 36 |
+
asks: 'how to serve it without silently empty answers',
|
| 37 |
+
leadsTo: 'precision',
|
| 38 |
+
takes: 'repo',
|
| 39 |
+
},
|
| 40 |
+
precision: {
|
| 41 |
+
space: 'pack-precision-map',
|
| 42 |
+
title: 'How much of this pack is actually 4-bit?',
|
| 43 |
+
asks: 'what a quantized pack really compressed, and what it kept',
|
| 44 |
+
leadsTo: 'integrity',
|
| 45 |
+
takes: 'repo',
|
| 46 |
+
},
|
| 47 |
+
integrity: {
|
| 48 |
+
space: 'pack-integrity-check',
|
| 49 |
+
title: 'Does this pack keep what it claims?',
|
| 50 |
+
asks: 'whether anything was dropped or left undeclared',
|
| 51 |
+
leadsTo: null,
|
| 52 |
+
takes: 'repo',
|
| 53 |
+
},
|
| 54 |
+
};
|
| 55 |
+
|
| 56 |
+
export const ORDER = ['search', 'context', 'parser', 'precision', 'integrity'];
|
| 57 |
+
|
| 58 |
+
const BASE = 'https://huggingface.co/spaces/aleada';
|
| 59 |
+
|
| 60 |
+
/**
|
| 61 |
+
* A link to one tool, carrying the model with it.
|
| 62 |
+
*
|
| 63 |
+
* A funnel where each step starts empty is five separate tools with
|
| 64 |
+
* links between them. `?repo=` is read on load by every page that takes
|
| 65 |
+
* one, so clicking through keeps the model you were looking at.
|
| 66 |
+
*/
|
| 67 |
+
export function url(key, repo = null) {
|
| 68 |
+
const t = TOOLS[key];
|
| 69 |
+
if (!t) return BASE;
|
| 70 |
+
const q = repo && t.takes === 'repo'
|
| 71 |
+
? `?repo=${encodeURIComponent(repo)}`
|
| 72 |
+
: repo && t.takes === 'query'
|
| 73 |
+
? `?q=${encodeURIComponent(repo)}` : '';
|
| 74 |
+
return `${BASE}/${t.space}${q}`;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
/** The model this page was opened with, if a link carried one over. */
|
| 78 |
+
export function repoFromUrl() {
|
| 79 |
+
const p = new URLSearchParams(window.location.search);
|
| 80 |
+
return (p.get('repo') || p.get('q') || '').trim() || null;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
const esc = (s) => String(s).replace(/[&<>"]/g, (c) =>
|
| 84 |
+
({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
| 85 |
+
|
| 86 |
+
/**
|
| 87 |
+
* The next questions, rendered under a result.
|
| 88 |
+
*
|
| 89 |
+
* Offered only once there is an answer on screen: a next step shown
|
| 90 |
+
* before the current one is finished is clutter, and a next step that
|
| 91 |
+
* cannot carry the model over is a link to an empty form.
|
| 92 |
+
*/
|
| 93 |
+
export function nextSteps(fromKey, repo = null, keys = null) {
|
| 94 |
+
const rest = keys || ORDER.filter((k) => k !== fromKey);
|
| 95 |
+
if (!rest.length) return '';
|
| 96 |
+
const items = rest.map((k) => {
|
| 97 |
+
const t = TOOLS[k];
|
| 98 |
+
return `<li><a href="${url(k, repo)}" target="_blank" rel="noopener">${esc(t.title)}</a>
|
| 99 |
+
<span class="ns-why">${esc(t.asks)}</span></li>`;
|
| 100 |
+
}).join('');
|
| 101 |
+
return `<nav class="nextsteps" aria-label="Related tools">
|
| 102 |
+
<h4>Next${repo ? ` for <code>${esc(repo)}</code>` : ''}</h4>
|
| 103 |
+
<ul>${items}</ul>
|
| 104 |
+
</nav>`;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
/** Styles for the block above, injected once so each Space need not carry them. */
|
| 108 |
+
export function ensureNextStepStyles() {
|
| 109 |
+
if (document.getElementById('ns-style')) return;
|
| 110 |
+
const el = document.createElement('style');
|
| 111 |
+
el.id = 'ns-style';
|
| 112 |
+
el.textContent = `
|
| 113 |
+
.nextsteps { margin: 1.6rem 0 0; padding-top: 1rem; border-top: 1px solid var(--line); }
|
| 114 |
+
.nextsteps h4 { margin: 0 0 .5rem; font-size: .74rem; font-weight: 600;
|
| 115 |
+
text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
|
| 116 |
+
.nextsteps h4 code { text-transform: none; letter-spacing: 0; }
|
| 117 |
+
.nextsteps ul { list-style: none; margin: 0; padding: 0; }
|
| 118 |
+
.nextsteps li { margin: .3rem 0; font-size: .89rem; }
|
| 119 |
+
.nextsteps a { color: var(--accent); text-decoration: none; }
|
| 120 |
+
.nextsteps a:hover { text-decoration: underline; }
|
| 121 |
+
.ns-why { color: var(--muted); }
|
| 122 |
+
.ns-why::before { content: " — "; }`;
|
| 123 |
+
document.head.appendChild(el);
|
| 124 |
+
}
|