Skip to content

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

Mozilla Hacks 9 min read Case study mediumAdept

Training efficient neural network models for Firefox Translations

Firefox Translations runs neural machine translation locally on CPU using small models produced by an open-source, reproducible training pipeline from the Bergamot project. The pipeline cleans parallel corpora from OPUS, WMT and Paracrawl with heuristics and bicleaner, augments the data with back-translation, and trains a large transformer teacher. That teacher is then compressed through ensemble knowledge distillation into a small student model with 8-bit quantization. The resulting en-pt student is 47x smaller (17MB vs 798MB) and 37x faster on one CPU core, losing under 2 BLEU points, and some models match cloud translation APIs. The Marian-based pipeline is orchestrated with Snakemake and distributed across GPU nodes with Slurm, and the models ship in the browser via a WebAssembly build of bergamot-translator.

Assumes: neural network training basicstransformer models

Related posts

  • Neural Machine Translation Engine for Firefox Translations add-on

    Mozilla Hacks mediumAdept

    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.

  • NVIDIA Releases 6 Million Multi-Lingual Reasoning Dataset

    Hugging Face mediumAdept

    Nemotron Post-Training Dataset V2 translates NVIDIA's English reasoning post-training data into French, Spanish, German, Italian and Japanese, translating prompts and responses while keeping the original English reasoning chains. LLM translation of long SFT data tends to hallucinate, so the pipeline translates line by line, skips code blocks, and forces outputs inside special brackets so malformed translations can be detected and discarded. Discard rates reach 26% for Spanish code data, and fastText language ID filtering removes another 1.1% of examples. Qwen2.5-32B-Instruct-AWQ (German) and Qwen2.5-14B-Instruct (other languages) did the translation, chosen for quality, single-A100 fit and Apache 2.0 licensing. The release ties in with Nemotron Nano 2 9B, a hybrid Transformer–Mamba model with a configurable thinking budget.

  • Train 400x faster Static Embedding Models with Sentence Transformers

    Hugging Face hardMaster

    Static embedding models, which replace the attention-based encoder with a token embedding lookup plus mean pooling (an EmbeddingBag), can be trained with modern contrastive losses and Matryoshka Representation Learning to run 100x to 400x faster on CPU than models like all-mpnet-base-v2 and multilingual-e5-small, while keeping at least 85% of their benchmark quality. The recipe trains two 1024-dimensional models from randomly initialized weights using BERT tokenizers and Sentence Transformers' StaticEmbedding module: an English retrieval model trained on 13 QA datasets chosen to avoid overlap with BEIR, and a multilingual similarity model trained on parallel-sentence and positive-pair datasets. The post covers dataset selection, loss choice, training arguments, evaluators, NanoBEIR results on CPU and GPU, and Matryoshka truncation tradeoffs. The resulting models suit on-device, in-browser and edge workloads.

  • Productizing Large Language Models

    Replit mediumAdept

    Replit runs transformer models from ~100M parameters (search, spam) through 1-10B (GhostWriter code autocomplete) to 100B+ in production, and shares lessons on making them usable. Nonsense and repetition loops are handled with temperature and frequency penalty tuning, cycle detection, multi-temperature sampling, reranking with a second model, and fine-tuning on user feedback. Quality is tracked with HumanEval, loop and nonsense rates, and A/B tests. Inference cost is cut with FasterTransformer, distillation and quantization, and GPUs are run at 70-80% utilization on Kubernetes so request queues stay bounded while autoscaling has headroom.

  • SmolLM - blazingly fast and remarkably powerful

    Hugging Face hardMaster

    SmolLM is a family of small language models (135M, 360M, 1.7B parameters) trained on SmolLM-Corpus, a new dataset combining Cosmopedia v2 synthetic textbooks (28B tokens), classifier-filtered Python-Edu (4B tokens) and deduplicated FineWeb-Edu (220B tokens). Ablations showed that better prompts mattered more than stronger generator models: BISAC-based topics with search-retrieved seed pages, plus textbooks aimed at middle-school readers, gave the best scores on most benchmarks. Filtering Python with an LLM-annotated educational classifier made training converge more than 3x faster. Using a trapezoidal LR schedule, MobileLLM-style deep-narrow architectures with GQA for the small models, and training well past Chinchilla-optimal token counts, the models beat MobileLLM, Qwen2 and Phi-1.5 in their size classes and are small enough to run on phones and in the browser.

The quest for software engineering knowledge.

Look:
Layout: