radinplaid commited on
Commit
90b62ed
·
verified ·
1 Parent(s): cca7e53

Upload folder using huggingface_hub

Browse files
.ipynb_checkpoints/README-checkpoint.md ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - ro
5
+ tags:
6
+ - translation
7
+ license: cc-by-4.0
8
+ datasets:
9
+ - quickmt/quickmt-train.ro-en
10
+ model-index:
11
+ - name: quickmt-ro-en
12
+ results:
13
+ - task:
14
+ name: Translation ron-eng
15
+ type: translation
16
+ args: ron-eng
17
+ dataset:
18
+ name: flores101-devtest
19
+ type: flores_101
20
+ args: ron_Latn eng_Latn devtest
21
+ metrics:
22
+ - name: BLEU
23
+ type: bleu
24
+ value: 44.93
25
+ - name: CHRF
26
+ type: chrf
27
+ value: 69.3
28
+ - name: COMET
29
+ type: comet
30
+ value: 89.31
31
+ ---
32
+
33
+
34
+ # `quickmt-ro-en` Neural Machine Translation Model
35
+
36
+ `quickmt-ro-en` is a reasonably fast and reasonably accurate neural machine translation model for translation from `ro` into `en`.
37
+
38
+
39
+ ## Try it on our Huggingface Space
40
+
41
+ Give it a try before downloading here: https://huggingface.co/spaces/quickmt/QuickMT-Demo
42
+
43
+
44
+ ## Model Information
45
+
46
+ * Trained using [`eole`](https://github.com/eole-nlp/eole)
47
+ * 200M parameter transformer 'big' with 8 encoder layers and 2 decoder layers
48
+ * 32k separate Sentencepiece vocabs
49
+ * Expested for fast inference to [CTranslate2](https://github.com/OpenNMT/CTranslate2) format
50
+ * Training data: https://huggingface.co/datasets/quickmt/quickmt-train.ro-en/tree/main
51
+
52
+ See the `eole` model configuration in this repository for further details and the `eole-model` for the raw `eole` (pytorch) model.
53
+
54
+
55
+ ## Usage with `quickmt`
56
+
57
+ You must install the Nvidia cuda toolkit first, if you want to do GPU inference.
58
+
59
+ Next, install the `quickmt` python library and download the model:
60
+
61
+ ```bash
62
+ git clone https://github.com/quickmt/quickmt.git
63
+ pip install ./quickmt/
64
+
65
+ quickmt-model-download quickmt/quickmt-ro-en ./quickmt-ro-en
66
+ ```
67
+
68
+ Finally use the model in python:
69
+
70
+ ```python
71
+ from quickmt import Translator
72
+
73
+ # Auto-detects GPU, set to "cpu" to force CPU inference
74
+ t = Translator("./quickmt-ro-en/", device="auto")
75
+
76
+ # Translate - set beam size to 1 for faster speed (but lower quality)
77
+ sample_text = 'Dr. Ehud Ur, profesor de medicină la Universitatea Dalhousie din Halifax, Nova Scotia, și președinte al diviziei clinice și științifice a Asociației Canadiene pentru Diabet, a atras atenția că cercetarea se află încă în fază incipientă.'
78
+
79
+ t(sample_text, beam_size=5)
80
+ ```
81
+
82
+ > 'Dr Ehud Ur, a professor of medicine at Dalhousie University in Halifax, Nova Scotia, and president of the clinical and scientific division of the Canadian Diabetes Association, said the research was still in its infancy.'
83
+
84
+ ```python
85
+ # Get alternative translations by sampling
86
+ # You can pass any cTranslate2 `translate_batch` arguments
87
+ t([sample_text], sampling_temperature=1.2, beam_size=1, sampling_topk=50, sampling_topp=0.9)
88
+ ```
89
+
90
+ > 'Dr Ehud Ur, MD, clinical clinical and scientific chair of the Canadian Diabetes Association’s Scientific and Clinical Division, stated: “the study is still in its infancy.'
91
+
92
+ The model is in `ctranslate2` format, and the tokenizers are `sentencepiece`, so you can use `ctranslate2` directly instead of through `quickmt`. It is also possible to get this model to work with e.g. [LibreTranslate](https://libretranslate.com/) which also uses `ctranslate2` and `sentencepiece`. A model in safetensors format to be used with `eole` is also provided.
93
+
94
+
95
+ ## Metrics
96
+
97
+ `bleu` and `chrf2` are calculated with [sacrebleu](https://github.com/mjpost/sacrebleu) on the [Flores200 `devtest` test set](https://huggingface.co/datasets/facebook/flores) ("ron_Latn"->"eng_Latn"). `comet22` with the [`comet`](https://github.com/Unbabel/COMET) library and the [default model](https://huggingface.co/Unbabel/wmt22-comet-da). "Time (s)" is the time in seconds to translate the flores-devtest dataset (1012 sentences) on an RTX 4070s GPU with batch size 32 (faster speed is possible using a larger batch size).
98
+
99
+
100
+ | | bleu | chrf2 | comet22 | Time (s) |
101
+ |:---------------------------------|-------:|--------:|----------:|-----------:|
102
+ | quickmt/quickmt-ro-en | 44.93 | 69.3 | 89.31 | 1.37 |
103
+ | facebook/nllb-200-distilled-600M | 43.3 | 68.16 | 88.86 | 22.01 |
104
+ | facebook/nllb-200-distilled-1.3B | 45.32 | 69.63 | 89.47 | 38.38 |
105
+ | facebook/m2m100_418M | 34.44 | 62.75 | 85.64 | 18.57 |
106
+ | facebook/m2m100_1.2B | 40.96 | 66.93 | 88.41 | 35.87 |
107
+
README.md CHANGED
@@ -1,3 +1,107 @@
1
- ---
2
- license: cc-by-4.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - ro
5
+ tags:
6
+ - translation
7
+ license: cc-by-4.0
8
+ datasets:
9
+ - quickmt/quickmt-train.ro-en
10
+ model-index:
11
+ - name: quickmt-ro-en
12
+ results:
13
+ - task:
14
+ name: Translation ron-eng
15
+ type: translation
16
+ args: ron-eng
17
+ dataset:
18
+ name: flores101-devtest
19
+ type: flores_101
20
+ args: ron_Latn eng_Latn devtest
21
+ metrics:
22
+ - name: BLEU
23
+ type: bleu
24
+ value: 44.93
25
+ - name: CHRF
26
+ type: chrf
27
+ value: 69.3
28
+ - name: COMET
29
+ type: comet
30
+ value: 89.31
31
+ ---
32
+
33
+
34
+ # `quickmt-ro-en` Neural Machine Translation Model
35
+
36
+ `quickmt-ro-en` is a reasonably fast and reasonably accurate neural machine translation model for translation from `ro` into `en`.
37
+
38
+
39
+ ## Try it on our Huggingface Space
40
+
41
+ Give it a try before downloading here: https://huggingface.co/spaces/quickmt/QuickMT-Demo
42
+
43
+
44
+ ## Model Information
45
+
46
+ * Trained using [`eole`](https://github.com/eole-nlp/eole)
47
+ * 200M parameter transformer 'big' with 8 encoder layers and 2 decoder layers
48
+ * 32k separate Sentencepiece vocabs
49
+ * Expested for fast inference to [CTranslate2](https://github.com/OpenNMT/CTranslate2) format
50
+ * Training data: https://huggingface.co/datasets/quickmt/quickmt-train.ro-en/tree/main
51
+
52
+ See the `eole` model configuration in this repository for further details and the `eole-model` for the raw `eole` (pytorch) model.
53
+
54
+
55
+ ## Usage with `quickmt`
56
+
57
+ You must install the Nvidia cuda toolkit first, if you want to do GPU inference.
58
+
59
+ Next, install the `quickmt` python library and download the model:
60
+
61
+ ```bash
62
+ git clone https://github.com/quickmt/quickmt.git
63
+ pip install ./quickmt/
64
+
65
+ quickmt-model-download quickmt/quickmt-ro-en ./quickmt-ro-en
66
+ ```
67
+
68
+ Finally use the model in python:
69
+
70
+ ```python
71
+ from quickmt import Translator
72
+
73
+ # Auto-detects GPU, set to "cpu" to force CPU inference
74
+ t = Translator("./quickmt-ro-en/", device="auto")
75
+
76
+ # Translate - set beam size to 1 for faster speed (but lower quality)
77
+ sample_text = 'Dr. Ehud Ur, profesor de medicină la Universitatea Dalhousie din Halifax, Nova Scotia, și președinte al diviziei clinice și științifice a Asociației Canadiene pentru Diabet, a atras atenția că cercetarea se află încă în fază incipientă.'
78
+
79
+ t(sample_text, beam_size=5)
80
+ ```
81
+
82
+ > 'Dr Ehud Ur, a professor of medicine at Dalhousie University in Halifax, Nova Scotia, and president of the clinical and scientific division of the Canadian Diabetes Association, said the research was still in its infancy.'
83
+
84
+ ```python
85
+ # Get alternative translations by sampling
86
+ # You can pass any cTranslate2 `translate_batch` arguments
87
+ t([sample_text], sampling_temperature=1.2, beam_size=1, sampling_topk=50, sampling_topp=0.9)
88
+ ```
89
+
90
+ > 'Dr Ehud Ur, MD, clinical clinical and scientific chair of the Canadian Diabetes Association’s Scientific and Clinical Division, stated: “the study is still in its infancy.'
91
+
92
+ The model is in `ctranslate2` format, and the tokenizers are `sentencepiece`, so you can use `ctranslate2` directly instead of through `quickmt`. It is also possible to get this model to work with e.g. [LibreTranslate](https://libretranslate.com/) which also uses `ctranslate2` and `sentencepiece`. A model in safetensors format to be used with `eole` is also provided.
93
+
94
+
95
+ ## Metrics
96
+
97
+ `bleu` and `chrf2` are calculated with [sacrebleu](https://github.com/mjpost/sacrebleu) on the [Flores200 `devtest` test set](https://huggingface.co/datasets/facebook/flores) ("ron_Latn"->"eng_Latn"). `comet22` with the [`comet`](https://github.com/Unbabel/COMET) library and the [default model](https://huggingface.co/Unbabel/wmt22-comet-da). "Time (s)" is the time in seconds to translate the flores-devtest dataset (1012 sentences) on an RTX 4070s GPU with batch size 32 (faster speed is possible using a larger batch size).
98
+
99
+
100
+ | | bleu | chrf2 | comet22 | Time (s) |
101
+ |:---------------------------------|-------:|--------:|----------:|-----------:|
102
+ | quickmt/quickmt-ro-en | 44.93 | 69.3 | 89.31 | 1.37 |
103
+ | facebook/nllb-200-distilled-600M | 43.3 | 68.16 | 88.86 | 22.01 |
104
+ | facebook/nllb-200-distilled-1.3B | 45.32 | 69.63 | 89.47 | 38.38 |
105
+ | facebook/m2m100_418M | 34.44 | 62.75 | 85.64 | 18.57 |
106
+ | facebook/m2m100_1.2B | 40.96 | 66.93 | 88.41 | 35.87 |
107
+
config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_source_bos": false,
3
+ "add_source_eos": false,
4
+ "bos_token": "<s>",
5
+ "decoder_start_token": "<s>",
6
+ "eos_token": "</s>",
7
+ "layer_norm_epsilon": 1e-06,
8
+ "multi_query_attention": false,
9
+ "unk_token": "<unk>"
10
+ }
eole-config.yaml ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## IO
2
+ save_data: data
3
+ overwrite: True
4
+ seed: 1234
5
+ report_every: 100
6
+ valid_metrics: ["BLEU"]
7
+ tensorboard: true
8
+ tensorboard_log_dir: tensorboard
9
+
10
+ ### Vocab
11
+ src_vocab: ro.eole.vocab
12
+ tgt_vocab: en.eole.vocab
13
+ src_vocab_size: 32000
14
+ tgt_vocab_size: 32000
15
+ vocab_size_multiple: 8
16
+ share_vocab: false
17
+ n_sample: 0
18
+
19
+ data:
20
+ corpus_1:
21
+ path_src: hf://quickmt/quickmt-train.ro-en/ro
22
+ path_tgt: hf://quickmt/quickmt-train.ro-en/en
23
+ path_sco: hf://quickmt/quickmt-train.ro-en/sco
24
+ valid:
25
+ path_src: valid.ro
26
+ path_tgt: valid.en
27
+
28
+ transforms: [sentencepiece, filtertoolong]
29
+ transforms_configs:
30
+ sentencepiece:
31
+ src_subword_model: "ro.spm.model"
32
+ tgt_subword_model: "en.spm.model"
33
+ filtertoolong:
34
+ src_seq_length: 256
35
+ tgt_seq_length: 256
36
+
37
+ training:
38
+ # Run configuration
39
+ model_path: quickmt-ro-en-eole-model
40
+ #train_from: model
41
+ keep_checkpoint: 4
42
+ train_steps: 100000
43
+ save_checkpoint_steps: 5000
44
+ valid_steps: 5000
45
+
46
+ # Train on a single GPU
47
+ world_size: 1
48
+ gpu_ranks: [0]
49
+
50
+ # Batching 10240
51
+ batch_type: "tokens"
52
+ batch_size: 12000
53
+ valid_batch_size: 2048
54
+ batch_size_multiple: 8
55
+ accum_count: [10]
56
+ accum_steps: [0]
57
+
58
+ # Optimizer & Compute
59
+ compute_dtype: "fp16"
60
+ optim: "adamw"
61
+ #use_amp: False
62
+ learning_rate: 2.0
63
+ warmup_steps: 2000
64
+ decay_method: "noam"
65
+ adam_beta2: 0.998
66
+
67
+ # Data loading
68
+ bucket_size: 128000
69
+ num_workers: 4
70
+ prefetch_factor: 32
71
+
72
+ # Hyperparams
73
+ dropout_steps: [0]
74
+ dropout: [0.1]
75
+ attention_dropout: [0.1]
76
+ max_grad_norm: 0
77
+ label_smoothing: 0.1
78
+ average_decay: 0.0001
79
+ param_init_method: xavier_uniform
80
+ normalization: "tokens"
81
+
82
+ model:
83
+ architecture: "transformer"
84
+ share_embeddings: false
85
+ share_decoder_embeddings: true
86
+ hidden_size: 1024
87
+ encoder:
88
+ layers: 8
89
+ decoder:
90
+ layers: 2
91
+ heads: 8
92
+ transformer_ff: 4096
93
+ embeddings:
94
+ word_vec_size: 1024
95
+ position_encoding_type: "SinusoidalInterleaved"
96
+
eole-model/config.json ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "vocab_size_multiple": 8,
3
+ "tensorboard_log_dir_dated": "tensorboard/Oct-11_12-25-44",
4
+ "tgt_vocab": "en.eole.vocab",
5
+ "n_sample": 0,
6
+ "transforms": [
7
+ "sentencepiece",
8
+ "filtertoolong"
9
+ ],
10
+ "valid_metrics": [
11
+ "BLEU"
12
+ ],
13
+ "src_vocab_size": 32000,
14
+ "tensorboard": true,
15
+ "tgt_vocab_size": 32000,
16
+ "tensorboard_log_dir": "tensorboard",
17
+ "report_every": 100,
18
+ "overwrite": true,
19
+ "share_vocab": false,
20
+ "src_vocab": "ro.eole.vocab",
21
+ "seed": 1234,
22
+ "save_data": "data",
23
+ "training": {
24
+ "accum_count": [
25
+ 10
26
+ ],
27
+ "batch_type": "tokens",
28
+ "average_decay": 0.0001,
29
+ "warmup_steps": 2000,
30
+ "learning_rate": 2.0,
31
+ "adam_beta2": 0.998,
32
+ "compute_dtype": "torch.float16",
33
+ "decay_method": "noam",
34
+ "dropout": [
35
+ 0.1
36
+ ],
37
+ "max_grad_norm": 0.0,
38
+ "bucket_size": 128000,
39
+ "prefetch_factor": 32,
40
+ "gpu_ranks": [
41
+ 0
42
+ ],
43
+ "save_checkpoint_steps": 5000,
44
+ "accum_steps": [
45
+ 0
46
+ ],
47
+ "model_path": "quickmt-ro-en-eole-model",
48
+ "normalization": "tokens",
49
+ "attention_dropout": [
50
+ 0.1
51
+ ],
52
+ "num_workers": 0,
53
+ "label_smoothing": 0.1,
54
+ "param_init_method": "xavier_uniform",
55
+ "valid_steps": 5000,
56
+ "keep_checkpoint": 4,
57
+ "world_size": 1,
58
+ "batch_size_multiple": 8,
59
+ "batch_size": 12000,
60
+ "dropout_steps": [
61
+ 0
62
+ ],
63
+ "valid_batch_size": 2048,
64
+ "optim": "adamw",
65
+ "train_steps": 100000
66
+ },
67
+ "model": {
68
+ "architecture": "transformer",
69
+ "heads": 8,
70
+ "transformer_ff": 4096,
71
+ "position_encoding_type": "SinusoidalInterleaved",
72
+ "share_embeddings": false,
73
+ "hidden_size": 1024,
74
+ "share_decoder_embeddings": true,
75
+ "encoder": {
76
+ "heads": 8,
77
+ "transformer_ff": 4096,
78
+ "position_encoding_type": "SinusoidalInterleaved",
79
+ "src_word_vec_size": 1024,
80
+ "n_positions": null,
81
+ "encoder_type": "transformer",
82
+ "layers": 8,
83
+ "hidden_size": 1024
84
+ },
85
+ "decoder": {
86
+ "tgt_word_vec_size": 1024,
87
+ "heads": 8,
88
+ "transformer_ff": 4096,
89
+ "decoder_type": "transformer",
90
+ "position_encoding_type": "SinusoidalInterleaved",
91
+ "n_positions": null,
92
+ "layers": 2,
93
+ "hidden_size": 1024
94
+ },
95
+ "embeddings": {
96
+ "position_encoding_type": "SinusoidalInterleaved",
97
+ "word_vec_size": 1024,
98
+ "tgt_word_vec_size": 1024,
99
+ "src_word_vec_size": 1024
100
+ }
101
+ },
102
+ "transforms_configs": {
103
+ "filtertoolong": {
104
+ "src_seq_length": 256,
105
+ "tgt_seq_length": 256
106
+ },
107
+ "sentencepiece": {
108
+ "tgt_subword_model": "${MODEL_PATH}/en.spm.model",
109
+ "src_subword_model": "${MODEL_PATH}/ro.spm.model"
110
+ }
111
+ },
112
+ "data": {
113
+ "corpus_1": {
114
+ "path_sco": "hf://quickmt/quickmt-train.ro-en/sco",
115
+ "path_tgt": "hf://quickmt/quickmt-train.ro-en/en",
116
+ "path_align": null,
117
+ "path_src": "hf://quickmt/quickmt-train.ro-en/ro",
118
+ "transforms": [
119
+ "sentencepiece",
120
+ "filtertoolong"
121
+ ]
122
+ },
123
+ "valid": {
124
+ "path_align": null,
125
+ "path_tgt": "valid.en",
126
+ "path_src": "valid.ro",
127
+ "transforms": [
128
+ "sentencepiece",
129
+ "filtertoolong"
130
+ ]
131
+ }
132
+ }
133
+ }
eole-model/en.spm.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:db0b667cb624705e59a1af53a05118ead90fd9ddb695880b7a9000601b445276
3
+ size 804879
eole-model/model.00.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b3927dd4eaca5a2c12e2f28ba103a52dc87202dccdf7ce6841ffd283fb64a73a
3
+ size 840314816
eole-model/ro.spm.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8cbacefea2837d7161439e3476c8ad05ad11826be8f3563db1bcb6748f373cb7
3
+ size 829294
eole-model/vocab.json ADDED
The diff for this file is too large to render. See raw diff
 
model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c23895ec8933238b14c883bb1a2488c9fef09b951abb23b9a36b171f9616013f
3
+ size 409915789
source_vocabulary.json ADDED
The diff for this file is too large to render. See raw diff
 
src.spm.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8cbacefea2837d7161439e3476c8ad05ad11826be8f3563db1bcb6748f373cb7
3
+ size 829294
target_vocabulary.json ADDED
The diff for this file is too large to render. See raw diff
 
tgt.spm.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:db0b667cb624705e59a1af53a05118ead90fd9ddb695880b7a9000601b445276
3
+ size 804879