locale-ai 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -7
- package/dist/catalog.js +30 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,9 +16,9 @@ npx locale-ai translate --from en --to fr,es,de
|
|
|
16
16
|
locale-ai 0.2.0
|
|
17
17
|
Found 3 en files in locales/en/
|
|
18
18
|
Models to download (one time, then cached for every project):
|
|
19
|
-
en-fr
|
|
19
|
+
en-fr 345 MB khabouss/opus-mt-tc-big-en-fr-onnx
|
|
20
20
|
...
|
|
21
|
-
Download
|
|
21
|
+
Download 577 MB? (Y/n)
|
|
22
22
|
✓ fr 43 strings translated, 3 files written in 2.7s, 1 plural forms added
|
|
23
23
|
✓ es 43 strings translated, 3 files written in 2.5s, 1 plural forms added
|
|
24
24
|
✓ de 43 strings translated, 3 files written in 2.1s
|
|
@@ -98,11 +98,10 @@ then declare it in `locale-ai.config.json`:
|
|
|
98
98
|
- `prefix` is required for multi-target models (`convert` lists the model's `>>xx<<` tokens).
|
|
99
99
|
- Project models take priority over built-ins for their language pairs and can be used for pivoting (e.g. `ja → en → tr`).
|
|
100
100
|
|
|
101
|
-
**Recommended for quality**: the `opus-mt-tc-big-en-*` models (
|
|
101
|
+
**Recommended for quality**: the `opus-mt-tc-big-en-*` models (es, it, pt, ar, tr, and `zle` for ru/uk). They are ~3x larger (270–370 MB int8) and ~1.5x slower, and clearly better. `en-fr` already uses one of these as its built-in model (see [Languages](#languages)), hosted at [khabouss/opus-mt-tc-big-en-fr-onnx](https://huggingface.co/khabouss/opus-mt-tc-big-en-fr-onnx) — no conversion needed for it.
|
|
102
102
|
|
|
103
103
|
| Target | Built-in model, chrF / BLEU | tc-big model, chrF / BLEU |
|
|
104
104
|
|---|---|---|
|
|
105
|
-
| fr | 68.9 / 53.7 | **72.5 / 55.9** |
|
|
106
105
|
| es | 72.9 / 56.9 | **73.6 / 57.4** |
|
|
107
106
|
| it | 73.8 / 54.9 | **75.3 / 58.2** |
|
|
108
107
|
| pt | 68.3 / 44.4 | **70.6 / 47.7** (`>>por<<`, or `>>pob<<` for pt-BR) |
|
|
@@ -124,7 +123,7 @@ Measured on a sample app (see `test/fixtures`):
|
|
|
124
123
|
| Usable — review before shipping | it, ar, ru, zh-CN, zh-TW |
|
|
125
124
|
| Untested | the other pairs in `locale-ai models list` |
|
|
126
125
|
|
|
127
|
-
With the tc-big models above, it, ar and ru move up a tier and tr becomes available. Not available yet: ja, ko, pl and others; he works with a converted `opus-mt-en-he` (weaker). Moroccan Arabic (Darija): the tc-big en-ar model has a `>>ary<<` token, but its output is close to Modern Standard Arabic — not supported.
|
|
126
|
+
`en-fr` is already on the tc-big model (chrF 72.5 / BLEU 55.9) as a built-in, no config needed. With the other tc-big models above, it, ar and ru move up a tier and tr becomes available. Not available yet: ja, ko, pl and others; he works with a converted `opus-mt-en-he` (weaker). Moroccan Arabic (Darija): the tc-big en-ar model has a `>>ary<<` token, but its output is close to Modern Standard Arabic — not supported.
|
|
128
127
|
|
|
129
128
|
## How it works
|
|
130
129
|
|
|
@@ -142,7 +141,7 @@ With the tc-big models above, it, ar and ru move up a tier and tr becomes availa
|
|
|
142
141
|
```bash
|
|
143
142
|
npm install
|
|
144
143
|
npm test # unit tests (no models)
|
|
145
|
-
npm run test:e2e # real models, downloads ~
|
|
144
|
+
npm run test:e2e # real models, downloads ~345 MB once (en-fr, tc-big)
|
|
146
145
|
node bench/eval.ts --dir <model dir> --lang fr --beams 4 --out out.json # quality benchmark (see bench/README.md)
|
|
147
146
|
npm run dev -- translate --to fr # run from source (Node ≥ 22.18 strips types)
|
|
148
147
|
npm run build # → dist/
|
|
@@ -150,7 +149,7 @@ npm run build # → dist/
|
|
|
150
149
|
|
|
151
150
|
## Next steps
|
|
152
151
|
|
|
153
|
-
1. **Host the tc-big models** (converted ONNX) on Hugging Face so they can become the built-in defaults instead of a manual conversion.
|
|
152
|
+
1. **Host the tc-big models** (converted ONNX) on Hugging Face so they can become the built-in defaults instead of a manual conversion. `en-fr` is done ([khabouss/opus-mt-tc-big-en-fr-onnx](https://huggingface.co/khabouss/opus-mt-tc-big-en-fr-onnx)); es, it, pt, ar, ru/uk, tr remain.
|
|
154
153
|
2. **Smaller install.** `onnxruntime-node` is ~550 MB unpacked: it ships binaries for every platform plus a 260 MB CUDA provider we never use.
|
|
155
154
|
3. **More languages**: ja, ko, pl have no usable OPUS-MT model yet; a different model family would be needed.
|
|
156
155
|
4. **More formats**: YAML, `.po`, ARB, Apple `.strings`.
|
package/dist/catalog.js
CHANGED
|
@@ -8,8 +8,8 @@ const pair = (src, tgt) => ({
|
|
|
8
8
|
});
|
|
9
9
|
const DIRECT = [
|
|
10
10
|
"af-en", "ar-en", "cs-en", "da-de", "da-en", "de-en", "de-es", "de-fr",
|
|
11
|
-
"en-af", "en-cs", "en-da", "en-de", "en-es", "en-fi", "en-
|
|
12
|
-
"en-hu", "en-id", "en-it", "en-nl", "en-ro", "en-
|
|
11
|
+
"en-af", "en-cs", "en-da", "en-de", "en-es", "en-fi", "en-hi",
|
|
12
|
+
"en-hu", "en-id", "en-it", "en-nl", "en-ro", "en-sv",
|
|
13
13
|
"en-xh", "es-de", "es-en", "es-fr", "es-it", "es-ru", "et-en", "fi-de",
|
|
14
14
|
"fi-en", "fr-de", "fr-en", "fr-es", "fr-ro", "fr-ru", "hi-en", "hu-en",
|
|
15
15
|
"id-en", "it-en", "it-es", "it-fr", "ja-en", "ko-en", "nl-en", "nl-fr",
|
|
@@ -22,10 +22,36 @@ export const CATALOG = [
|
|
|
22
22
|
const [s, t] = p.split("-");
|
|
23
23
|
return pair(s, t);
|
|
24
24
|
}),
|
|
25
|
+
// tc-big: larger OPUS-MT checkpoints, clearly better than the defaults (see
|
|
26
|
+
// bench/README.md). Converted and hosted per the README's "Add a language,
|
|
27
|
+
// or a better model" section.
|
|
28
|
+
{ ...pair("en", "fr"), repo: "khabouss/opus-mt-tc-big-en-fr-onnx" }, // chrF 72.5 vs 68.9, BLEU 55.9 vs 53.7
|
|
29
|
+
{ ...pair("en", "es"), repo: "khabouss/opus-mt-tc-big-en-es-onnx" }, // chrF 73.6 vs 72.9, BLEU 57.4 vs 56.9
|
|
30
|
+
{ ...pair("en", "it"), repo: "khabouss/opus-mt-tc-big-en-it-onnx" }, // chrF 75.3 vs 73.8, BLEU 58.2 vs 54.9
|
|
31
|
+
// New: Turkish, not supported by any built-in model before this.
|
|
32
|
+
{ ...pair("en", "tr"), repo: "khabouss/opus-mt-tc-big-en-tr-onnx" }, // chrF 67.4, BLEU 42.1
|
|
25
33
|
{
|
|
26
|
-
//
|
|
27
|
-
//
|
|
34
|
+
// Multi-target: >>por<< (European) / >>pob<< (Brazilian). No individual built-in
|
|
35
|
+
// existed before; pt was only reachable via the weaker en-ROMANCE model.
|
|
36
|
+
id: "en-pt",
|
|
37
|
+
repo: "khabouss/opus-mt-tc-big-en-pt-onnx", // chrF 70.6 vs 68.3, BLEU 47.7 vs 44.4
|
|
38
|
+
sources: ["en"],
|
|
39
|
+
targets: ["pt"],
|
|
40
|
+
prefix: (t) => (t.region === "BR" ? ">>pob<<" : ">>por<<"),
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
// Multi-target East Slavic model, replaces the separate en-ru/en-uk built-ins.
|
|
44
|
+
id: "en-zle",
|
|
45
|
+
repo: "khabouss/opus-mt-tc-big-en-zle-onnx", // ru: chrF 68.2 vs 65.7, BLEU 48.1 vs 46.0
|
|
46
|
+
sources: ["en"],
|
|
47
|
+
targets: ["ru", "uk"],
|
|
48
|
+
prefix: (t) => (t.lang === "ru" ? ">>rus<<" : ">>ukr<<"),
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
// Note: the model card lists Moroccan Arabic ("ary") but its output stays close
|
|
52
|
+
// to Modern Standard Arabic, so Darija is not treated as supported.
|
|
28
53
|
...pair("en", "ar"),
|
|
54
|
+
repo: "khabouss/opus-mt-tc-big-en-ar-onnx", // chrF 49.7 vs 47.8, BLEU 19.9 vs 16.6 (greedy)
|
|
29
55
|
prefix: () => ">>ara<<",
|
|
30
56
|
},
|
|
31
57
|
{
|