|
Download ideas/034-model-diff.md from broadfield/things-we-should-build: direct link, hf CLI and curl.
- Browser
- Download file 2.37 kB
-
https://huggingface.co/datasets/broadfield/things-we-should-build/resolve/main/ideas/034-model-diff.md
- Command line
-
hf download hf://datasets/broadfield/things-we-should-build/ideas/034-model-diff.md
-
curl -L -o 034-model-diff.md https://huggingface.co/datasets/broadfield/things-we-should-build/resolve/main/ideas/034-model-diff.md
2.37 kB
034 · Model Diff
title: Model Diff — side-by-side diff of two model repos: config, tokenizer, files, license status: MVP ready license: MIT
why
Choosing between two similar models is currently a manual dance of opening tabs and squinting at config.json. Model Diff turns it into a table: param count, context length, quantization, architectures, license, file tree, last commit — with a real line-level diff on configs. It kills the "which one do I deploy?" 30-minute rabbit hole and is fully static + Hub API.
what
- Inputs: two repo ids (models; optionally datasets/spaces).
- Fetches
config.json,tokenizer_config.json,README.md(first 2k), file tree, and metadata. - Renders: stat table (diff-colored), file tree union, and a side-by-side YAML/JSON diff.
- Deep-linkable:
/diff?left=openai/whisper-tiny&right=openai/whisper-small.
plan
- Static page + simple
diffalgorithm (LCS) in JS. - Normalize configs (sort keys, drop
_name_or_path) before diffing to reduce noise. - Add "why different" hints: param ratio, vocab, context length differences.
- Export diff as markdown for pasting into PRs/notes.
code
async function getJson(repo, file) {
const r = await fetch(`https://huggingface.co/${repo}/raw/main/${file}`);
return r.ok ? r.json() : null;
}
function diffLines(a, b) { // tiny LCS line diff
const A = a.split('\n'), B = b.split('\n');
const dp = Array.from({ length: A.length + 1 }, () => new Array(B.length + 1).fill(0));
for (let i = A.length - 1; i >= 0; i--) for (let j = B.length - 1; j >= 0; j--)
dp[i][j] = A[i] === B[j] ? dp[i + 1][j + 1] + 1 : Math.max(dp[i + 1][j], dp[i][j + 1]);
let out = [], i = 0, j = 0;
while (i < A.length && j < B.length)
A[i] === B[j] ? (out.push(' ' + A[i]), i++, j++)
: dp[i + 1][j] >= dp[i][j + 1] ? (out.push('- ' + A[i++]), 0)
: (out.push('+ ' + B[j++]), 0);
while (i < A.length) out.push('- ' + A[i++]);
while (j < B.length) out.push('+ ' + B[j++]);
return out.join('\n');
}
// call: diffLines(JSON.stringify(l.config, null, 2), JSON.stringify(r.config, null, 2))
next
- GPU-memory estimator based on params × precision (ties into #035).
- Watch mode: subscribe a pair, get pinged when either file changes (#049 cron).
- Tokenizer diff: load both tokenizer files and show vocab overlap.