fxtranslate
Translate using the Firefox Translations models. These are high-quality, lightweight, CPU-optimized models that Firefox ships for on-device translation.
Install
$ pip install fxtranslate
Requires Python 3.8 or newer. Prebuilt wheels cover Linux (x86_64 and aarch64), macOS (Apple silicon), and Windows (x86_64). Other platforms, install from the source distribution, which compiles the engine locally. You'll need a Rust toolchain and a C++ compiler installed first.
The CLI
# Discover what models are available.
$ fxtranslate list
$ fxtranslate list es
$ fxtranslate list --all
# Translate a phrase. The model for the pair is discovered, downloaded, and
# cached on first use, then reused from disk on subsequent runs.
$ fxtranslate translate en es "The weather is nice today."
> El clima es agradable hoy.
# You can switch languages.
$ fxtranslate translate en de "Translations are fun"
> Übersetzungen machen Spaß
# Changing the language order changes the translation direction.
$ fxtranslate translate es en "Buenos días, ¿cómo estás?"
> Good morning, how are you?
# When translating between languages where there is not a specific matching language pair,
# it translates through a "pivot language".
# Here Spanish to Russian pivots through a common English model: es → en → ru.
$ fxtranslate translate es ru "Buenos días, ¿cómo estás?"
> Доброе утро, как дела?
# Translate entire documents by piping text into the CLI.
$ cat document.txt | fxtranslate translate en es > document-es.txt
# Enter into an interactive translation mode.
$ fxtranslate translate en es
# Access the full CLI documentation.
$ fxtranslate --help
Model usage
The auto-discovery is powered by Firefox's internal model delivery service. This should not be used for production services. Please download and re-host the models. They can be downloaded through the CLI, or manually from the mozilla/translations models dashboard. The CLI has best-effort support for model downloads, but may break.
Library examples
Load models from your local model store.
from pathlib import Path
from fxtranslate import Translator
# English-Spanish has a shared vocab file.
model_dir = Path("models/en-es")
vocab = (model_dir / "vocab.enes.spm").read_bytes()
en_es = Translator(
model=(model_dir / "model.enes.intgemm.alphas.bin").read_bytes(),
src_vocab=vocab,
trg_vocab=vocab,
)
print(en_es.translate_long("The weather is nice today. Don't you think so?"))
print(en_es.translate("The weather is nice today."))
translate_long segments the text into sentences and translates each one, which is
the right default for input you haven't split yourself. translate treats its
argument as a single sentence and silently truncates anything past the model's
context size.
Some pairs have split vocabs, like English-Japanese. The source and target vocabs differ.
model_dir = Path("models/en-ja")
en_ja = Translator(
model=(model_dir / "model.enja.intgemm.alphas.bin").read_bytes(),
src_vocab=(model_dir / "srcvocab.enja.spm").read_bytes(),
trg_vocab=(model_dir / "trgvocab.enja.spm").read_bytes(),
)
Most supported languages can translate between each other. When no direct model exists for a pair, the translation routes through a pivot language; for 50 languages that means fewer than 100 models rather than the 2,450 a fully direct matrix would need. The CLI and Translator.load pick the route automatically, but it can also be done manually.
es_en = Translator(...)
en_ru = Translator(...)
print(en_ru.translate_long(es_en.translate_long("Buenos días, ¿cómo estás?")))
Fetch all model files once, to re-host them. This can be several gigabytes.
from fxtranslate import Cache, discovery
records = discovery.fetch_records_body()
pairs = discovery.model_pairs(records)
for src, trg in pairs:
discovery.add_models(src, trg, cache_dir="./models", progress=True)
cache = Cache("./models")
print(cache.pair_files("en-es"))
# [ ('lex.50.50.enes.s2t.bin', 4198436, '/path/to/models/en-es/lex.50.50.enes.s2t.bin'),
# ('model.enes.intgemm.alphas.bin', 31561787, '/path/to/models/en-es/model.enes.intgemm.alphas.bin'),
# ('vocab.enes.spm', 816054, '/path/to/models/en-es/vocab.enes.spm')]
Or just specific ones.
for src, trg in [("en", "es"), ("es", "en"), ("en", "de"), ("de", "en")]:
discovery.add_models(src, trg, cache_dir="./models", progress=True)
Without a cache_dir, models land in the platform-native cache directory:
- macOS –
~/Library/Caches/fxtranslate/models - Linux –
$XDG_CACHE_HOME/fxtranslate/modelsor~/.cache/fxtranslate/models - Windows –
%LOCALAPPDATA%\fxtranslate\models
Cache allows for working with cached models.
from fxtranslate import Cache
cache = Cache()
print(cache.root)
# /path/to/cache/fxtranslate/models
for entry in cache.list_cached():
print(entry["name"], entry["bytes"])
# en-de 36719532
# en-es 36576277
# Removes the model.
cache.remove_pair("en-de")
How this works
The underlying inference engine is a portable Rust library based on the Marian expression graph powered by the Gemmology matrix library. The Firefox models have a similar architecture to the traditional encoder/decoder transformer models, but with a shallow RNN decoder based on the SSRU described here. These models come from Mozilla's translation training program. They are student models distilled and quantized for CPU from larger transformer-based teacher models.
fxtranslateon crates.io – The Rust inference engine libraryfxtranslate-clion crates.io – The Rust CLIfxtranslateon npm – The Node.js bindings library and CLIfxtranslateon pypi – The Python bindings library and CLI
License
MPL-2.0 from Firefox Translations
Metadata
Release files for fxtranslate 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fxtranslate-0.5.0.tar.gz | 428.2 kB | With provenance | Details for fxtranslate-0.5.0.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| fxtranslate-0.5.0-cp38-abi3-win_amd64.whl | CPython 3.8 | abi3 | Windows x86-64 | Details for fxtranslate-0.5.0-cp38-abi3-win_amd64.whl |
| fxtranslate-0.5.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.8 | abi3 | Linux glibc 2.17+ x86-64 | Details for fxtranslate-0.5.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
| fxtranslate-0.5.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.8 | abi3 | Linux glibc 2.17+ ARM64 | Details for fxtranslate-0.5.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
| fxtranslate-0.5.0-cp38-abi3-macosx_11_0_arm64.whl | CPython 3.8 | abi3 | macOS 11.0+ ARM64 | Details for fxtranslate-0.5.0-cp38-abi3-macosx_11_0_arm64.whl |
Total release size: 6.8 MB
Release files / fxtranslate-0.5.0.tar.gz
| Download URL | fxtranslate-0.5.0.tar.gz |
|---|---|
| Size | 428.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bd2be786fb0ec06ad234c624f92a8337c6efb300e401e8f0d2e805310ce2b09e
|
|
BLAKE2b-256 checksum How to use checksums |
7e8503ce3cd339ef788f66eaf0f415aee5bac00c3dd8a3689d977d2662f33c51
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.
Transparency logRelease files / fxtranslate-0.5.0-cp38-abi3-win_amd64.whl
| Download URL | fxtranslate-0.5.0-cp38-abi3-win_amd64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.8 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
fa8238a43e189a70a9abae8a5cd3c5b1585e32e1a28184616a6352028fb7a309
|
|
BLAKE2b-256 checksum How to use checksums |
f6cae4bb481f6ccae105574a70bb3f4fc444f58d8e23286e11d6d30c0a8f58ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.
Transparency logRelease files / fxtranslate-0.5.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | fxtranslate-0.5.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.8 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
d57659694bfd96ee1f5ff0b15fb2a48aa2a325c7562f50d1e2b120139d1ac964
|
|
BLAKE2b-256 checksum How to use checksums |
8a0c03f43be3d4f3f20fde8c3cee475e17232073c3eba4d8a71fc671d87f5379
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.
Transparency logRelease files / fxtranslate-0.5.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | fxtranslate-0.5.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.8 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
16e02b37bcfd331cdf80772ecec5cf76b788d3a233ef5e8c0c8b511c4a448a85
|
|
BLAKE2b-256 checksum How to use checksums |
b364fb12fc4fef28cf5ee8c4ac3ee93714e0015df7cc505fd1caef291fe629b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.
Transparency logRelease files / fxtranslate-0.5.0-cp38-abi3-macosx_11_0_arm64.whl
| Download URL | fxtranslate-0.5.0-cp38-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.8 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
d28492b0091c826d6955ebd49229e84de1bbb8d64deceb5958b509a4059644d8
|
|
BLAKE2b-256 checksum How to use checksums |
65c0fea61cb5ed5b868b5975fbca219c0a2759e38e410eeadcf5cb3822d9bcbc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.
Transparency logSecurity for fxtranslate 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 5 files in this release have been uploaded with provenance metadata.
Attestation for fxtranslate-0.5.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.