Skip to main content

Firefox Translations neural machine-translation engine — native (compiled Rust), batteries-included model management.

Project description

fxtranslate

Translate with Firefox Translations models from Python — a library powered by the same lightweight, CPU-only models Firefox ships for on-device translation. The engine is native compiled Rust (fast, CPU-only, no GPU), and it discovers, downloads, and caches the models for you; no API keys, no network round-trips to a translation service, nothing leaves your machine after the model download.

Unlike the npm/wasm build, the Python wheel ships the fast, batteries-included engine: the gemmology SIMD int8 GEMM kernel, mmap, ICU4X sentence segmentation, and built-in networked model discovery/download/caching. Prefer a native binary, a Rust dependency, or Node? See Related packages.

Install

$ pip install fxtranslate

The first release ships an sdist plus one platform wheel (built on the release machine). On other platforms pip compiles from source — that needs a Rust and C++ toolchain, and it falls back to the portable scalar kernel automatically if no SIMD backend is wired for your target — until the full binary-wheel matrix lands.

Library, batteries-included

Lead with this — the native advantage over the wasm build. One call discovers the model for the pair, downloads and hash-verifies it into a local cache, builds the engine, and is ready to translate:

from fxtranslate import Translator

t = Translator.load("en", "es")          # discover → download → cache → ready
print(t.translate("The weather is nice today."))
# El clima es agradable hoy.

# translate_long segments multi-sentence / long input and translates each part
# within the model's context window, instead of truncating.
print(t.translate_long(long_article))

Library, bring-your-own model

If you already have the model files on disk (recommended for production — see The models), pass the bytes directly. You supply the marian .bin model and the source/target SentencePiece vocabularies (the same file for most pairs; only CJK pairs differ) — pass the source vocab twice for a shared-vocab pair:

from fxtranslate import Translator

model = open("en-es/model.bin", "rb").read()
vocab = open("en-es/vocab.spm", "rb").read()
t = Translator(model, vocab, vocab)       # src vocab twice for shared-vocab pairs
print(t.translate("The weather is nice today."))

Discovery helpers

fxtranslate.discovery re-exports the pure model-discovery/routing surface the batteries-included path is built on — over a Remote Settings records body, returning native Python objects (no JSON strings) — for building your own model-management flow:

from fxtranslate import discovery

route = discovery.resolve_route(records_json, "en", "es")  # {"kind": "direct", ...}
cat = discovery.catalog(records_json, "en")           # {"bidirectional": [...], ...}
pairs = discovery.model_pairs(records_json)           # list[(src, trg)]
recs = discovery.parse_records(records_json)          # list[dict]
sents = discovery.segment_sentences(text)             # list[str] (ICU4X UAX #29)
plain = discovery.verify_and_decompress(zst_bytes, sha256_hex)  # bytes

The models

fxtranslate uses the models Firefox ships. They're discovered through Mozilla's Remote Settings and downloaded from Firefox's CDN, then cached under the platform-native cache directory — ~/Library/Caches/fxtranslate/models on macOS, $XDG_CACHE_HOME/fxtranslate/models on Linux, %LOCALAPPDATA%\fxtranslate\models on Windows — one subdirectory per language pair.

That hosting is provisioned for Firefox, not for third-party traffic, and neither the endpoints nor the availability of any particular model are a stable contract for downstream projects. Translator.load is a convenient way to try the engine; if you're shipping a product on top of it, mirror the model files you depend on, serve them from infrastructure you control, and load them with the bring-your-own-model Translator(...) constructor.

Related packages

The same engine is published across ecosystems on one shared version, so you can pick the artifact that fits:

  • fxtranslate (crates.io) — the Rust engine library. Native SIMD int8 kernel, optional built-in model management.
  • fxtranslate-cli (crates.io) — the native Rust CLI, installed with cargo install fxtranslate-cli.
  • fxtranslate (npm) — the Node CLI + library (WebAssembly core).

License

MPL-2.0. The engine is a Rust port of the Firefox Translations inference engine.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fxtranslate-0.4.2.tar.gz (397.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

fxtranslate-0.4.2-cp38-abi3-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.8+Windows x86-64

fxtranslate-0.4.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

fxtranslate-0.4.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.7 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

fxtranslate-0.4.2-cp38-abi3-macosx_11_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

File details

Details for the file fxtranslate-0.4.2.tar.gz.

File metadata

  • Download URL: fxtranslate-0.4.2.tar.gz
  • Upload date:
  • Size: 397.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for fxtranslate-0.4.2.tar.gz
Algorithm Hash digest
SHA256 2c276d4ff31a2bbb673be37f2d07ce4b477adc13b760d6b91ef0e9984c22aff2
MD5 2cac3350605978bc7a80d8a1be96c8c6
BLAKE2b-256 76047886f4013ed3ca2739d88c84d2f8ebf32f0d61fe3f683980d3c224b85c97

See more details on using hashes here.

Provenance

The following attestation bundles were made for fxtranslate-0.4.2.tar.gz:

Publisher: pypi-wheels.yml on gregtatum/translations

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fxtranslate-0.4.2-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: fxtranslate-0.4.2-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for fxtranslate-0.4.2-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 c882849e744ec869639f36ddec24064e07991b240846609f43e7f5e480ee8507
MD5 797749b6161a8cd7ac769b8c17dd5c9e
BLAKE2b-256 7fc2908d75b0a1bcd6f8ac2b510297b9a8708ee33db894135e13072d9400dab0

See more details on using hashes here.

Provenance

The following attestation bundles were made for fxtranslate-0.4.2-cp38-abi3-win_amd64.whl:

Publisher: pypi-wheels.yml on gregtatum/translations

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fxtranslate-0.4.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fxtranslate-0.4.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b7db1aeb474a7c568ca6531a130ca4ddd528f9421c2da88eca2d19a33bb51c16
MD5 e13761241d92c20c6216326c7ab1bc8b
BLAKE2b-256 c20791c7d0324f8f427bb0d694422bde99d93270df1994954e9f8733e877b1ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for fxtranslate-0.4.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: pypi-wheels.yml on gregtatum/translations

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fxtranslate-0.4.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for fxtranslate-0.4.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 511aafe82ddad8814a11819a018062f35cd3a9dc166d2aa436a6c8c915f64a0b
MD5 ff41b889e68b0b8972ba06f7e5e0ebad
BLAKE2b-256 05c27e2b0668cc107f6d3b2437732de2105c47b45f6eea0fcbd2e81443b13624

See more details on using hashes here.

Provenance

The following attestation bundles were made for fxtranslate-0.4.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: pypi-wheels.yml on gregtatum/translations

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fxtranslate-0.4.2-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fxtranslate-0.4.2-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 251ac787436ab9ccf8063e0e8da504e7d68663d2dd03d3bdc1eaeb73f66f191a
MD5 7cd6a97282bbbc0abaa1e478a23b3bc8
BLAKE2b-256 b1955b8faea7d15d6a2c9e671955ed726a354f7d2eacc68e30e4b4660d30704b

See more details on using hashes here.

Provenance

The following attestation bundles were made for fxtranslate-0.4.2-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: pypi-wheels.yml on gregtatum/translations

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page