---
title: "Neural Machine Translation Engine for Firefox Translations add-on"
description: "Firefox Translations runs neural machine translation entirely on the client by compiling the Bergamot Translator engine, a C++ layer on the Marian framework, to WebAssembly."
url: "https://swe.quest/articles/neural-machine-translation-engine-for-firefox-translations-add-on-e81e0925c599fd24"
canonical: "https://hacks.mozilla.org/2022/06/neural-machine-translation-engine-for-firefox-translations-add-on/"
source: "Mozilla Hacks"
published: "2022-06-29"
difficulty: "medium"
kind: "Case study"
reading_minutes: 9
tags: ["webassembly","inference","performance","browsers","c-cpp"]
---

# Neural Machine Translation Engine for Firefox Translations add-on

A post on [Mozilla Hacks](https://swe.quest/sources/mozilla-hacks.md), published 2022-06-29, 9 min read, Case study. Original: [https://hacks.mozilla.org/2022/06/neural-machine-translation-engine-for-firefox-translations-add-on/](https://hacks.mozilla.org/2022/06/neural-machine-translation-engine-for-firefox-translations-add-on/)

## Summary

Firefox Translations runs neural machine translation entirely on the client by compiling the Bergamot Translator engine, a C++ layer on the Marian framework, to WebAssembly. Wasm won over native Firefox integration and native messaging because it was safer, cross-platform and could be shipped as a single binary. The first prototype was unusable: about 8 seconds to start, 95 words per second and a ~250 MB binary. Loading models as byte buffers instead of bundling them, swapping hot try/catch paths for if/else, and adding experimental, non-standard and native GEMM intrinsics in Firefox brought this to ~1 second startup, ~870 wps for English to German and a ~4.94 MB binary. ARM performance and multithreading still depend on standardized Wasm GEMM and SharedArrayBuffer.

Written by swe.quest, not by the author.

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

## Topics

- [WebAssembly](https://swe.quest/tags/webassembly.md) (Languages)
- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Browsers](https://swe.quest/tags/browsers.md) (Web & mobile)
- [C & C++](https://swe.quest/tags/c-cpp.md) (Languages)

## Prerequisites

- WebAssembly basics ([easy posts on WebAssembly](https://swe.quest/tags/webassembly.md?difficulty=easy))
- C++ compilation ([easy posts on C & C++](https://swe.quest/tags/c-cpp.md?difficulty=easy))
- matrix multiplication in neural networks ([easy posts on Machine learning](https://swe.quest/tags/machine-learning.md?difficulty=easy))

## Keywords

Firefox Translations, Bergamot Translator, Marian, Emscripten, GEMM, SharedArrayBuffer

## Related posts

- [Training efficient neural network models for Firefox Translations](https://swe.quest/articles/training-efficient-neural-network-models-for-firefox-translations-fe8eb9b49ba04dbc.md): Mozilla Hacks · 2022-06-07 · Medium · 9 min read · Model training, Machine learning, Inference & serving, ML platforms, Privacy
  Firefox Translations runs neural machine translation locally on CPU using small models produced by an open-source, reproducible training pipeline from the Bergamot project.
- [Why is WebAssembly a second-class language on the web?](https://swe.quest/articles/why-is-webassembly-a-second-class-language-on-the-web-36ba94a05082ce89.md): Mozilla Hacks · 2026-02-26 · Medium · 13 min read · WebAssembly, Browsers, Language design, Performance engineering
  WebAssembly remains second-class on the web because it can only load code and reach Web APIs through JavaScript.
- [Extensible Language Support in Zed - Part 1](https://swe.quest/articles/extensible-language-support-in-zed-part-1-13bc037c6f5096a9.md): Zed · 2024-04-18 · Medium · 7 min read · WebAssembly, Developer tools, Sandboxing & isolation, Compilers, Rust
  Zed loads third-party Tree-sitter grammars as WebAssembly modules using a hybrid design.
- [How We Built the Turso Shell in the Browser](https://swe.quest/articles/how-we-built-the-turso-shell-in-the-browser-3b4c7642ce66be0b.md): Turso · 2025-10-14 · Medium · 9 min read · WebAssembly, SQLite, React, Frontend, Browsers
  Turso's SQLite-compatible database can run entirely in the browser via WebAssembly, persisting data to OPFS with no backend.
- [WebAssembly and Back Again: Fine-Grained Sandboxing in Firefox 95](https://swe.quest/articles/webassembly-and-back-again-fine-grained-sandboxing-in-firefox-95-d23a4c9673130b46.md): Mozilla Hacks · 2021-12-06 · Medium · 4 min read · Sandboxing & isolation, WebAssembly, Browsers, Memory safety, Supply chain security
  Firefox 95 ships RLBox, a fine-grained sandboxing technique that compiles third-party C/C++ libraries (Graphite, Hunspell, Ogg, with Expat and Woff2 following in 96) to WebAssembly and then back to native code, so untrusted code runs in-process but cannot jump to unexpected code or touch memory outside its region.

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)
