radinplaid commited on
Commit
0d3e097
·
verified ·
1 Parent(s): 2e4f066

Upload folder using huggingface_hub

Browse files
.ipynb_checkpoints/README-checkpoint.md ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - it
5
+ tags:
6
+ - translation
7
+ license: cc-by-4.0
8
+ datasets:
9
+ - quickmt/quickmt-train.it-en
10
+ model-index:
11
+ - name: quickmt-en-it
12
+ results:
13
+ - task:
14
+ name: Translation eng-ita
15
+ type: translation
16
+ args: eng-ita
17
+ dataset:
18
+ name: flores101-devtest
19
+ type: flores_101
20
+ args: eng_Latn ita_Latn devtest
21
+ metrics:
22
+ - name: BLEU
23
+ type: bleu
24
+ value: 30.52
25
+ - name: CHRF
26
+ type: chrf
27
+ value: 59.72
28
+ - name: COMET
29
+ type: comet
30
+ value: 87.55
31
+ ---
32
+
33
+
34
+ # `quickmt-en-it` Neural Machine Translation Model
35
+
36
+ `quickmt-en-it` is a reasonably fast and reasonably accurate neural machine translation model for translation from `en` into `it`.
37
+
38
+
39
+ ## Model Information
40
+
41
+ * Trained using [`eole`](https://github.com/eole-nlp/eole)
42
+ * 185M parameter transformer 'big' with 8 encoder layers and 2 decoder layers
43
+ * 20k sentencepiece vocabularies
44
+ * Exported for fast inference to [CTranslate2](https://github.com/OpenNMT/CTranslate2) format
45
+ * Training data: https://huggingface.co/datasets/quickmt/quickmt-train.it-en/tree/main
46
+
47
+ See the `eole` model configuration in this repository for further details and the `eole-model` for the raw `eole` (pytorch) model.
48
+
49
+
50
+ ## Usage with `quickmt`
51
+
52
+ You must install the Nvidia cuda toolkit first, if you want to do GPU inference.
53
+
54
+ Next, install the `quickmt` python library and download the model:
55
+
56
+ ```bash
57
+ git clone https://github.com/quickmt/quickmt.git
58
+ pip install ./quickmt/
59
+
60
+ quickmt-model-download quickmt/quickmt-en-it ./quickmt-en-it
61
+ ```
62
+
63
+ Finally use the model in python:
64
+
65
+ ```python
66
+ from quickmt import Translator
67
+
68
+ # Auto-detects GPU, set to "cpu" to force CPU inference
69
+ t = Translator("./quickmt-en-it/", device="auto")
70
+
71
+ # Translate - set beam size to 5 for higher quality (but slower speed)
72
+ sample_text = 'Dr. Ehud Ur, professor of medicine at Dalhousie University in Halifax, Nova Scotia and chair of the clinical and scientific division of the Canadian Diabetes Association cautioned that the research is still in its early days.'
73
+ t(sample_text, beam_size=5)
74
+
75
+ > 'Il dottor Ehud Ur, professore di medicina alla Dalhousie University di Halifax, in Nuova Scozia e presidente della divisione clinica e scientifica della Canadian Diabetes Association, ha avvertito che la ricerca è ancora agli inizi.'
76
+
77
+ # Get alternative translations by sampling
78
+ # You can pass any cTranslate2 `translate_batch` arguments
79
+ t([sample_text], sampling_temperature=1.2, beam_size=1, sampling_topk=50, sampling_topp=0.9)
80
+
81
+ > "Il Dott. Ehud Ur, professore di medicina alla Dalhousie University di Halifax, Nuova Scozia e presidente del dipartimento scientifico e clinica dell'Associazione Canada-del diabete ha avvertito che questa ricerca si trova ancora in pieno giorno."
82
+
83
+ ```
84
+
85
+ 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`.
86
+
87
+
88
+ ## Metrics
89
+
90
+ `bleu` and `chrf2` are calculated with [sacrebleu](https://github.com/mjpost/sacrebleu) on the [Flores200 `devtest` test set](https://huggingface.co/datasets/facebook/flores) ("eng_Latn"->"ita_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 (using `ctranslate2`) the flores-devtest dataset (1012 sentences) on an RTX 4070s GPU with batch size 32 (faster speed is possible using a large batch size).
91
+
92
+ | | bleu | chrf2 | comet22 | Time (s) |
93
+ |:---------------------------------|-------:|--------:|----------:|-----------:|
94
+ | quickmt/quickmt-en-it | 30.52 | 59.72 | 87.55 | 1.06 |
95
+ | Helsink-NLP/opus-mt-en-it | 27.58 | 57.66 | 85.1 | 4.42 |
96
+ | facebook/nllb-200-distilled-600M | 28.58 | 58.3 | 87.3 | 24.93 |
97
+ | facebook/nllb-200-distilled-1.3B | 30.92 | 59.89 | 88.52 | 43.8 |
98
+ | facebook/m2m100_418M | 23.81 | 54.34 | 82.64 | 20.34 |
99
+ | facebook/m2m100_1.2B | 27.22 | 57.19 | 86.23 | 39.98 |
100
+
101
+ `quickmt-en-it` is the fastest and second highest quality next to `nllb-200-distilled-1.3B`.
README.md ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - it
5
+ tags:
6
+ - translation
7
+ license: cc-by-4.0
8
+ datasets:
9
+ - quickmt/quickmt-train.it-en
10
+ model-index:
11
+ - name: quickmt-en-it
12
+ results:
13
+ - task:
14
+ name: Translation eng-ita
15
+ type: translation
16
+ args: eng-ita
17
+ dataset:
18
+ name: flores101-devtest
19
+ type: flores_101
20
+ args: eng_Latn ita_Latn devtest
21
+ metrics:
22
+ - name: BLEU
23
+ type: bleu
24
+ value: 30.52
25
+ - name: CHRF
26
+ type: chrf
27
+ value: 59.72
28
+ - name: COMET
29
+ type: comet
30
+ value: 87.55
31
+ ---
32
+
33
+
34
+ # `quickmt-en-it` Neural Machine Translation Model
35
+
36
+ `quickmt-en-it` is a reasonably fast and reasonably accurate neural machine translation model for translation from `en` into `it`.
37
+
38
+
39
+ ## Model Information
40
+
41
+ * Trained using [`eole`](https://github.com/eole-nlp/eole)
42
+ * 185M parameter transformer 'big' with 8 encoder layers and 2 decoder layers
43
+ * 20k sentencepiece vocabularies
44
+ * Exported for fast inference to [CTranslate2](https://github.com/OpenNMT/CTranslate2) format
45
+ * Training data: https://huggingface.co/datasets/quickmt/quickmt-train.it-en/tree/main
46
+
47
+ See the `eole` model configuration in this repository for further details and the `eole-model` for the raw `eole` (pytorch) model.
48
+
49
+
50
+ ## Usage with `quickmt`
51
+
52
+ You must install the Nvidia cuda toolkit first, if you want to do GPU inference.
53
+
54
+ Next, install the `quickmt` python library and download the model:
55
+
56
+ ```bash
57
+ git clone https://github.com/quickmt/quickmt.git
58
+ pip install ./quickmt/
59
+
60
+ quickmt-model-download quickmt/quickmt-en-it ./quickmt-en-it
61
+ ```
62
+
63
+ Finally use the model in python:
64
+
65
+ ```python
66
+ from quickmt import Translator
67
+
68
+ # Auto-detects GPU, set to "cpu" to force CPU inference
69
+ t = Translator("./quickmt-en-it/", device="auto")
70
+
71
+ # Translate - set beam size to 5 for higher quality (but slower speed)
72
+ sample_text = 'Dr. Ehud Ur, professor of medicine at Dalhousie University in Halifax, Nova Scotia and chair of the clinical and scientific division of the Canadian Diabetes Association cautioned that the research is still in its early days.'
73
+ t(sample_text, beam_size=5)
74
+
75
+ > 'Il dottor Ehud Ur, professore di medicina alla Dalhousie University di Halifax, in Nuova Scozia e presidente della divisione clinica e scientifica della Canadian Diabetes Association, ha avvertito che la ricerca è ancora agli inizi.'
76
+
77
+ # Get alternative translations by sampling
78
+ # You can pass any cTranslate2 `translate_batch` arguments
79
+ t([sample_text], sampling_temperature=1.2, beam_size=1, sampling_topk=50, sampling_topp=0.9)
80
+
81
+ > "Il Dott. Ehud Ur, professore di medicina alla Dalhousie University di Halifax, Nuova Scozia e presidente del dipartimento scientifico e clinica dell'Associazione Canada-del diabete ha avvertito che questa ricerca si trova ancora in pieno giorno."
82
+
83
+ ```
84
+
85
+ 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`.
86
+
87
+
88
+ ## Metrics
89
+
90
+ `bleu` and `chrf2` are calculated with [sacrebleu](https://github.com/mjpost/sacrebleu) on the [Flores200 `devtest` test set](https://huggingface.co/datasets/facebook/flores) ("eng_Latn"->"ita_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 (using `ctranslate2`) the flores-devtest dataset (1012 sentences) on an RTX 4070s GPU with batch size 32 (faster speed is possible using a large batch size).
91
+
92
+ | | bleu | chrf2 | comet22 | Time (s) |
93
+ |:---------------------------------|-------:|--------:|----------:|-----------:|
94
+ | quickmt/quickmt-en-it | 30.52 | 59.72 | 87.55 | 1.06 |
95
+ | Helsink-NLP/opus-mt-en-it | 27.58 | 57.66 | 85.1 | 4.42 |
96
+ | facebook/nllb-200-distilled-600M | 28.58 | 58.3 | 87.3 | 24.93 |
97
+ | facebook/nllb-200-distilled-1.3B | 30.92 | 59.89 | 88.52 | 43.8 |
98
+ | facebook/m2m100_418M | 23.81 | 54.34 | 82.64 | 20.34 |
99
+ | facebook/m2m100_1.2B | 27.22 | 57.19 | 86.23 | 39.98 |
100
+
101
+ `quickmt-en-it` is the fastest and second highest quality next to `nllb-200-distilled-1.3B`.
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,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: en.eole.vocab
12
+ tgt_vocab: it.eole.vocab
13
+ src_vocab_size: 20000
14
+ tgt_vocab_size: 20000
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.ja-en/ja
22
+ # path_tgt: hf://quickmt/quickmt-train.ja-en/en
23
+ # path_sco: hf://quickmt/quickmt-train.ja-en/sco
24
+ path_src: train.en
25
+ path_tgt: train.it
26
+ valid:
27
+ path_src: valid.en
28
+ path_tgt: valid.it
29
+
30
+ transforms: [sentencepiece, filtertoolong]
31
+ transforms_configs:
32
+ sentencepiece:
33
+ src_subword_model: "en.spm.model"
34
+ tgt_subword_model: "it.spm.model"
35
+ filtertoolong:
36
+ src_seq_length: 256
37
+ tgt_seq_length: 256
38
+
39
+ training:
40
+ # Run configuration
41
+ model_path: quickmt-en-it-eole-model
42
+ #train_from: model
43
+ keep_checkpoint: 4
44
+ train_steps: 100000
45
+ save_checkpoint_steps: 5000
46
+ valid_steps: 5000
47
+
48
+ # Train on a single GPU
49
+ world_size: 1
50
+ gpu_ranks: [0]
51
+
52
+ # Batching 10240
53
+ batch_type: "tokens"
54
+ batch_size: 8000
55
+ valid_batch_size: 4096
56
+ batch_size_multiple: 8
57
+ accum_count: [10]
58
+ accum_steps: [0]
59
+
60
+ # Optimizer & Compute
61
+ compute_dtype: "fp16"
62
+ optim: "adamw"
63
+ learning_rate: 2.0
64
+ warmup_steps: 4000
65
+ decay_method: "noam"
66
+ adam_beta2: 0.998
67
+
68
+ # Data loading
69
+ bucket_size: 512000
70
+ num_workers: 4
71
+ prefetch_factor: 64
72
+
73
+ # Hyperparams
74
+ dropout_steps: [0]
75
+ dropout: [0.1]
76
+ attention_dropout: [0.1]
77
+ max_grad_norm: 0
78
+ label_smoothing: 0.1
79
+ average_decay: 0.0001
80
+ param_init_method: xavier_uniform
81
+ normalization: "tokens"
82
+
83
+ model:
84
+ architecture: "transformer"
85
+ share_embeddings: false
86
+ share_decoder_embeddings: false
87
+ hidden_size: 1024
88
+ encoder:
89
+ layers: 8
90
+ decoder:
91
+ layers: 2
92
+ heads: 8
93
+ transformer_ff: 4096
94
+ embeddings:
95
+ word_vec_size: 1024
96
+ position_encoding_type: "SinusoidalInterleaved"
97
+
eole-model/config.json ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "src_vocab": "en.eole.vocab",
3
+ "n_sample": 0,
4
+ "seed": 1234,
5
+ "tensorboard": true,
6
+ "src_vocab_size": 20000,
7
+ "vocab_size_multiple": 8,
8
+ "tensorboard_log_dir_dated": "tensorboard/Apr-21_19-00-53",
9
+ "tgt_vocab_size": 20000,
10
+ "tensorboard_log_dir": "tensorboard",
11
+ "share_vocab": false,
12
+ "save_data": "data",
13
+ "transforms": [
14
+ "sentencepiece",
15
+ "filtertoolong"
16
+ ],
17
+ "valid_metrics": [
18
+ "BLEU"
19
+ ],
20
+ "tgt_vocab": "it.eole.vocab",
21
+ "report_every": 100,
22
+ "overwrite": true,
23
+ "training": {
24
+ "optim": "adamw",
25
+ "average_decay": 0.0001,
26
+ "keep_checkpoint": 4,
27
+ "model_path": "quickmt-en-it-eole-model",
28
+ "gpu_ranks": [
29
+ 0
30
+ ],
31
+ "valid_steps": 5000,
32
+ "batch_size": 8000,
33
+ "bucket_size": 512000,
34
+ "adam_beta2": 0.998,
35
+ "label_smoothing": 0.1,
36
+ "warmup_steps": 4000,
37
+ "param_init_method": "xavier_uniform",
38
+ "normalization": "tokens",
39
+ "batch_type": "tokens",
40
+ "save_checkpoint_steps": 5000,
41
+ "num_workers": 0,
42
+ "accum_count": [
43
+ 10
44
+ ],
45
+ "train_steps": 100000,
46
+ "dropout": [
47
+ 0.1
48
+ ],
49
+ "learning_rate": 2.0,
50
+ "max_grad_norm": 0.0,
51
+ "attention_dropout": [
52
+ 0.1
53
+ ],
54
+ "batch_size_multiple": 8,
55
+ "prefetch_factor": 64,
56
+ "compute_dtype": "torch.float16",
57
+ "decay_method": "noam",
58
+ "valid_batch_size": 4096,
59
+ "world_size": 1,
60
+ "accum_steps": [
61
+ 0
62
+ ],
63
+ "dropout_steps": [
64
+ 0
65
+ ]
66
+ },
67
+ "data": {
68
+ "corpus_1": {
69
+ "transforms": [
70
+ "sentencepiece",
71
+ "filtertoolong"
72
+ ],
73
+ "path_tgt": "train.it",
74
+ "path_align": null,
75
+ "path_src": "train.en"
76
+ },
77
+ "valid": {
78
+ "transforms": [
79
+ "sentencepiece",
80
+ "filtertoolong"
81
+ ],
82
+ "path_tgt": "valid.it",
83
+ "path_align": null,
84
+ "path_src": "valid.en"
85
+ }
86
+ },
87
+ "model": {
88
+ "transformer_ff": 4096,
89
+ "architecture": "transformer",
90
+ "heads": 8,
91
+ "share_embeddings": false,
92
+ "hidden_size": 1024,
93
+ "share_decoder_embeddings": false,
94
+ "position_encoding_type": "SinusoidalInterleaved",
95
+ "embeddings": {
96
+ "position_encoding_type": "SinusoidalInterleaved",
97
+ "src_word_vec_size": 1024,
98
+ "tgt_word_vec_size": 1024,
99
+ "word_vec_size": 1024
100
+ },
101
+ "decoder": {
102
+ "tgt_word_vec_size": 1024,
103
+ "layers": 2,
104
+ "transformer_ff": 4096,
105
+ "n_positions": null,
106
+ "heads": 8,
107
+ "decoder_type": "transformer",
108
+ "hidden_size": 1024,
109
+ "position_encoding_type": "SinusoidalInterleaved"
110
+ },
111
+ "encoder": {
112
+ "src_word_vec_size": 1024,
113
+ "layers": 8,
114
+ "transformer_ff": 4096,
115
+ "n_positions": null,
116
+ "encoder_type": "transformer",
117
+ "heads": 8,
118
+ "hidden_size": 1024,
119
+ "position_encoding_type": "SinusoidalInterleaved"
120
+ }
121
+ },
122
+ "transforms_configs": {
123
+ "filtertoolong": {
124
+ "tgt_seq_length": 256,
125
+ "src_seq_length": 256
126
+ },
127
+ "sentencepiece": {
128
+ "src_subword_model": "${MODEL_PATH}/en.spm.model",
129
+ "tgt_subword_model": "${MODEL_PATH}/it.spm.model"
130
+ }
131
+ }
132
+ }
eole-model/en.spm.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:352edbef8a5896ac750aa1318696d770c15c85d79116c94b4872086a1de94b2d
3
+ size 586485
eole-model/it.spm.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:47b20d73c2224922ffef2d6f4bbe72810d7f75c80281dcea17515fc25a7a7bb9
3
+ size 598389
eole-model/model.00.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1164a0b5ebb78a58e4e10563aeab594b3633d5e306c3e7e5760699984c0e9076
3
+ size 823882912
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:def57a69faad1db092d1ac8ad7db1a9ee056e77625ab3dca0d2d1ac22d6c1f37
3
+ size 401699775
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:352edbef8a5896ac750aa1318696d770c15c85d79116c94b4872086a1de94b2d
3
+ size 586485
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:47b20d73c2224922ffef2d6f4bbe72810d7f75c80281dcea17515fc25a7a7bb9
3
+ size 598389