Most active commenters
  • ameliaquining(3)

←back to thread

Web Translator API

(developer.mozilla.org)
97 points kozika | 13 comments | | HN request time: 1.825s | source | bottom
Show context
sfmz ◴[] No.44376080[source]
https://developer.chrome.com/docs/ai/translator-api

const translator = await Translator.create({ sourceLanguage: 'en', targetLanguage: 'fr', });

await translator.translate('Where is the next bus stop, please?');

replies(1): >>44378311 #
1. ks2048 ◴[] No.44378311[source]
So, this is Google Translate built running locally in Chrome? I wonder if it is a small/degraded model or limited languages? Otherwise, how is it not a simple way around the paid Google API?
replies(5): >>44378361 #>>44378552 #>>44379184 #>>44381572 #>>44381935 #
2. sfmz ◴[] No.44378552[source]
There's already ways to do translation locally in javascript with neural-nets running in WASM, this is just more convenient.

https://huggingface.co/Xenova/nllb-200-distilled-600M

replies(1): >>44384757 #
3. ameliaquining ◴[] No.44379184[source]
The article explains that this feature uses a small (up to 22 GB) language model that runs on-device.

That said, the "simple way around the paid API" problem is something Google has to deal with anyway, because there are a bunch of ways to use Google Translate without paying for it (e.g., the translate.google.com web UI, or the non-JavaScript-exposed "Translate to [language]" feature built into Chrome), and any action that can be taken by a human can in principle also be taken by a script. The only thing to do about it is use secret-sauce server-side abuse detection to block as much of this activity as they can; they can't get all of it but they can get enough to push enough people onto the paid API that the economics pencil out.

replies(1): >>44379749 #
4. jannes ◴[] No.44379749[source]
So installing Chrome is going to require 22 GB of disk space now?
replies(2): >>44379776 #>>44388237 #
5. ks2048 ◴[] No.44379776{3}[source]
It only installs models that explicitly downloaded via this API, it seems.

Also, it says to have 22 GB free, but below (under "Note"...), it says the model takes "around a couple of GB".

replies(1): >>44379798 #
6. cj ◴[] No.44379798{4}[source]
Does the API trigger the download automatically, or does it ask for user permission?

(Answered my own question): Doesn't look like it requires the user's permission. Upon first use, the model will start downloading. The user has to wait for the download to finish before the API will work. That could take hours for 22gb.

I presume this can't work on mobile?

https://developer.mozilla.org/en-US/docs/Web/API/Translator_...

replies(1): >>44379956 #
7. ameliaquining ◴[] No.44379956{5}[source]
The article indicates that it will only download the model over an unmetered connection, e.g., while the phone is connected to wifi.
replies(1): >>44385408 #
8. akazantsev ◴[] No.44381572[source]
Here is the information on how it works in Chrome. https://developer.chrome.com/docs/ai/translator-api
9. dbbk ◴[] No.44381935[source]
Could it get more degraded?
10. vitonsky ◴[] No.44384757[source]
I tried to use this model in my package with translators kit https://github.com/translate-tools/core/pull/112

It runs very slow. Test case that run translation for text in 3k chars multiple times, takes about 30 seconds for google translator, but more than 10 minutes for `nllb-200-distilled-600M`.

Text sample: https://github.com/translate-tools/core/pull/112/files#diff-...

My tests runs on nodejs, it looks in browser it have no chance for real world use

11. djhn ◴[] No.44385408{6}[source]
Seems very backwards for markets where wired/wifi connections at home are nonexistant, 4g/5g is already unmetered and phones are the wifi you connect your devices to.
replies(1): >>44392160 #
12. dhx ◴[] No.44388237{3}[source]
This sounds off by an order of magnitude? Firefox's local translation models are only 20-70MB per language pair direction (e.g. en-to-fr or fr-to-en).[1] These models are also only released when they reach at least -5% of Google Translate's COMET score.[1] Currently Firefox ships with support for 32 xx-to-en language pairs and 29 en-to-xx language pairs.[1] As the number of language pairs increases, it probably isn't unreasonable for browsers to stop bundling every language pair and instead prompt users to download uncommon models the first time the user wants to use them.

[1] https://mozilla.github.io/translations/firefox-models/

13. ameliaquining ◴[] No.44392160{7}[source]
If you have an unlimited data plan then Android counts that as an unmetered connection and Chrome will download the model over it.