Readit News logoReadit News
sfmz · 9 months ago
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?');

ks2048 · 9 months ago
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?
ameliaquining · 9 months ago
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.

sfmz · 9 months ago
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

akazantsev · 9 months ago
Here is the information on how it works in Chrome. https://developer.chrome.com/docs/ai/translator-api
dbbk · 9 months ago
Could it get more degraded?

Dead Comment

troupo · 9 months ago
While this might be useful, be mindful:

- it's experimental

- the "specification" is nowhere near a standards track: https://webmachinelearning.github.io/translation-api/

Of course it's already shipped in Chrome, and now Chrome pretends that its own Chrome-only API is somehow standard. Expect people on HN to blame other browsers for not shipping this.

jazzypants · 9 months ago
I've been pleasantly surprised by the last few conversations about this type of thing that I've seen. It seems like people are pretty sick of Chrome's IE proclivities.
moron4hire · 9 months ago
This is the W3C standardization process.

The W3C is not a prescriptive standardization body. It doesn't have any regulatory power giving it any teeth to go after vendors acting in bad faith. So the W3C process is descriptive and encourages a period of competitive divergence in implementations. It is only after the early adopters have hammered on the features and figured out which parts they like best that a Web API can then start to get standardized.

troupo · 9 months ago
> This is the W3C standardization process.

Let me quote the site for you

--- start quote ---

This specification was published by the Web Machine Learning Community Group. It is not a W3C Standard nor is it on the W3C Standards Track.

--- end quote ---

> So the W3C process is descriptive and encourages a period of competitive divergence in implementations.

That is exactly opposite of how the w3c standardization process works

> It is only after the early adopters have hammered on the features and figured out which parts they like best that a Web API can then start to get standardized.

Yes, and until then this work is not supposed to be enabled by default

sandstrom · 9 months ago
This would be very useful.

Basically, the 'translate this' button you see on Twitter or Instagram next to comments in foreign languages. This API would make it trivial for all developers to add that to their web apps.

greatgib · 9 months ago
Except that it is the user that will pay with his own llm tokens
8n4vidtmkvmk · 9 months ago
The user pays with some disk space, not API tokens
cAtte_ · 9 months ago
how do you know this?
vitonsky · 9 months ago
As maintainer of https://linguister.io/, should I start work on polyfill for that API?

If this API will be implemented in next few years, there will be browsers who hold up the world in progress.

Linguist have enough many users, so we could expose this API for client side code, and users with browsers where Translation API is not implemented yet, could install Linguist and sites who uses Translation API would works fine. Translation API calls would proxy by Linguist and preferred translator module would be used.

Any thoughts about it?

RockRobotRock · 9 months ago
sandstrom · 9 months ago
I honestly don't understand the arguments Mozilla have against it.

Safari/webkit is positive (though no official stance yet):

https://github.com/WebKit/standards-positions/issues/339#iss...

yjftsjthsd-h · 9 months ago
I don't know enough to understand the DOM argument, but

> The spec assumes a certain form of translation backend, exposing information about model availability, download progress, quotas, and usage prediction. We'd like to minimize the information exposure so that the implementation can be more flexible.

reads to me as Chrome once again trying to export itself verbatim as a "standard" and Mozilla pointing out that that's not really applicable to others.

Also the WebKit post seems to raise somewhat similar arguments but on the basis of fingerprinting/privacy problems.

pwdisswordfishz · 9 months ago
Why does it need to be a JavaScript API?

Why not just use the lang= attribute as it was intended, then let the user select text to translate as they wish?

diggan · 9 months ago
If it's a HTML attribute, then you can only use it with DOM elements, with no control about when it runs.

Instead, a JS API gives more flexibility and control.

Besides, I think the "lang" attribute is supposed to signal what the language of the text inside that element is, not what it could/should be. So even if going with attributes would be the way forward, a new one would need to be created.

tempodox · 9 months ago
It's only implemented in Google Chrome, so go figure.
Uehreka · 9 months ago
If Chrome tried to pull this in like 2016, when Google Translate was the only-ish game in town, I’d call them out for it. But we now have multiple competing open weights translation models that are really good, making this kind of service essentially a commodity. One vendor might give users free access to their services to entice them to use their browser, another might differentiate themself by running the model locally and giving the user better privacy guarantees in exchange for performance.

I get that this is one more brick in the wall that teams like LadyBird will have to maintain, but as a web developer I do think more Web API features is generally a good thing, as it makes it easier for smaller shops to implement richer functionality.

rhabarba · 9 months ago
You had me at "Browser compatibility".
Raed667 · 9 months ago
Chrome embeds a small LLM (never stops being a funny thing) in the browser allowing them to do local translations.

I assume every browser will do the same as on-device models start becoming more useful.

rhabarba · 9 months ago
While I appreciate the on-device approach for a couple of reasons, it is rather ironic that Mozilla needs to document that for them.
Asraelite · 9 months ago
What's the easiest way to get this functionality outside of the browser, e.g. as a CLI tool?

Last time I looked I wasn't able to find any easy to run models that supported more than a handful of languages.

tempodox · 9 months ago
What compatibility? It's Chrome-only.
seabass · 9 months ago
With js being a garbage collected language, what is the benefit of the destroy method here and why is it necessary?
charcircuit · 9 months ago
The is no guarantee when it will be garbage collected. For large local models that use a lot of resources they should be unloaded as soon as possible to allow other programs on the computer to use the resources.