jelmervdl / translatelocally-web-ext

TranslateLocally for the Browser is a web-extension that enables client side in-page translations for web browsers.
https://addons.mozilla.org/en-GB/firefox/addon/translatelocally-for-firefox/
Mozilla Public License 2.0
65 stars 3 forks source link

Q: what's the difference between this ext. and the one by Mozilla? #59

Closed atomGit closed 1 year ago

atomGit commented 1 year ago

hi Jelmer - i'm just curious; what's the difference between your extension and the one by Mozilla?

the supported languages seem to be the same and both appear to be using the same resource for translations

jelmervdl commented 1 year ago

The README mentions some of it, but I'll expand a bit on it here.

The gist is: same translation engine, but the extension around it is developed slightly different. Some of the features made it into Mozilla's extension at some point, but I've kept developing my fork after that.

Differences from Firefox Translations

atomGit commented 1 year ago

interesting - thanks for the detailed description!

regarding shared memory across tabs - that seems like it might be a concern - for example if the user enables network partitioning (privacy.firstparty.isolate), might this negate that? or break translation in another tab? ... i haven't used either add-on yet, but if the overhead in not sharing this memory is only a few hundred ms, i don't think anyone would complain

regarding quality indicators - assuming that feature remains, i think this could be valuable even if no context is provided - my thinking here is that some translations of particular words are purposely inaccurate in order to mislead the reader

cadeyrn commented 1 year ago

Hi and thank you for for all the details!

I've continued development of the webpage translation bit (that translates web apps as you interact with them), fixing bugs that I discovered after I last contributed back to Mozilla's copy of that component.

I don't know if it's appropriate to ask this since you're maintaining your own extension with TranslateLocally. But since you know Firefox Translations very well would you consider contributing improvements / bug fixes to the webpage translation bit of Firefox Translations as well? Or is the code base already very different from each other? Maybe you don't want to, which would be understandable, but I thought it doesn't cost anything to ask. I like both extensions very much (and for this reason I cover updates for both extensions on my blog). :)

jelmervdl commented 1 year ago

Hey @atomGit,

regarding shared memory across tabs - that seems like it might be a concern - for example if the user enables network partitioning (privacy.firstparty.isolate), might this negate that? or break translation in another tab? ... i haven't used either add-on yet, but if the overhead in not sharing this memory is only a few hundred ms, i don't think anyone would complain

There's no directly shared memory between tabs. All tabs just send translation requests to the same translation worker. If you want to make tabs read memory from one another, you'll have to find a way to communicate through response times to translation messages.

I think privacy.firstparty.isolate only applies to cookies etc. However, if you configure firefox in such a way that it runs isolated profiles for different websites, I think extensions are part of a profile, so you'd end up running multiple copies of the extensions as well. Which then would not share their translation memory among each other. But I haven't tried any of this.

i haven't used either add-on yet, but if the overhead in not sharing this memory is only a few hundred ms, i don't think anyone would complain

You'd be surprised how much memory this add-on actually eats, I'm afraid 😅 The loaded wasm runtime + transformer model uses quite a chunk of memory.

One way to measure it yourself: go to https://translatelocally.com/web/. Then also open about:memory and measure the memory usage of that tab. Now start typing in the translation box on that page (which will trigger it to load) and measure again.

my thinking here is that some translations of particular words are purposely inaccurate in order to mislead the reader

Quality estimation isn't advanced in any way. I think roughly it is based on how likely a certain word sequence is according to the translation model. Or even more roughly, how similar a produced translation sequence is to data the model has seen during training. I dug a bit through the commit history (this was all done before I joined the project) and I think the implementation is doing what is described in this paper. In a way, I'm maybe more worried about the false sense of confidence they give in parts that are not marked as inaccurate. It would be fairly simple to trick the translation model to produce a wrong translation that it is very confident about precisely because of how it prefers to produce translations that match what it has seen during training.

jelmervdl commented 1 year ago

Hi @cadeyrn,

I don't know if it's appropriate to ask this since you're maintaining your own extension with TranslateLocally. But since you know Firefox Translations very well would you consider contributing improvements / bug fixes to the webpage translation bit of Firefox Translations as well?

I've done this a couple of times in the past, but relations between University of Edinburgh and Mozilla have broken down a bit since the project ended. I've been active in their Github issues, diagnosing bugs and proposing fixes that are related to parts I wrote. But they don't seem to engage at all. I get the impression that they're mostly in maintenance mode for the moment.