radinplaid commited on
Commit
8fddb97
·
verified ·
1 Parent(s): b6c3551

Upload folder using huggingface_hub

Browse files
.ipynb_checkpoints/README-checkpoint.md ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - es
5
+ tags:
6
+ - translation
7
+ license: cc-by-4.0
8
+ datasets:
9
+ - quickmt/quickmt-train.es-en
10
+ model-index:
11
+ - name: quickmt-en-es
12
+ results:
13
+ - task:
14
+ name: Translation eng-spa
15
+ type: translation
16
+ args: eng-spa
17
+ dataset:
18
+ name: flores101-devtest
19
+ type: flores_101
20
+ args: eng_Latn spa_Latn devtest
21
+ metrics:
22
+ - name: BLEU
23
+ type: bleu
24
+ value: 26.64
25
+ - name: CHRF
26
+ type: chrf
27
+ value: 55.12
28
+ - name: COMET
29
+ type: comet
30
+ value: 85.15
31
+ ---
32
+
33
+
34
+ # `quickmt-en-es` Neural Machine Translation Model
35
+
36
+ `quickmt-en-es` is a reasonably fast and reasonably accurate neural machine translation model for translation from `en` into `es`.
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-es ./quickmt-en-es
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-es/", 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
+ > 'El Dr. Ehud Ur, profesor de medicina de la Universidad de Dalhousie en Halifax, Nueva Escocia y presidente de la división clínica y científica de la Asociación Canadiense de Diabetes, advirtió que la investigación todavía está en sus primeros días.'
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
+ > 'El Dr. Ehud Ur, profesor de medicina en la Universidad de Dalhousie en Halifax (Nova Escocia), y presidenta de la división clínica y científica de la Asociación Canadiense de Diabetes, advirtió que la investigación continúa en sus días iniciales.'
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"->"spa_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-es | 26.64 | 55.12 | 85.15 | 1.41 |
95
+ | Helsink-NLP/opus-mt-en-es | 26.56 | 55.01 | 84.92 | 3.79 |
96
+ | facebook/nllb-200-distilled-600M | 27.2 | 55.68 | 85.82 | 24.12 |
97
+ | facebook/nllb-200-distilled-1.3B | 28.06 | 56.47 | 86.55 | 42.12 |
98
+ | facebook/m2m100_418M | 22.48 | 51.72 | 81.05 | 19.65 |
99
+ | facebook/m2m100_1.2B | 25.75 | 54.38 | 84.58 | 38.47 |
README.md CHANGED
@@ -1,3 +1,99 @@
1
- ---
2
- license: cc-by-4.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - es
5
+ tags:
6
+ - translation
7
+ license: cc-by-4.0
8
+ datasets:
9
+ - quickmt/quickmt-train.es-en
10
+ model-index:
11
+ - name: quickmt-en-es
12
+ results:
13
+ - task:
14
+ name: Translation eng-spa
15
+ type: translation
16
+ args: eng-spa
17
+ dataset:
18
+ name: flores101-devtest
19
+ type: flores_101
20
+ args: eng_Latn spa_Latn devtest
21
+ metrics:
22
+ - name: BLEU
23
+ type: bleu
24
+ value: 26.64
25
+ - name: CHRF
26
+ type: chrf
27
+ value: 55.12
28
+ - name: COMET
29
+ type: comet
30
+ value: 85.15
31
+ ---
32
+
33
+
34
+ # `quickmt-en-es` Neural Machine Translation Model
35
+
36
+ `quickmt-en-es` is a reasonably fast and reasonably accurate neural machine translation model for translation from `en` into `es`.
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-es ./quickmt-en-es
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-es/", 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
+ > 'El Dr. Ehud Ur, profesor de medicina de la Universidad de Dalhousie en Halifax, Nueva Escocia y presidente de la división clínica y científica de la Asociación Canadiense de Diabetes, advirtió que la investigación todavía está en sus primeros días.'
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
+ > 'El Dr. Ehud Ur, profesor de medicina en la Universidad de Dalhousie en Halifax (Nova Escocia), y presidenta de la división clínica y científica de la Asociación Canadiense de Diabetes, advirtió que la investigación continúa en sus días iniciales.'
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"->"spa_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-es | 26.64 | 55.12 | 85.15 | 1.41 |
95
+ | Helsink-NLP/opus-mt-en-es | 26.56 | 55.01 | 84.92 | 3.79 |
96
+ | facebook/nllb-200-distilled-600M | 27.2 | 55.68 | 85.82 | 24.12 |
97
+ | facebook/nllb-200-distilled-1.3B | 28.06 | 56.47 | 86.55 | 42.12 |
98
+ | facebook/m2m100_418M | 22.48 | 51.72 | 81.05 | 19.65 |
99
+ | facebook/m2m100_1.2B | 25.75 | 54.38 | 84.58 | 38.47 |
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,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: es.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.es-en/en
22
+ # path_tgt: hf://quickmt/quickmt-train.es-en/es
23
+ # path_sco: hf://quickmt/quickmt-train.es-en/sco
24
+ path_src: train.en
25
+ path_tgt: train.es
26
+ valid:
27
+ path_src: dev.en
28
+ path_tgt: dev.es
29
+
30
+ transforms: [sentencepiece, filtertoolong]
31
+ transforms_configs:
32
+ sentencepiece:
33
+ src_subword_model: "en.spm.model"
34
+ tgt_subword_model: "es.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-es-eole-model
42
+ train_from: quickmt-en-es-eole-model
43
+ #train_from: model
44
+ keep_checkpoint: 4
45
+ train_steps: 200000
46
+ save_checkpoint_steps: 5000
47
+ valid_steps: 5000
48
+
49
+ # Train on a single GPU
50
+ world_size: 1
51
+ gpu_ranks: [0]
52
+
53
+ # Batching 10240
54
+ batch_type: "tokens"
55
+ batch_size: 8000
56
+ valid_batch_size: 4096
57
+ batch_size_multiple: 8
58
+ accum_count: [10]
59
+ accum_steps: [0]
60
+
61
+ # Optimizer & Compute
62
+ compute_dtype: "fp16"
63
+ optim: "adamw"
64
+ #use_amp: False
65
+ learning_rate: 2.0
66
+ warmup_steps: 4000
67
+ decay_method: "noam"
68
+ adam_beta2: 0.998
69
+
70
+ # Data loading
71
+ bucket_size: 128000
72
+ num_workers: 4
73
+ prefetch_factor: 32
74
+
75
+ # Hyperparams
76
+ dropout_steps: [0]
77
+ dropout: [0.1]
78
+ attention_dropout: [0.1]
79
+ max_grad_norm: 0
80
+ label_smoothing: 0.1
81
+ average_decay: 0.0001
82
+ param_init_method: xavier_uniform
83
+ normalization: "tokens"
84
+
85
+ model:
86
+ architecture: "transformer"
87
+ share_embeddings: false
88
+ share_decoder_embeddings: false
89
+ hidden_size: 1024
90
+ encoder:
91
+ layers: 8
92
+ decoder:
93
+ layers: 2
94
+ heads: 8
95
+ transformer_ff: 4096
96
+ embeddings:
97
+ word_vec_size: 1024
98
+ position_encoding_type: "SinusoidalInterleaved"
99
+
eole-model/config.json ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "seed": 1234,
3
+ "tensorboard": true,
4
+ "src_vocab": "en.eole.vocab",
5
+ "tensorboard_log_dir_dated": "tensorboard/May-01_21-37-35",
6
+ "src_vocab_size": 20000,
7
+ "report_every": 100,
8
+ "valid_metrics": [
9
+ "BLEU"
10
+ ],
11
+ "transforms": [
12
+ "sentencepiece",
13
+ "filtertoolong"
14
+ ],
15
+ "tensorboard_log_dir": "tensorboard",
16
+ "vocab_size_multiple": 8,
17
+ "save_data": "data",
18
+ "tgt_vocab_size": 20000,
19
+ "overwrite": true,
20
+ "tgt_vocab": "es.eole.vocab",
21
+ "share_vocab": false,
22
+ "n_sample": 0,
23
+ "training": {
24
+ "warmup_steps": 4000,
25
+ "optim": "adamw",
26
+ "adam_beta2": 0.998,
27
+ "batch_size_multiple": 8,
28
+ "bucket_size": 128000,
29
+ "world_size": 1,
30
+ "batch_type": "tokens",
31
+ "dropout_steps": [
32
+ 0
33
+ ],
34
+ "normalization": "tokens",
35
+ "valid_steps": 5000,
36
+ "keep_checkpoint": 4,
37
+ "learning_rate": 2.0,
38
+ "prefetch_factor": 32,
39
+ "gpu_ranks": [
40
+ 0
41
+ ],
42
+ "model_path": "quickmt-en-es-eole-model",
43
+ "dropout": [
44
+ 0.1
45
+ ],
46
+ "average_decay": 0.0001,
47
+ "attention_dropout": [
48
+ 0.1
49
+ ],
50
+ "batch_size": 8000,
51
+ "decay_method": "noam",
52
+ "accum_steps": [
53
+ 0
54
+ ],
55
+ "compute_dtype": "torch.float16",
56
+ "accum_count": [
57
+ 10
58
+ ],
59
+ "label_smoothing": 0.1,
60
+ "param_init_method": "xavier_uniform",
61
+ "save_checkpoint_steps": 5000,
62
+ "valid_batch_size": 4096,
63
+ "max_grad_norm": 0.0,
64
+ "train_steps": 100000,
65
+ "num_workers": 0
66
+ },
67
+ "model": {
68
+ "position_encoding_type": "SinusoidalInterleaved",
69
+ "hidden_size": 1024,
70
+ "transformer_ff": 4096,
71
+ "share_embeddings": false,
72
+ "share_decoder_embeddings": false,
73
+ "architecture": "transformer",
74
+ "heads": 8,
75
+ "embeddings": {
76
+ "position_encoding_type": "SinusoidalInterleaved",
77
+ "tgt_word_vec_size": 1024,
78
+ "word_vec_size": 1024,
79
+ "src_word_vec_size": 1024
80
+ },
81
+ "decoder": {
82
+ "position_encoding_type": "SinusoidalInterleaved",
83
+ "hidden_size": 1024,
84
+ "transformer_ff": 4096,
85
+ "n_positions": null,
86
+ "tgt_word_vec_size": 1024,
87
+ "decoder_type": "transformer",
88
+ "layers": 2,
89
+ "heads": 8
90
+ },
91
+ "encoder": {
92
+ "position_encoding_type": "SinusoidalInterleaved",
93
+ "hidden_size": 1024,
94
+ "transformer_ff": 4096,
95
+ "n_positions": null,
96
+ "src_word_vec_size": 1024,
97
+ "encoder_type": "transformer",
98
+ "layers": 8,
99
+ "heads": 8
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}/es.spm.model",
109
+ "src_subword_model": "${MODEL_PATH}/en.spm.model"
110
+ }
111
+ },
112
+ "data": {
113
+ "corpus_1": {
114
+ "path_align": null,
115
+ "transforms": [
116
+ "sentencepiece",
117
+ "filtertoolong"
118
+ ],
119
+ "path_tgt": "train.es",
120
+ "path_src": "train.en"
121
+ },
122
+ "valid": {
123
+ "path_align": null,
124
+ "transforms": [
125
+ "sentencepiece",
126
+ "filtertoolong"
127
+ ],
128
+ "path_tgt": "dev.es",
129
+ "path_src": "dev.en"
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:c26488c6db0bdca05f0e9e8edf43e8bdb4f78fc5c41c51749f88aefa6a1d030b
3
+ size 593820
eole-model/es.spm.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:515603821dd149cb66b99febbe4bbb05b9c7819943621d1f66c28ca2270a47e9
3
+ size 603700
eole-model/model.00.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3b2bd6403da5d52459a8d986d5736ed1744b0211a4856ae45b7fe03c6699d79b
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:a609e71626f9629e7d8cbf76f0961b32f87268e1e4e9548c3ef2de061dece10e
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:c26488c6db0bdca05f0e9e8edf43e8bdb4f78fc5c41c51749f88aefa6a1d030b
3
+ size 593820
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:515603821dd149cb66b99febbe4bbb05b9c7819943621d1f66c28ca2270a47e9
3
+ size 603700