AmerAlreyahi commited on
Commit
267ead2
·
verified ·
1 Parent(s): d7efe74

Add OptimaMT en-nl

Browse files
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ source.spm filter=lfs diff=lfs merge=lfs -text
37
+ target.spm filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-4.0
3
+ language:
4
+ - en
5
+ - nl
6
+ pipeline_tag: translation
7
+ library_name: transformers.js
8
+ base_model: Xenova/opus-mt-en-nl
9
+ tags:
10
+ - translation
11
+ - marian
12
+ - opus-mt
13
+ - onnx
14
+ ---
15
+
16
+ # OptimaMT en → nl (English to Dutch)
17
+
18
+ Drop-in copy of [Xenova/opus-mt-en-nl](https://huggingface.co/Xenova/opus-mt-en-nl) at revision `c3a0541231a7` with a lighter merged decoder: same weights, same tokens, less memory.
19
+ Part of [OptimaMT](https://github.com/AmerAlreyahi/OptimaMT) (49 pairs, `OptimaMT/<src>-<tgt>`).
20
+
21
+ | Memory after load | Linux | Windows | Identical tokens |
22
+ |---|---:|---:|---|
23
+ | `disable_quant_qdq = 1` | 557 → 296 MiB (-47 %) | 533 → 270 MiB (-49 %) | yes |
24
+ | ONNX Runtime defaults | 230 → 197 MiB (-14 %) | 206 → 173 MiB (-16 %) | yes |
25
+
26
+ ONNX Runtime 1.31.1, CPU, 4 threads (Linux; Windows in a VM). Interactive results: [OptimaMT/results](https://huggingface.co/spaces/OptimaMT/results) ·
27
+ method: [REPORT.md](https://github.com/AmerAlreyahi/OptimaMT/blob/main/REPORT.md).
28
+
29
+ ## Use
30
+
31
+ ```js
32
+ import { pipeline } from "@huggingface/transformers";
33
+
34
+ const translator = await pipeline("translation", "OptimaMT/en-nl", {
35
+ dtype: "q8",
36
+ session_options: { extra: { session: { disable_quant_qdq: "1" } } },
37
+ });
38
+ const [out] = await translator("The lighthouse stands on the coast.");
39
+ console.log(out.translation_text);
40
+ ```
41
+
42
+ Python ([translate.py](https://github.com/AmerAlreyahi/OptimaMT/blob/main/scripts/translate.py): onnxruntime, sentencepiece, numpy):
43
+
44
+ ```bash
45
+ python translate.py OptimaMT/en-nl "The lighthouse stands on the coast."
46
+ ```
47
+
48
+ ## Files
49
+
50
+ Only `onnx/decoder_model_merged_quantized.onnx` is rebuilt; every other file is the original, byte for byte.
51
+ Vocabulary: 67,028 tokens.
52
+
53
+ ## Licence and credits
54
+
55
+ - Weights: [OPUS-MT](https://huggingface.co/Helsinki-NLP/opus-mt-en-nl) by the University of Helsinki, CC BY 4.0.
56
+ - ONNX export: [Xenova/opus-mt-en-nl](https://huggingface.co/Xenova/opus-mt-en-nl) at revision `c3a0541231a7`.
57
+ - Modified: the decoder's output projection was moved out of its two branches (graph change only). CC BY 4.0.
config.json ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "Helsinki-NLP/opus-mt-en-nl",
3
+ "_num_labels": 3,
4
+ "activation_dropout": 0.0,
5
+ "activation_function": "swish",
6
+ "add_bias_logits": false,
7
+ "add_final_layer_norm": false,
8
+ "architectures": [
9
+ "MarianMTModel"
10
+ ],
11
+ "attention_dropout": 0.0,
12
+ "bad_words_ids": [
13
+ [
14
+ 67027
15
+ ]
16
+ ],
17
+ "bos_token_id": 0,
18
+ "classif_dropout": 0.0,
19
+ "classifier_dropout": 0.0,
20
+ "d_model": 512,
21
+ "decoder_attention_heads": 8,
22
+ "decoder_ffn_dim": 2048,
23
+ "decoder_layerdrop": 0.0,
24
+ "decoder_layers": 6,
25
+ "decoder_start_token_id": 67027,
26
+ "decoder_vocab_size": 67028,
27
+ "dropout": 0.1,
28
+ "encoder_attention_heads": 8,
29
+ "encoder_ffn_dim": 2048,
30
+ "encoder_layerdrop": 0.0,
31
+ "encoder_layers": 6,
32
+ "eos_token_id": 0,
33
+ "forced_eos_token_id": 0,
34
+ "id2label": {
35
+ "0": "LABEL_0",
36
+ "1": "LABEL_1",
37
+ "2": "LABEL_2"
38
+ },
39
+ "init_std": 0.02,
40
+ "is_encoder_decoder": true,
41
+ "label2id": {
42
+ "LABEL_0": 0,
43
+ "LABEL_1": 1,
44
+ "LABEL_2": 2
45
+ },
46
+ "max_length": 512,
47
+ "max_position_embeddings": 512,
48
+ "model_type": "marian",
49
+ "normalize_before": false,
50
+ "normalize_embedding": false,
51
+ "num_beams": 4,
52
+ "num_hidden_layers": 6,
53
+ "pad_token_id": 67027,
54
+ "scale_embedding": true,
55
+ "share_encoder_decoder_embeddings": true,
56
+ "static_position_embeddings": true,
57
+ "transformers_version": "4.34.0.dev0",
58
+ "use_cache": true,
59
+ "vocab_size": 67028
60
+ }
generation_config.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bad_words_ids": [
3
+ [
4
+ 67027
5
+ ]
6
+ ],
7
+ "bos_token_id": 0,
8
+ "decoder_start_token_id": 67027,
9
+ "eos_token_id": 0,
10
+ "forced_eos_token_id": 0,
11
+ "max_length": 512,
12
+ "num_beams": 4,
13
+ "pad_token_id": 67027,
14
+ "renormalize_logits": true,
15
+ "transformers_version": "4.34.0.dev0"
16
+ }
onnx/decoder_model_merged_quantized.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c41791e07e4995f06c719eb8917140d8150f3404d8fecbdaee2287a74bcdd5f8
3
+ size 61258403
onnx/encoder_model_quantized.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0febb990f8ca8ed9fd3e0017dfcb55ec5293999f20ead81d2bb4370e9e3120ff
3
+ size 53937565
quantize_config.json ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "per_channel": true,
3
+ "reduce_range": true,
4
+ "per_model_config": {
5
+ "encoder_model": {
6
+ "op_types": [
7
+ "Pow",
8
+ "Mul",
9
+ "Div",
10
+ "Gather",
11
+ "ReduceMean",
12
+ "Range",
13
+ "ConstantOfShape",
14
+ "Concat",
15
+ "Unsqueeze",
16
+ "Sigmoid",
17
+ "Sqrt",
18
+ "Expand",
19
+ "Equal",
20
+ "Softmax",
21
+ "Where",
22
+ "Cast",
23
+ "Shape",
24
+ "Add",
25
+ "Constant",
26
+ "MatMul",
27
+ "Reshape",
28
+ "Sub",
29
+ "Transpose"
30
+ ],
31
+ "weight_type": "QInt8"
32
+ },
33
+ "decoder_with_past_model": {
34
+ "op_types": [
35
+ "Pow",
36
+ "Mul",
37
+ "Div",
38
+ "Gather",
39
+ "ReduceMean",
40
+ "Range",
41
+ "ConstantOfShape",
42
+ "Concat",
43
+ "Unsqueeze",
44
+ "Sigmoid",
45
+ "Sqrt",
46
+ "Expand",
47
+ "Equal",
48
+ "Softmax",
49
+ "Where",
50
+ "Cast",
51
+ "Shape",
52
+ "Add",
53
+ "Constant",
54
+ "MatMul",
55
+ "Reshape",
56
+ "Sub",
57
+ "Transpose"
58
+ ],
59
+ "weight_type": "QInt8"
60
+ },
61
+ "decoder_model_merged": {
62
+ "op_types": [
63
+ "Pow",
64
+ "Mul",
65
+ "Div",
66
+ "Gather",
67
+ "ReduceMean",
68
+ "Range",
69
+ "Slice",
70
+ "ConstantOfShape",
71
+ "Concat",
72
+ "Unsqueeze",
73
+ "Sigmoid",
74
+ "Less",
75
+ "Sqrt",
76
+ "Expand",
77
+ "Equal",
78
+ "Softmax",
79
+ "Squeeze",
80
+ "Cast",
81
+ "Shape",
82
+ "Add",
83
+ "Where",
84
+ "Constant",
85
+ "MatMul",
86
+ "Reshape",
87
+ "Sub",
88
+ "Transpose",
89
+ "If"
90
+ ],
91
+ "weight_type": "QInt8"
92
+ },
93
+ "decoder_model": {
94
+ "op_types": [
95
+ "Pow",
96
+ "Mul",
97
+ "Div",
98
+ "Gather",
99
+ "ReduceMean",
100
+ "Range",
101
+ "Slice",
102
+ "ConstantOfShape",
103
+ "Concat",
104
+ "Unsqueeze",
105
+ "Sigmoid",
106
+ "Less",
107
+ "Sqrt",
108
+ "Expand",
109
+ "Equal",
110
+ "Softmax",
111
+ "Squeeze",
112
+ "Cast",
113
+ "Shape",
114
+ "Add",
115
+ "Where",
116
+ "Constant",
117
+ "MatMul",
118
+ "Reshape",
119
+ "Sub",
120
+ "Transpose"
121
+ ],
122
+ "weight_type": "QInt8"
123
+ }
124
+ }
125
+ }
source.spm ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d05781fde84b8793191528a7a176e1b17f96265388f602379ee6ae3139f59141
3
+ size 789525
special_tokens_map.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "eos_token": "</s>",
3
+ "pad_token": "<pad>",
4
+ "unk_token": "<unk>"
5
+ }
target.spm ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f538d23d4b30641cd97c608d2a83890d503aa1286a5560f19ef949404a786e94
3
+ size 813866
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "clean_up_tokenization_spaces": true,
3
+ "eos_token": "</s>",
4
+ "model_max_length": 512,
5
+ "pad_token": "<pad>",
6
+ "separate_vocabs": false,
7
+ "source_lang": "en",
8
+ "sp_model_kwargs": {},
9
+ "target_lang": "nl",
10
+ "tokenizer_class": "MarianTokenizer",
11
+ "unk_token": "<unk>"
12
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff