Mozilla releases local machine translation tools as part of Project Bergamot
blog.mozilla.org
blog.mozilla.org
Super cool! Real-time translation, in the browser, running locally! And sure, not state of the art / on the level of deepl, but on the level of Google Translate, 2015ish, maybe? Amazing!
"Türkiye quit being called Turkey cold turkey"
Under Google Übersetzer I see three button: Text, Dokumente, Websites
Also if you entered "translate website" Google sugested Yandex on second place ..
the whole project is a EU funded one, all done in the university of Edinburgh
https://cordis.europa.eu/project/id/825303
you giving full credit to Mozilla is dishonest, to say the least
it aligns to their past projects, including using Mullvad and slapping a Mozilla sticker on top of it to claim it as their own
also it is super funny to read this:
> H2020-EU.2.1.1. - INDUSTRIAL LEADERSHIP - Leadership in enabling and industrial technologies - Information and Communication Technologies (ICT) MAIN PROGRAMME
little do they know, EU never learn
> Our solution to that was to develop a high-level API around the machine translation engine, port it to WebAssembly, and optimize the operations for matrix multiplication to run efficiently on CPUs.
EDIT: maybe this is it: https://github.com/mozilla/firefox-translations-models
also some info here: https://github.com/mozilla/firefox-translations-training
The models and training pipeline are in the urls your posted and the evaluation of those models are hosted here [4]
[1] https://github.com/mozilla/firefox-translations [2] https://github.com/browsermt/bergamot-translator [3] https://github.com/browsermt/bergamot-translator/tree/main/w... [4] https://github.com/mozilla/firefox-translations-models/tree/...
Your comment is pedantic and unhelpful. It is effectively the same as overhearing someone asking another person for a Kleenex, then choosing to interject and lecture that person on the difference between Kleenex and tissue paper when the other person does have actual Kleenex-brand tissue. Yes, I know what open source is. Yes, Mozilla uses GitHub. I even provided links to relevant GitHub repositories by Mozilla once I found what I was looking for.
Are you planning on adding a “select some text → right click → Translate in a tooltip” feature? It'd be extremely useful for language learners.
It seems there is an open issue for this: https://github.com/mozilla/firefox-translations/issues/358
[1] https://addons.mozilla.org/en-US/firefox/addon/firefox-trans...
I tried it quick and a few comments:
It looks like both the web page version and browser extension download from storage.googleapis.com, which is not ideal (obviously much better than the text to be translated being sent). IMO, this should be clarified in the extension description. Are there any plans for Mozilla to host this data? (Well, Amazon I guess to match addons.mozilla.org)
https://mozilla.github.io/translate/
I noticed the web page has Polish but not the extension. Is it not considered sufficiently high quality yet? (Looks like that might be the case from a quick test.)
As with others, I first tried to translate a bit of text not the whole page. Another super helpful feature likely already on a todo list is the ability to see alternative translation options.
Thanks again, this is great and I'm surprised it isn't a larger download. I am curious about any size/quality tradeoffs being made.
Also, playing with the web page a bit English->Spanish I see it does a whole text translation such that adding new sentences affects the translation of earlier ones, sometimes in very odd ways (with one combination of words it translated "Spanish->English" to "español-esplén"). It seems to sometimes produce "Spanish" words that don't seem to be actual words in Spanish as best I can tell and even accoding to its own Spanish->English. It seems like a way to indicate a section to be translated as a unit might be helpful.
I'll bring this internally for discussion.
> I noticed the web page has Polish but not the extension. Is it not considered sufficiently high quality yet? (Looks like that might be the case from a quick test.)
The Polish model finished training after we had the extension reviewed and signed for distribution, so that's why we could already integrate it in the website, which is controlled just by my team, and not in the extension yet, but we'll ship it in the next version which might come next week.
This feature you requested is something that I consider interesting and important, would you mind filing an issue in the repo so we could track it [1]?
We did not find any large quality issues after quantizing the models.
In regards to the neologism in Spanish, that is yes a condition that the consortium is aware and working to remediate it.
https://www.musixmatch.com/lyrics/Teskno/Woda-t%C4%99skno-gr...
I'll add a few feature requests to the issue tracker (if not there already) hopefully later today. Including a request to put that web page in the extension :).
This is an awesome project, congratulations!
Could you share details about the machine translation engine that is used (or where to find out more about it)? Are there any plans to open source the extension code (with the WebAssembly optmizations that are mentioned in the article)?
Thanks.
- https://github.com/browsermt/marian-dev
Development of higher-level code wrapping around marian-dev make suitable for the browser-extension happens at:
- https://github.com/browsermt/bergamot-translator
Some of the WebAssembly optimizations are available in bergamot-translator/marian-dev. Rest are in Firefox source-code. A start point could be https://bugzilla.mozilla.org/show_bug.cgi?id=1720747.
Extension code is open-source, and linked already in other comments: - https://github.com/mozilla/firefox-translations
[1] https://marian-nmt.github.io/
[2] https://github.com/browsermt/bergamot-translator
[3] https://github.com/browsermt/bergamot-translator/tree/main/w...
[4] https://github.com/mozilla/gecko-dev/tree/master/third_party...
[1] https://github.com/mozilla/firefox-translations/issues [2] https://github.com/mozilla/firefox-translations-training
Mozilla implemented a REST service based on (an earlier version of) bergamot-translator [1]. You could use that as a replacement for the WASM component in the addon's code.
I also know of some full-page translation demo code that uses the python bindings of bergamot-translator [2]. That's basically a web proxy a la Goole Translate.
Lastly, marian, the translation software that's being used, has a web server as well [3]. It does not support HTML though.
EDIT: see also my earlier comment for using it with Node or Python [4], which you could use to implement a simple web API.
[1] https://github.com/mozilla/translation-service
[2] https://github.com/jerinphilip/tagtransfer
You can have an example on how we did here [1] and test it here (I recommend using Firefox) [2]
That way you don't need a server and everything is processed in the browser, so no need of google translate, or any cloud service to have translations embedded in any website anymore.
[1] https://github.com/mozilla/translate [2] https://mozilla.github.io/translate
[1] https://pypi.org/project/mtdata/
[2] https://github.com/mozilla/firefox-translations-training/blo...
Yes there’s work to be done, resilience, power efficiency, responsiveness, but it’s the right direction for everything that involves private computing.
[1] https://addons.mozilla.org/firefox/addon/firefox-translation...
as an aside, pretty sad to see the project page, https://browser.mt/ , requiring not just javascript but specifically google connections to work. to 5 different google properties, no less.
(Of course technically the work was out there in the open already, since it's Mozilla.)
Agreed about the Bergamot website. I suspect it's not by Mozilla, but I'll see if I can ask someone to take a look, as I don't think all those connections should be necessary.
you know a simple setting "always translate this website" and an option to hide the bar
edit: and for the actual translations https://github.com/mozilla/bergamot-translator
I'm also immediately curious about using it headless outside the browser
I was experimenting with running the wasm version of bergamot-translator (the translation engine used by the addon) in node [2].
However, if you want more performance, using the Python library [3] or the native C++ interface [4] gets you further because the wasm build is limited to a single thread and thus a blocking interface, and can't use all the processor specific optimisations that are in the native builds.
EDIT: Another option is using translateLocally [5], which is a Qt desktop app based on bergamot-translator. It has a native messaging API that is designed as a much faster alternative to the wasm build for browser extensions, but it can also be used from Python [6].
[1] https://github.com/mozilla/firefox-translations-training
[2] https://gist.github.com/jelmervdl/a4c8b6b92ad88a885e1cbd51c6...
[3] https://colab.research.google.com/drive/1AHpgewVJBFaupwAbZq0...
[4] https://github.com/browsermt/bergamot-translator/blob/main/a...
[5] https://github.com/XapaJIaMnu/translateLocally
[6] https://github.com/XapaJIaMnu/translateLocally/blob/master/s...
Sadly, the extension either doesn't work on mobile or Mozilla couldn't be bothered to add it to the whitelist.
You can select text almost anywhere (from browser to even from a screenshot/image; literally anywhere you are able to select text), and in a tooltip above the word, one of the few options is translate. I love the UX of it, as it is super intuitive and unobtrusive, and works pretty much instantaneously It runs fully locally, no connection required. Slides a native OS pane over the page to show possible translations along with pronunciations and other extra info.
Sidenote: other features in that tooltip are pretty nifty too. Aside from the obvious copy/cut/paste/share, i found "look up" to be quite useful when i see a word I've not encountered before. It pulls another native OS pane that shows dictionary definitions and extra info like the wikipedia link. And the actual dictionary definitions are local too afaik.
It doesn't come with a dictionary built in, but the search button becomes an online dictionary in a pinch. Any dictionary app could extend the menu to add a local dictionary, of course.
When my phone is on portrait mode (almost always), I don't see the translate option until I tap on the three dots.
The translation isn't instant. It takes a second to show up, and then takes up the top of the screen.
I'd much prefer a UI similar to the Zhongwen Chrome extension.
I think this could have to do with it not being local...
> This set of requirements posed a number of technological challenges to the team: the translation engine was entirely written in programming languages that compile to native code. We needed a way to streamline the distribution of the project in order to avoid the overhead involved in providing builds compatible with all platforms supported by Firefox — that would be impracticable to scale and maintain.
Does Firefox really support so many different platforms and archs that CI builds are unrealistic?
I'm completely speculating, but it's probably a matter of not wanting to complicate iterating on the translation engine by introducing a bunch of cruft from the Firefox build system (which, though it uses GNU make under the hood, is very much bespoke and complicated).
Since the translation engine is intended to run on a product that hosts WASM, they might as well just build to that.
(Edit: also free sandboxing of a blob of C++ code that needs to handle arbitrary input from the web!)
When the project started for example, the engine has incompatible with ARM, which we could just get for free with WebAssembly. The performance penalty of doing that was minimal for the user eyes, and so far we received less than a handful of complains about it.
Bundling the entire engine on Firefox was never an option for many obvious reasons.
Apparantly Kenneth Heafield https://neural.mt/ of kenlm fame has been coordinating the project, also doing good work like organizing shared tasks on Efficient MT https://statmt.org/wmt21/efficiency-task.html
Sadly, no support for Svenska (Swedish) to English yet.
Meanwhile they have Persian which is not even in the EU.
As for the addon, on Android you'll need to install an unstable version of Firefox and configures a custom addon list in an addons.mozilla.org account that includes it so you can download it.
On iOS there isn't any option to download addons as far as I'm aware. On mobile Linux environments everything should work like on desktop.
The translation code itself should work on mobile. It's just some javascript & wasm (albeit with SIMD instructions not implemented in Safari's WASM vm…)
Sad to hear there's no such feature on iOS. At least Android gets uBlock Origin in the stable channels. Hopefully this will change when Apple will eventually be forced to permit other browsers into the iOS app store.
How many stories have you heard about breaches due to accidentally mis-configured logging in web services? Also in the news lately was Twitter misusing 2fa phone numbers for advertising purposes.
I'm sure cloud processing is better in many ways. But if this is "good enough" I'd rather just do it all locally.