File size: 3,109 Bytes
3366989
960364a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c5af4bb
 
 
 
 
 
960364a
 
 
 
 
 
 
 
c5af4bb
960364a
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---
license: mpl-2.0
tags:
  - translation
  - onnx
  - offline_translate
---

# offline_translate model bundles

int8 ONNX translation models packaged for the
[`offline_translate`](https://pub.dev/packages/offline_translate) Flutter
package: neural machine translation that runs entirely on a phone, with no
network access of any kind once a model is installed.

Each direction lives in its own directory:

```text
<pair>/manifest.json   metadata, architecture constants, SHA-256 per file
<pair>/encoder.onnx    graph
<pair>/encoder.data    int8 encoder weights (memory-mapped at runtime)
<pair>/decoder.onnx    graph, with a greedy `next_token` output built in
<pair>/decoder.data    int8 decoder weights
<pair>/embedding.data  the tied embedding, shared by both graphs (tiny-ssru)
<pair>/source.spm      upstream SentencePiece model, unmodified
<pair>/vocab.json      upstream shared vocabulary, unmodified (marian only)
```

Use them with:

```dart
final translator = await OfflineTranslator.initialize(
  languages: {Language.en, Language.fr},
  defaultLanguage: Language.fr,
  modelSource: HttpModelSource.official(),
);
await translator.installModel(from: Language.en, to: Language.fr);

final result = translator.translate('Hello, how are you?');
print(result.translatedText); // Bonjour, comment allez-vous ?
```

Every file is verified against the SHA-256 in its manifest before the model is
moved into place, so the transport does not have to be trusted beyond TLS.

## Directions

| Direction | Size | Family | Vocab | Upstream | License |
|---|---:|---|---:|---|---|
| `de-en` | 32.3 MB | tiny-ssru | 32000 | mozilla/firefox-translations-models base-memory/deen | MPL-2.0 |
| `en-de` | 32.3 MB | tiny-ssru | 32000 | mozilla/firefox-translations-models base-memory/ende | MPL-2.0 |
| `en-es` | 32.3 MB | tiny-ssru | 32000 | mozilla/firefox-translations-models base-memory/enes | MPL-2.0 |
| `en-fr` | 32.3 MB | tiny-ssru | 32000 | mozilla/firefox-translations-models base-memory/enfr | MPL-2.0 |
| `es-en` | 32.3 MB | tiny-ssru | 32000 | mozilla/firefox-translations-models base-memory/esen | MPL-2.0 |
| `fr-en` | 32.3 MB | tiny-ssru | 32000 | mozilla/firefox-translations-models base-memory/fren | MPL-2.0 |

## Licensing

These are **modified** weights: converted to ONNX, dynamically quantised to
int8, and extended with a greedy arg-max output node. The conversion pipeline is
`tool/build_tiny_model.py` (and `tool/build_model.py` for the `marian` family) in
the package repository — that, plus the upstream checkpoint, is the source form.

* **MPL-2.0** — `de-en`, `en-de`, `en-es`, `en-fr`, `es-en`, `fr-en`. File-level copyleft: applications that merely *use* these files are unaffected and keep their own licence. Anyone **redistributing** them must keep them under MPL-2.0 and make the source form available.

Upstream projects:

> Mozilla. *Firefox Translations models.*
> <https://github.com/mozilla/firefox-translations-models> — MPL-2.0.

> Jörg Tiedemann and Santhosh Thottingal. *OPUS-MT — Building open translation
> services for the World.* EAMT 2020, Lisbon, Portugal.