AmerAlreyahi commited on
Commit
aacb23f
·
verified ·
1 Parent(s): 9a04681

Add OptimaMT vi-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
+ - vi
5
+ - en
6
+ pipeline_tag: translation
7
+ library_name: transformers.js
8
+ base_model: Xenova/opus-mt-vi-en
9
+ tags:
10
+ - translation
11
+ - marian
12
+ - opus-mt
13
+ - onnx
14
+ ---
15
+
16
+ # OptimaMT vi → en (Vietnamese to English)
17
+
18
+ Drop-in copy of [Xenova/opus-mt-vi-en](https://huggingface.co/Xenova/opus-mt-vi-en) at revision `541dfd72ec07` 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` | 465 → 255 MiB (-45 %) | 442 → 232 MiB (-47 %) | yes |
24
+ | ONNX Runtime defaults | 251 → 198 MiB (-21 %) | 181 → 154 MiB (-15 %) | 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/vi-en", {
35
+ dtype: "q8",
36
+ session_options: { extra: { session: { disable_quant_qdq: "1" } } },
37
+ });
38
+ const [out] = await translator("Ngọn hải đăng đứng trên bờ biển.");
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/vi-en "Ngọn hải đăng đứng trên bờ biển."
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: 53,739 tokens.
52
+
53
+ ## Licence and credits
54
+
55
+ - Weights: [OPUS-MT](https://huggingface.co/Helsinki-NLP/opus-mt-vi-en) by the University of Helsinki, CC BY 4.0.
56
+ - ONNX export: [Xenova/opus-mt-vi-en](https://huggingface.co/Xenova/opus-mt-vi-en) at revision `541dfd72ec07`.
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-vi-en",
3
+ "activation_dropout": 0.0,
4
+ "activation_function": "swish",
5
+ "add_bias_logits": false,
6
+ "add_final_layer_norm": false,
7
+ "architectures": [
8
+ "MarianMTModel"
9
+ ],
10
+ "attention_dropout": 0.0,
11
+ "bad_words_ids": [
12
+ [
13
+ 53738
14
+ ]
15
+ ],
16
+ "bos_token_id": 0,
17
+ "classif_dropout": 0.0,
18
+ "classifier_dropout": 0.0,
19
+ "d_model": 512,
20
+ "decoder_attention_heads": 8,
21
+ "decoder_ffn_dim": 2048,
22
+ "decoder_layerdrop": 0.0,
23
+ "decoder_layers": 6,
24
+ "decoder_start_token_id": 53738,
25
+ "decoder_vocab_size": 53739,
26
+ "dropout": 0.1,
27
+ "encoder_attention_heads": 8,
28
+ "encoder_ffn_dim": 2048,
29
+ "encoder_layerdrop": 0.0,
30
+ "encoder_layers": 6,
31
+ "eos_token_id": 0,
32
+ "extra_pos_embeddings": 53739,
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": 6,
52
+ "num_hidden_layers": 6,
53
+ "pad_token_id": 53738,
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": 53739
60
+ }
generation_config.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bad_words_ids": [
3
+ [
4
+ 53738
5
+ ]
6
+ ],
7
+ "bos_token_id": 0,
8
+ "decoder_start_token_id": 53738,
9
+ "eos_token_id": 0,
10
+ "forced_eos_token_id": 0,
11
+ "max_length": 512,
12
+ "num_beams": 6,
13
+ "pad_token_id": 53738,
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:699ef5a7a2c6ba1d9fa05879dd13adaccbc496454b08e3fb6919ecf70744a51a
3
+ size 54401279
onnx/encoder_model_quantized.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fa7bd78e8bed6bdc03728f62f1592c4bb52d9e12795496604c1e990e102abdb2
3
+ size 47133597
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
+ "Sigmoid",
8
+ "Unsqueeze",
9
+ "Range",
10
+ "Concat",
11
+ "Div",
12
+ "Gather",
13
+ "Shape",
14
+ "Reshape",
15
+ "MatMul",
16
+ "Sub",
17
+ "Sqrt",
18
+ "Where",
19
+ "Add",
20
+ "Softmax",
21
+ "Transpose",
22
+ "Constant",
23
+ "Mul",
24
+ "Expand",
25
+ "Equal",
26
+ "ConstantOfShape",
27
+ "ReduceMean",
28
+ "Pow",
29
+ "Cast"
30
+ ],
31
+ "weight_type": "QInt8"
32
+ },
33
+ "decoder_with_past_model": {
34
+ "op_types": [
35
+ "Sigmoid",
36
+ "Unsqueeze",
37
+ "Range",
38
+ "Concat",
39
+ "Div",
40
+ "Gather",
41
+ "Shape",
42
+ "Reshape",
43
+ "MatMul",
44
+ "Sub",
45
+ "Sqrt",
46
+ "Where",
47
+ "Add",
48
+ "Softmax",
49
+ "Transpose",
50
+ "Constant",
51
+ "Mul",
52
+ "Expand",
53
+ "Equal",
54
+ "ConstantOfShape",
55
+ "ReduceMean",
56
+ "Pow",
57
+ "Cast"
58
+ ],
59
+ "weight_type": "QInt8"
60
+ },
61
+ "decoder_model_merged": {
62
+ "op_types": [
63
+ "Sigmoid",
64
+ "Unsqueeze",
65
+ "Range",
66
+ "Concat",
67
+ "Div",
68
+ "Gather",
69
+ "Shape",
70
+ "Reshape",
71
+ "MatMul",
72
+ "Sub",
73
+ "Squeeze",
74
+ "Slice",
75
+ "Sqrt",
76
+ "Where",
77
+ "Add",
78
+ "Softmax",
79
+ "Transpose",
80
+ "Constant",
81
+ "If",
82
+ "Mul",
83
+ "Less",
84
+ "Equal",
85
+ "ConstantOfShape",
86
+ "Expand",
87
+ "ReduceMean",
88
+ "Pow",
89
+ "Cast"
90
+ ],
91
+ "weight_type": "QInt8"
92
+ },
93
+ "decoder_model": {
94
+ "op_types": [
95
+ "Sigmoid",
96
+ "Unsqueeze",
97
+ "Range",
98
+ "Concat",
99
+ "Div",
100
+ "Gather",
101
+ "Shape",
102
+ "Reshape",
103
+ "MatMul",
104
+ "Sub",
105
+ "Squeeze",
106
+ "Slice",
107
+ "Sqrt",
108
+ "Where",
109
+ "Add",
110
+ "Softmax",
111
+ "Transpose",
112
+ "Constant",
113
+ "Mul",
114
+ "Less",
115
+ "Equal",
116
+ "ConstantOfShape",
117
+ "Expand",
118
+ "ReduceMean",
119
+ "Pow",
120
+ "Cast"
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:9deb4f9e7bebd3876f4bf238a9eb52f2f95a1fba2210a4a8239167c55c15e67d
3
+ size 756168
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:629182070d11db929990c603779345a11743b749f6586f224829303fa979c138
3
+ size 808853
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": "vie",
8
+ "sp_model_kwargs": {},
9
+ "target_lang": "eng",
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