AmerAlreyahi commited on
Commit
6ce1191
·
verified ·
1 Parent(s): fc05736

Add OptimaMT fr-de

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
+ - de
6
+ pipeline_tag: translation
7
+ library_name: transformers.js
8
+ base_model: Xenova/opus-mt-fr-de
9
+ tags:
10
+ - translation
11
+ - marian
12
+ - opus-mt
13
+ - onnx
14
+ ---
15
+
16
+ # OptimaMT fr → de (French to German)
17
+
18
+ Drop-in copy of [Xenova/opus-mt-fr-de](https://huggingface.co/Xenova/opus-mt-fr-de) at revision `7eea1996b448` 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` | 516 → 276 MiB (-46 %) | 494 → 255 MiB (-48 %) | yes |
24
+ | ONNX Runtime defaults | 276 → 216 MiB (-22 %) | 195 → 164 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-de", {
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-de "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: 61,153 tokens.
52
+
53
+ ## Licence and credits
54
+
55
+ - Weights: [OPUS-MT](https://huggingface.co/Helsinki-NLP/opus-mt-fr-de) by the University of Helsinki, CC BY 4.0.
56
+ - ONNX export: [Xenova/opus-mt-fr-de](https://huggingface.co/Xenova/opus-mt-fr-de) at revision `7eea1996b448`.
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-fr-de",
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
+ 61152
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": 61152,
26
+ "decoder_vocab_size": 61153,
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": 61152,
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": 61153
60
+ }
generation_config.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bad_words_ids": [
3
+ [
4
+ 61152
5
+ ]
6
+ ],
7
+ "bos_token_id": 0,
8
+ "decoder_start_token_id": 61152,
9
+ "eos_token_id": 0,
10
+ "forced_eos_token_id": 0,
11
+ "max_length": 512,
12
+ "num_beams": 4,
13
+ "pad_token_id": 61152,
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:26ada70f131c8fffbea44462c190dede181fc4e6411ace33278ef50d71a0122f
3
+ size 58226904
onnx/encoder_model_quantized.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:76e81a715482c10d25fe3cbfe1129b236adcdc75bac4d9cee37bc97dc61ee8dd
3
+ size 50929566
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
+ "Div",
8
+ "Sigmoid",
9
+ "Reshape",
10
+ "MatMul",
11
+ "ConstantOfShape",
12
+ "ReduceMean",
13
+ "Sub",
14
+ "Concat",
15
+ "Mul",
16
+ "Constant",
17
+ "Softmax",
18
+ "Equal",
19
+ "Unsqueeze",
20
+ "Add",
21
+ "Gather",
22
+ "Transpose",
23
+ "Pow",
24
+ "Expand",
25
+ "Range",
26
+ "Shape",
27
+ "Cast",
28
+ "Sqrt",
29
+ "Where"
30
+ ],
31
+ "weight_type": "QInt8"
32
+ },
33
+ "decoder_with_past_model": {
34
+ "op_types": [
35
+ "Div",
36
+ "Sigmoid",
37
+ "Reshape",
38
+ "MatMul",
39
+ "ConstantOfShape",
40
+ "ReduceMean",
41
+ "Sub",
42
+ "Concat",
43
+ "Mul",
44
+ "Constant",
45
+ "Softmax",
46
+ "Equal",
47
+ "Unsqueeze",
48
+ "Add",
49
+ "Gather",
50
+ "Transpose",
51
+ "Pow",
52
+ "Expand",
53
+ "Range",
54
+ "Shape",
55
+ "Cast",
56
+ "Sqrt",
57
+ "Where"
58
+ ],
59
+ "weight_type": "QInt8"
60
+ },
61
+ "decoder_model_merged": {
62
+ "op_types": [
63
+ "Div",
64
+ "Sigmoid",
65
+ "Slice",
66
+ "Reshape",
67
+ "MatMul",
68
+ "ConstantOfShape",
69
+ "ReduceMean",
70
+ "Sub",
71
+ "Less",
72
+ "Concat",
73
+ "Mul",
74
+ "Constant",
75
+ "Softmax",
76
+ "Squeeze",
77
+ "Equal",
78
+ "Unsqueeze",
79
+ "Add",
80
+ "Gather",
81
+ "Transpose",
82
+ "Pow",
83
+ "Expand",
84
+ "Range",
85
+ "Shape",
86
+ "Cast",
87
+ "If",
88
+ "Sqrt",
89
+ "Where"
90
+ ],
91
+ "weight_type": "QInt8"
92
+ },
93
+ "decoder_model": {
94
+ "op_types": [
95
+ "Div",
96
+ "Sigmoid",
97
+ "Slice",
98
+ "Reshape",
99
+ "MatMul",
100
+ "ConstantOfShape",
101
+ "ReduceMean",
102
+ "Sub",
103
+ "Less",
104
+ "Concat",
105
+ "Mul",
106
+ "Constant",
107
+ "Softmax",
108
+ "Squeeze",
109
+ "Equal",
110
+ "Unsqueeze",
111
+ "Add",
112
+ "Gather",
113
+ "Transpose",
114
+ "Pow",
115
+ "Expand",
116
+ "Range",
117
+ "Shape",
118
+ "Cast",
119
+ "Sqrt",
120
+ "Where"
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:e9a9acb44b4f88235ca6cc9f0b4546f942ba34fb1b27937b11386cc8db63ee83
3
+ size 812399
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:965802053f4a59f81d48283bd1160ed49950124891f8f532d98945de4f5e58eb
3
+ size 827737
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": "de",
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