AmerAlreyahi commited on
Commit
11e95e9
·
verified ·
1 Parent(s): 22cef66

Add OptimaMT fr-en

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
+ - fr
5
+ - en
6
+ pipeline_tag: translation
7
+ library_name: transformers.js
8
+ base_model: Xenova/opus-mt-fr-en
9
+ tags:
10
+ - translation
11
+ - marian
12
+ - opus-mt
13
+ - onnx
14
+ ---
15
+
16
+ # OptimaMT fr → en (French to English)
17
+
18
+ Drop-in copy of [Xenova/opus-mt-fr-en](https://huggingface.co/Xenova/opus-mt-fr-en) at revision `6b166a182780` 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` | 505 → 272 MiB (-46 %) | 481 → 249 MiB (-48 %) | yes |
24
+ | ONNX Runtime defaults | 270 → 212 MiB (-22 %) | 192 → 162 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/fr-en", {
35
+ dtype: "q8",
36
+ session_options: { extra: { session: { disable_quant_qdq: "1" } } },
37
+ });
38
+ const [out] = await translator("Le phare se dresse sur la côte.");
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/fr-en "Le phare se dresse sur la côte."
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: 59,514 tokens.
52
+
53
+ ## Licence and credits
54
+
55
+ - Weights: [OPUS-MT](https://huggingface.co/Helsinki-NLP/opus-mt-fr-en) by the University of Helsinki, CC BY 4.0.
56
+ - ONNX export: [Xenova/opus-mt-fr-en](https://huggingface.co/Xenova/opus-mt-fr-en) at revision `6b166a182780`.
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,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "Helsinki-NLP/opus-mt-fr-en",
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
+ 59513
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": 59513,
26
+ "decoder_vocab_size": 59514,
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
+ "gradient_checkpointing": false,
35
+ "id2label": {
36
+ "0": "LABEL_0",
37
+ "1": "LABEL_1",
38
+ "2": "LABEL_2"
39
+ },
40
+ "init_std": 0.02,
41
+ "is_encoder_decoder": true,
42
+ "label2id": {
43
+ "LABEL_0": 0,
44
+ "LABEL_1": 1,
45
+ "LABEL_2": 2
46
+ },
47
+ "max_length": 512,
48
+ "max_position_embeddings": 512,
49
+ "model_type": "marian",
50
+ "normalize_before": false,
51
+ "normalize_embedding": false,
52
+ "num_beams": 4,
53
+ "num_hidden_layers": 6,
54
+ "pad_token_id": 59513,
55
+ "scale_embedding": true,
56
+ "share_encoder_decoder_embeddings": true,
57
+ "static_position_embeddings": true,
58
+ "transformers_version": "4.34.0.dev0",
59
+ "use_cache": true,
60
+ "vocab_size": 59514
61
+ }
generation_config.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bad_words_ids": [
3
+ [
4
+ 59513
5
+ ]
6
+ ],
7
+ "bos_token_id": 0,
8
+ "decoder_start_token_id": 59513,
9
+ "eos_token_id": 0,
10
+ "forced_eos_token_id": 0,
11
+ "max_length": 512,
12
+ "num_beams": 4,
13
+ "pad_token_id": 59513,
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:bbbb96e87399efc2a1d9e878ccb9e56dccd481b9a082d1860d5cb9d71b878401
3
+ size 57381180
onnx/encoder_model_quantized.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e727cb26ac6bf816394c49671af69c9ae5798868fed1e40849872415dffc1772
3
+ size 50090398
quantize_config.json ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "per_channel": true,
3
+ "reduce_range": true,
4
+ "per_model_config": {
5
+ "decoder_model": {
6
+ "op_types": [
7
+ "Concat",
8
+ "Softmax",
9
+ "Cast",
10
+ "Where",
11
+ "Squeeze",
12
+ "Range",
13
+ "Gather",
14
+ "Add",
15
+ "ConstantOfShape",
16
+ "Sigmoid",
17
+ "Reshape",
18
+ "Mul",
19
+ "Slice",
20
+ "Pow",
21
+ "ReduceMean",
22
+ "Less",
23
+ "Expand",
24
+ "Transpose",
25
+ "MatMul",
26
+ "Constant",
27
+ "Sub",
28
+ "Unsqueeze",
29
+ "Shape",
30
+ "Sqrt",
31
+ "Equal",
32
+ "Div"
33
+ ],
34
+ "weight_type": "QInt8"
35
+ },
36
+ "encoder_model": {
37
+ "op_types": [
38
+ "Concat",
39
+ "Softmax",
40
+ "Cast",
41
+ "Where",
42
+ "Range",
43
+ "Gather",
44
+ "Add",
45
+ "ConstantOfShape",
46
+ "Sigmoid",
47
+ "Reshape",
48
+ "Mul",
49
+ "Pow",
50
+ "ReduceMean",
51
+ "Expand",
52
+ "Transpose",
53
+ "MatMul",
54
+ "Constant",
55
+ "Sub",
56
+ "Unsqueeze",
57
+ "Shape",
58
+ "Sqrt",
59
+ "Equal",
60
+ "Div"
61
+ ],
62
+ "weight_type": "QInt8"
63
+ },
64
+ "decoder_model_merged": {
65
+ "op_types": [
66
+ "Concat",
67
+ "If",
68
+ "Softmax",
69
+ "Cast",
70
+ "Where",
71
+ "Squeeze",
72
+ "Range",
73
+ "Gather",
74
+ "Add",
75
+ "ConstantOfShape",
76
+ "Sigmoid",
77
+ "Reshape",
78
+ "Mul",
79
+ "Slice",
80
+ "Pow",
81
+ "ReduceMean",
82
+ "Less",
83
+ "Expand",
84
+ "Transpose",
85
+ "MatMul",
86
+ "Constant",
87
+ "Sub",
88
+ "Unsqueeze",
89
+ "Shape",
90
+ "Sqrt",
91
+ "Equal",
92
+ "Div"
93
+ ],
94
+ "weight_type": "QInt8"
95
+ },
96
+ "decoder_with_past_model": {
97
+ "op_types": [
98
+ "Concat",
99
+ "Softmax",
100
+ "Cast",
101
+ "Where",
102
+ "Range",
103
+ "Gather",
104
+ "Add",
105
+ "ConstantOfShape",
106
+ "Sigmoid",
107
+ "Reshape",
108
+ "Mul",
109
+ "Pow",
110
+ "ReduceMean",
111
+ "Expand",
112
+ "Transpose",
113
+ "MatMul",
114
+ "Constant",
115
+ "Sub",
116
+ "Unsqueeze",
117
+ "Shape",
118
+ "Sqrt",
119
+ "Equal",
120
+ "Div"
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:78d0e717c77053f1c4b856d8661d9cb87c64f083a35418c087b9146300e4f585
3
+ size 802397
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:173e9f493a668fe396d599e28d414a201193094e6ffd7a4678e5aab0f6d3d838
3
+ size 778395
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": "fr",
8
+ "sp_model_kwargs": {},
9
+ "target_lang": "en",
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