Spaces:
Running
Running
MVP1: working prototype of transformer ablation playground. web app for composing tiny transformer architectures, running real inference, and seeing how each architectural switch affects cost and quality. Hash-stable arch_config shared between Python and TS; closed-form cost formulas parity-tested against actual sum(p.numel())
84702bc Download frontend/src/lib/format.ts from philippyt/ablation-lab: direct link, hf CLI and curl.
- Browser
- Download file 802 Bytes
-
https://huggingface.co/spaces/philippyt/ablation-lab/resolve/main/frontend/src/lib/format.ts
- Command line
-
hf download hf://spaces/philippyt/ablation-lab/frontend/src/lib/format.ts
-
curl -L -o format.ts https://huggingface.co/spaces/philippyt/ablation-lab/resolve/main/frontend/src/lib/format.ts
802 Bytes
| export function fmtBytes(n: number): string { | |
| if (n < 1024) return `${n} B`; | |
| if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`; | |
| if (n < 1024 * 1024 * 1024) return `${(n / (1024 * 1024)).toFixed(2)} MB`; | |
| return `${(n / (1024 * 1024 * 1024)).toFixed(2)} GB`; | |
| } | |
| export function fmtParams(n: number): string { | |
| if (n < 1000) return `${n}`; | |
| if (n < 1_000_000) return `${(n / 1000).toFixed(1)}K`; | |
| if (n < 1_000_000_000) return `${(n / 1_000_000).toFixed(2)}M`; | |
| return `${(n / 1_000_000_000).toFixed(2)}B`; | |
| } | |
| export function fmtPercent(x: number): string { | |
| const sign = x > 0 ? "+" : ""; | |
| return `${sign}${(x * 100).toFixed(0)}%`; | |
| } | |
| export function relativeChange(oldV: number, newV: number): number { | |
| if (oldV === 0) return newV === 0 ? 0 : 1; | |
| return (newV - oldV) / oldV; | |
| } | |