---
title: "Experimenting with local alt text generation in Firefox Nightly"
description: "Firefox 130 adds experimental on-device alt text generation for images in the built-in PDF editor, using a 182M-parameter ViT image encoder paired with DistilGPT-2, fine-tuned on COCO, quantized to under 200MB and running in a few seconds on a laptop CPU."
url: "https://swe.quest/articles/experimenting-with-local-alt-text-generation-in-firefox-nightly-d486bd54cc20de2e"
canonical: "https://hacks.mozilla.org/2024/05/experimenting-with-local-alt-text-generation-in-firefox-nightly/"
source: "Mozilla Hacks"
published: "2024-05-31"
difficulty: "medium"
kind: "Case study"
reading_minutes: 9
tags: ["inference","accessibility","browsers","computer-vision","webassembly"]
---

# Experimenting with local alt text generation in Firefox Nightly

A post on [Mozilla Hacks](https://swe.quest/sources/mozilla-hacks.md), published 2024-05-31, 9 min read, Case study. Original: [https://hacks.mozilla.org/2024/05/experimenting-with-local-alt-text-generation-in-firefox-nightly/](https://hacks.mozilla.org/2024/05/experimenting-with-local-alt-text-generation-in-firefox-nightly/)

## Summary

Firefox 130 adds experimental on-device alt text generation for images in the built-in PDF editor, using a 182M-parameter ViT image encoder paired with DistilGPT-2, fine-tuned on COCO, quantized to under 200MB and running in a few seconds on a laptop CPU. The inference stack reuses the Firefox Translations architecture: the ONNX runtime compiled to WASM runs in a separate process, Transformers.js is vendored with Node pieces and eval() calls removed, and a custom cache serves models from Mozilla's servers into IndexedDB instead of Hugging Face. Small local models trade some accuracy against GPT-4o for privacy, lower resource use and quick retraining. The longer-term goal is to offer generated alt text during general browsing for screen reader users.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [Accessibility](https://swe.quest/tags/accessibility.md) (Web & mobile)
- [Browsers](https://swe.quest/tags/browsers.md) (Web & mobile)
- [Computer vision](https://swe.quest/tags/computer-vision.md) (AI & ML)
- [WebAssembly](https://swe.quest/tags/webassembly.md) (Languages)

## Prerequisites

- Transformer models basics
- WebAssembly basics ([easy posts on WebAssembly](https://swe.quest/tags/webassembly.md?difficulty=easy))

## Keywords

Firefox, PDF.js, ONNX Runtime, Transformers.js, DistilGPT-2, Vision Transformer, COCO, Bergamot

## Related posts

- [Experimenting with the proposed Cross-Origin Storage API in Transformers.js](https://swe.quest/articles/experimenting-with-the-proposed-cross-origin-storage-api-in-transformers-js-f57157be2f20fb70.md): Hugging Face · 2026-06-23 · Medium · 13 min read · Browsers, Caching, Privacy, Inference & serving, JavaScript
  Browser cache partitioning (in Chrome, keying by Network Isolation Key plus URL) forces every origin running Transformers.js to re-download identical model weights and the ONNX Runtime Wasm file.
- [Diffusers welcomes FLUX-2](https://swe.quest/articles/diffusers-welcomes-flux-2-7cb4762bf1303faf.md): Hugging Face · 2025-11-25 · Hard · 21 min read · Inference & serving, Computer vision, Model training, Python
  FLUX.2 from Black Forest Labs is a new image generation and editing model, not a drop-in replacement for Flux.1.
- [Making a web app generator with open ML models](https://swe.quest/articles/making-a-web-app-generator-with-open-ml-models-3da427bd1ac5acd0.md): Hugging Face · 2023-07-03 · Medium · 9 min read · LLMs, AI for coding, JavaScript, Inference & serving
  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.
- [Generate Images Locally with Docker Model Runner and Open WebUI](https://swe.quest/articles/generate-images-locally-with-docker-model-runner-and-open-webui-a7d2d8b5e6b87cba.md): Docker · 2026-05-05 · Medium · 7 min read · Inference & serving, Containers, Developer tools, Computer vision
  Docker Model Runner can now serve diffusion image models locally through an OpenAI-compatible /v1/images/generations endpoint.
- [State of open video generation models in Diffusers](https://swe.quest/articles/state-of-open-video-generation-models-in-diffusers-9770186e8fdb5a0a.md): Hugging Face · 2025-01-27 · Medium · 16 min read · Inference & serving, Computer vision, Video & media, Performance engineering, Model training
  Open video generation models such as HunyuanVideo, CogVideoX, LTX-Video, Mochi-1 and Allegro share a common architecture: T5-style text encoders, a DiT-based denoiser over 3D spatio-temporal tokens, a spatially and temporally compressing VAE, and a scheduler.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
