Spaces:
Running
Running
Download index.html from Techno03/sudoku-diffusion: direct link, hf CLI and curl.
- Browser
- Download file 8.72 kB
-
https://huggingface.co/spaces/Techno03/sudoku-diffusion/resolve/main/index.html
- Command line
-
hf download hf://spaces/Techno03/sudoku-diffusion/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Techno03/sudoku-diffusion/resolve/main/index.html
8.72 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <title>Sudoku Diffusion</title> | |
| <style> | |
| body{font-family:system-ui,-apple-system,sans-serif;max-width:1150px;margin:0 auto;padding:20px;color:#111;background:#fafafa} | |
| h1{margin:0 0 6px} | |
| p{line-height:1.5} | |
| a{color:#4f46e5} | |
| .controls{display:flex;gap:18px;align-items:center;flex-wrap:wrap;margin:14px 0} | |
| .controls label{font-weight:600;margin-right:6px} | |
| select,button{font-size:14px;padding:5px 8px;border-radius:6px;border:1px solid #ccc;background:#fff;cursor:pointer} | |
| button.on{background:#4f46e5;color:#fff;border-color:#4f46e5} | |
| .cards{display:flex;flex-wrap:wrap;gap:14px;justify-content:center} | |
| .card{background:#fff;border:1px solid #e5e7eb;border-radius:10px;padding:10px 12px;text-align:center} | |
| .card h3{margin:2px 0 8px;font-size:14px} | |
| .card .sub{font-size:12px;margin-top:6px;color:#333} | |
| .card .big{font-size:20px;font-weight:700} | |
| table.g{border-collapse:collapse;margin:0 auto;font-family:ui-monospace,monospace} | |
| table.g td{width:26px;height:26px;text-align:center;font-size:15px;border:1px solid #cbd5e1;padding:0} | |
| table.g tr:nth-child(3n) td{border-bottom:3px solid #111} | |
| table.g tr:first-child td{border-top:3px solid #111} | |
| table.g td:nth-child(3n){border-right:3px solid #111} | |
| table.g td:first-child{border-left:3px solid #111} | |
| .gv{background:#d1d5db;font-weight:700} | |
| .ok{background:#bbf7d0;color:#14532d} | |
| .bad{background:#fecaca;color:#7f1d1d} | |
| .na{background:#f1f5f9;color:#94a3b8} | |
| .legend span{padding:2px 8px;margin-right:6px;border-radius:4px;font-size:12px} | |
| table.res{border-collapse:collapse;margin:10px 0;background:#fff} | |
| table.res th,table.res td{border:1px solid #e5e7eb;padding:6px 12px;text-align:center} | |
| table.res th{background:#f1f5f9} | |
| .note{font-size:13px;color:#555} | |
| .agg{font-size:13px;color:#333;margin:6px 0 14px} | |
| </style> | |
| </head> | |
| <body> | |
| <h1>Sudoku Diffusion</h1> | |
| <p>A masked-diffusion language model (<b>iLLaDA-8B</b>) fine-tuned with LoRA to solve 9×9 Sudoku, compared against | |
| autoregressive LLMs. Diffusion fills the whole grid in parallel and unmasks the cells it is most confident about first, | |
| so it can use constraints from anywhere on the board instead of committing left to right.<br> | |
| Adapter: <a href="https://huggingface.co/Techno03/illada-8b-sudoku-lora">Techno03/illada-8b-sudoku-lora</a> · | |
| Code: <a href="https://github.com/arush-garg/SudokuDiffusion">github.com/arush-garg/SudokuDiffusion</a></p> | |
| <h2>Benchmark</h2> | |
| <table class="res"> | |
| <tr><th>Difficulty</th><th>iLLaDA zero-shot</th><th>Gemma-4 zero-shot</th><th>iLLaDA fine-tuned</th><th>Gemma-4 fine-tuned</th><th>Llama 3.3 70B</th></tr> | |
| <tr><td>easy (n=13)</td><td>~35.8%</td><td>72.5%</td><td>92.7%</td><td><b>95.7%</b></td><td>35.2%</td></tr> | |
| <tr><td>medium (n=70)</td><td>~8.2%</td><td>21.5%</td><td><b>69.6%</b></td><td>38.9%</td><td>14.4%</td></tr> | |
| <tr><td>hard (n=17)</td><td>~0.0%</td><td>3.6%</td><td><b>27.4%</b></td><td>8.9%</td><td>7.5%</td></tr> | |
| </table> | |
| <div class="note">Metric: % of originally-blank cells predicted correctly, on the same 100 held-out validation puzzles. | |
| iLLaDA zero-shot numbers are estimates from a small sample.</div> | |
| <h2>Compare the models puzzle by puzzle</h2> | |
| <p class="note">These are the real outputs recorded during evaluation for the 100 held-out puzzles, scored cell by cell. | |
| Live inference isn't hosted here because the 8B model needs a GPU.</p> | |
| <div class="controls"> | |
| <div><label>Difficulty</label><span id="levels"></span></div> | |
| <div><label for="pick">Puzzle</label><select id="pick"></select></div> | |
| <div><button id="prev">◀ prev</button> <button id="next">next ▶</button> <button id="rand">random</button></div> | |
| </div> | |
| <div class="agg" id="agg"></div> | |
| <div class="legend"><span class="gv">given</span><span class="ok">correct</span><span class="bad">wrong</span><span class="na">no parseable answer</span></div> | |
| <div class="cards" id="cards"></div> | |
| <script> | |
| const MODELS = [ | |
| ["illada_ft", "iLLaDA-8B + LoRA", "diffusion, fine-tuned"], | |
| ["gemma_zs", "Gemma-4-12B", "autoregressive, zero-shot"], | |
| ["llama70b", "Llama 3.3 70B", "autoregressive, zero-shot"], | |
| ]; | |
| const bucket = d => d < 0.3 ? "easy" : (d < 0.7 ? "medium" : "hard"); | |
| // Mirrors utils.parse_sudoku_string: take text after "Solution:", need exactly 81 standalone 1-9 digits. | |
| function parseGrid(text) { | |
| if (!text) return null; | |
| if (text.includes("Solution:")) text = text.split("Solution:").slice(1).join("Solution:"); | |
| const d = text.match(/\b[1-9]\b/g); | |
| return d && d.length === 81 ? d.map(Number) : null; | |
| } | |
| function promptGrid(p) { | |
| return p.replace("Input:", "").split("|").slice(0, 9) | |
| .flatMap(row => row.split(":")[1].trim().split(/\s+/).slice(0, 9).map(x => x === "." ? 0 : +x)); | |
| } | |
| function table(cells, cls) { | |
| let h = '<table class="g">'; | |
| for (let r = 0; r < 9; r++) { | |
| h += "<tr>"; | |
| for (let c = 0; c < 9; c++) h += `<td class="${cls[r*9+c]}">${cells[r*9+c]}</td>`; | |
| h += "</tr>"; | |
| } | |
| return h + "</table>"; | |
| } | |
| function score(s, key) { | |
| const given = promptGrid(s.prompt_text), truth = parseGrid(s.solution_text), pred = parseGrid(s.preds[key]); | |
| const blanks = given.map((v, i) => v === 0 ? i : -1).filter(i => i >= 0); | |
| if (!pred) return {pred: null, given, truth, correct: 0, total: blanks.length}; | |
| return {pred, given, truth, correct: blanks.filter(i => pred[i] === truth[i]).length, total: blanks.length}; | |
| } | |
| let SAMPLES = [], level = "all", ids = []; | |
| function render() { | |
| const id = document.getElementById("pick").value; | |
| const s = SAMPLES.find(x => x.id === id); | |
| const given = promptGrid(s.prompt_text); | |
| let html = `<div class="card"><h3>Puzzle<br><span style="font-weight:400;font-size:12px">input</span></h3>${table(given.map(v => v || ""), given.map(v => v ? "gv" : ""))} | |
| <div class="sub">${given.filter(v => !v).length} blanks · difficulty ${s.difficulty} (${bucket(s.difficulty)})</div></div>`; | |
| for (const [key, name, kind] of MODELS) { | |
| const r = score(s, key); | |
| let body, sub; | |
| if (!r.pred) { | |
| body = table(Array(81).fill(""), Array(81).fill("na")); | |
| sub = `<span class="big">0%</span><br>output didn't parse to 81 digits`; | |
| } else { | |
| const cls = r.pred.map((v, i) => v === r.truth[i] ? (r.given[i] ? "gv" : "ok") : "bad"); | |
| const solved = r.pred.every((v, i) => v === r.truth[i]); | |
| sub = `<span class="big">${(100 * r.correct / r.total).toFixed(1)}%</span><br>${r.correct}/${r.total} blank cells correct${solved ? " · solved ✓" : ""}`; | |
| body = table(r.pred, cls); | |
| } | |
| html += `<div class="card"><h3>${name}<br><span style="font-weight:400;font-size:12px">${kind}</span></h3>${body}<div class="sub">${sub}</div></div>`; | |
| } | |
| document.getElementById("cards").innerHTML = html; | |
| } | |
| function aggregate() { | |
| const rows = SAMPLES.filter(s => level === "all" || bucket(s.difficulty) === level); | |
| const parts = MODELS.map(([key, name]) => { | |
| let c = 0, t = 0, solved = 0; | |
| for (const s of rows) { | |
| const r = score(s, key); c += r.correct; t += r.total; | |
| if (r.pred && r.pred.every((v, i) => v === r.truth[i])) solved++; | |
| } | |
| return `<b>${name}</b>: ${(100 * c / t).toFixed(1)}% blanks correct, ${solved}/${rows.length} fully solved`; | |
| }); | |
| document.getElementById("agg").innerHTML = `Across these ${rows.length} puzzles: ` + parts.join(" · "); | |
| } | |
| function setLevel(l) { | |
| level = l; | |
| document.querySelectorAll("#levels button").forEach(b => b.classList.toggle("on", b.dataset.l === l)); | |
| ids = SAMPLES.filter(s => l === "all" || bucket(s.difficulty) === l).map(s => s.id); | |
| const pick = document.getElementById("pick"); | |
| pick.innerHTML = ids.map(id => { | |
| const s = SAMPLES.find(x => x.id === id); | |
| return `<option value="${id}">${id} (${bucket(s.difficulty)}, ${s.difficulty})</option>`; | |
| }).join(""); | |
| aggregate(); | |
| render(); | |
| } | |
| function step(d) { | |
| const pick = document.getElementById("pick"); | |
| pick.selectedIndex = (pick.selectedIndex + d + ids.length) % ids.length; | |
| render(); | |
| } | |
| fetch("data/eval_samples.json").then(r => r.json()).then(data => { | |
| SAMPLES = data; | |
| document.getElementById("levels").innerHTML = ["all", "easy", "medium", "hard"] | |
| .map(l => `<button data-l="${l}">${l}</button>`).join(" "); | |
| document.querySelectorAll("#levels button").forEach(b => b.onclick = () => setLevel(b.dataset.l)); | |
| document.getElementById("pick").onchange = render; | |
| document.getElementById("prev").onclick = () => step(-1); | |
| document.getElementById("next").onclick = () => step(1); | |
| document.getElementById("rand").onclick = () => step(1 + Math.floor(Math.random() * (ids.length - 1))); | |
| setLevel("all"); | |
| }); | |
| </script> | |
| </body> | |
| </html> | |