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

TranslateLocally _base_ models do not work #14

Closed jelmervdl closed 2 years ago

jelmervdl commented 2 years ago

I have no idea why, but when trying to translate de.wikipedia.org with German-English base it fails, and just repeats the first word for every word in the input text.

What I've tried:

To experience this yourself: Check out c5c308a55be8b39c6ad29f8d207e462b170ada47, and apply this patch to prefer base models over tiny models:

diff --git a/extension/controller/translation/translationHelper.js b/extension/controller/translation/translationHelper.js
index e9ed0c7203faf809a923d126971a5c1fd78bc277..edb3046559905f5a3f2cec7f537c6b46d13cd7ba 100644
--- a/extension/controller/translation/translationHelper.js
+++ b/extension/controller/translation/translationHelper.js
@@ -233,6 +233,8 @@ class Channel {
         // Prefer tiny models above non-tiny ones (right now base models don't even work properly 😅)
         entries.sort((a, b) => (a.shortName.indexOf('tiny') === -1 ? 1 : 0) - (b.shortName.indexOf('tiny') === -1 ? 1 : 0));

+        entries.reverse();
+
         if (!entries)
             throw new Error(`No model for ${from} -> ${to}`);

image

jelmervdl commented 2 years ago

Might be related to https://github.com/browsermt/marian-dev/issues/81 (need to confirm that the quick patch there fixes it when run in wasm runtime)

jelmervdl commented 2 years ago

Waiting on browsermt/marian-dev#81. If that gets fixed, this is fine. If not, we might need to drop mozilla's embedded intgemm and always use the fallback path (and then probably push a few more things to get to a reasonable speedy experience.)

jelmervdl commented 2 years ago

This case is mentioned in the code. I don't think Mozilla intends to fix its embedded MozIntGemm, but I also don't think Mozilla intends to ship it in any release version of Firefox. So closing this for now as the only one impacted by it would be the people that are already aware of it.