Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Hugging Face 8 min read How-to mediumAdept

Making ML-powered web games with Transformers.js

Doodle Dash is a Quick, Draw!-style sketch-guessing game that runs entirely in the browser, using a MobileViT-small model (5.6M parameters, ~20 MB) fine-tuned on Google's Quick, Draw! dataset. The model is converted to ONNX with Optimum and run via Transformers.js in a Web Worker so inference doesn't block the UI, producing over 60 predictions per second with no server latency. The game loop is redesigned around that real-time speed: players draw as many prompts as they can in 60 seconds, and scores for early incorrect labels are progressively suppressed. Ambiguous or hard-to-draw classes were pruned, leaving over 300 categories.

Assumes: React basicsHugging Face TransformersWeb Workers

Related posts

  • Create an infinite icon library by fine-tuning Stable Diffusion

    Modal mediumAdept

    Stable Diffusion v1.5 is fully fine-tuned on the ~300-icon Heroicons set to generate new icons in a similar black-and-white line style. Captions are derived from icon names like "golden-retriever" or "barack-obama". The walkthrough covers choosing between full, sequential-adapter and parallel-adapter (LoRA) fine-tuning, then preparing the data: rasterizing SVGs to PNG, adding white backgrounds, and building a metadata.csv of captions. Training uses the Diffusers train_text_to_image script on an A100 via Modal, with 4000 steps, learning rate 1e-5, batch size 1 and 128px resolution. Weights are saved to a Modal Volume and served on a cheaper A10G behind a Gradio UI, and dataset preparation proved the hardest and most important part.

  • Timm ❤️ Transformers: Use any timm model with transformers

    Hugging Face mediumAdept

    TimmWrapper lets any timm vision model load through Hugging Face transformers' Auto classes and pipeline API. That makes architectures with no native transformers implementation, like MobileNetV4, usable with the standard tooling. Code examples cover pipeline inference, a Gradio demo, 8-bit quantization with bitsandbytes (346 MB to 88 MB, about 75% smaller, with near-identical predictions), Trainer-based fine-tuning and LoRA via PEFT (0.77% of parameters trainable), and torch.compile benchmarking. Fine-tuned models round-trip back into timm via the Hub with timm.create_model.

  • Making a web app generator with open ML models

    Hugging Face mediumAdept

    A Node.js/Express server can generate web apps from a text prompt by streaming tokens from a code LLM (WizardCoder-15B on Hugging Face Inference Endpoints) straight into the browser as HTML. Prompt tuning does most of the work: terse imperative instructions, pre-seeding the output with `<html><body class=...>`, and requiring TailwindCSS so styles arrive inline without a stylesheet that stalls rendering. Image URLs come from a Stable Diffusion `/image` endpoint that the model is told to call. Alpine.js provides a minimal UI, and DaisyUI's shorthand classes cut token usage compared with verbose Tailwind utility classes.

  • Transformers.js v3: WebGPU Support, New Models & Tasks, and More…

    Hugging Face mediumAdept

    Transformers.js v3 adds WebGPU acceleration via ONNX Runtime Web, claimed up to 100x faster than WASM and enabled by passing `device: 'webgpu'` when loading a pipeline. A new `dtype` option replaces the old boolean `quantized` flag and supports fp32, fp16, 8-bit and 4-bit variants, including per-module dtypes for quantization-sensitive encoder-decoder models like Whisper and Florence-2. The release also expands support to 120 architectures and over 1200 pre-converted Hub models, and adds Node.js, Deno and Bun compatibility under the new @huggingface/transformers npm package. WebGPU reaches only about 70% of browsers, so some users need feature flags.

  • Transformers.js v4: Now Available on NPM!

    Hugging Face mediumAdept

    Transformers.js v4 ships on NPM with a new C++ WebGPU runtime built with the ONNX Runtime team, enabling WebGPU-accelerated models in browsers as well as Node, Bun and Deno. Models are re-exported operation by operation using ONNX Runtime contrib operators such as GroupQueryAttention, MatMulNBits and MultiHeadAttention, giving about a 4x speedup for BERT embedding models. The release also adds Mamba, MLA and MoE architectures such as GPT-OSS 20B, which runs at about 60 tokens/s on an M4 Pro Max. Other changes include a move from Webpack to esbuild (10x faster builds, 53% smaller default bundle), a pnpm monorepo, a ModelRegistry API for inspecting and caching pipeline assets, and a standalone 8.8kB tokenizers library.

The quest for software engineering knowledge.

Look:
Layout: