AmerAlreyahi commited on
Commit
6901f2c
·
verified ·
1 Parent(s): 670f8c1

Add OptimaMT fr-ru

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