radinplaid commited on
Commit
7aebeee
·
verified ·
1 Parent(s): 74d00bf

Upload folder using huggingface_hub

Browse files
.ipynb_checkpoints/README-checkpoint.md ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - lv
5
+ tags:
6
+ - translation
7
+ license: cc-by-4.0
8
+ datasets:
9
+ - quickmt/quickmt-train.lv-en
10
+ model-index:
11
+ - name: quickmt-en-lv
12
+ results:
13
+ - task:
14
+ name: Translation eng-lav
15
+ type: translation
16
+ args: eng-lav
17
+ dataset:
18
+ name: flores101-devtest
19
+ type: flores_101
20
+ args: eng_Latn lvs_Latn devtest
21
+ metrics:
22
+ - name: BLEU
23
+ type: bleu
24
+ value: 35.3
25
+ - name: CHRF
26
+ type: chrf
27
+ value: 62.91
28
+ - name: COMET
29
+ type: comet
30
+ value: 86.98
31
+ ---
32
+
33
+
34
+ # `quickmt-en-lv` Neural Machine Translation Model
35
+
36
+ `quickmt-en-lv` is a reasonably fast and reasonably accurate neural machine translation model for translation from `en` into `lv`.
37
+
38
+
39
+ ## Model Information
40
+
41
+ * Trained using [`eole`](https://github.com/eole-nlp/eole)
42
+ * 200M parameter transformer 'big' with 8 encoder layers and 2 decoder layers
43
+ * 32k 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.lv-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-lv ./quickmt-en-lv
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-lv/", 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
+
76
+ > 'Dr. Ehud Uhr, Professor of Medicine at Dalhuzy University in Halifax, Nova Scotia, and Chair of the Clinical and Scientific Department of the Canadian Diabetes Association, warned that the study is still in its early stages.'
77
+
78
+ ```python
79
+ # Get alternative translations by sampling
80
+ # You can pass any cTranslate2 `translate_batch` arguments
81
+ t([sample_text], sampling_temperature=1.2, beam_size=1, sampling_topk=50, sampling_topp=0.9)
82
+ ```
83
+
84
+ > 'Dr. Ehud Uurs, a professor of medicine at Dalhuzy University, Halifax, Nova Scotia, and chair of the clinical and scientific department of the Canadian Diabeta Association warned that the research was still under the start.'
85
+
86
+
87
+ 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`.
88
+
89
+
90
+ ## Metrics
91
+
92
+ `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"->"lvs_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 with a larger batch size).
93
+
94
+ | | bleu | chrf2 | comet22 | Time (s) |
95
+ |:----------------------------------|-------:|--------:|----------:|-----------:|
96
+ | quickmt/quickmt-en-lv | 31.46 | 60.49 | 86.22 | 1.39 |
97
+ | Helsinki-NLP/opus-mt-tc-big-en-lv | 30.8 | 60.11 | 86.00 | 3.43 |
98
+ | facebook/nllb-200-distilled-600M | 18.9 | 49.28 | 79.11 | 24.48 |
99
+ | facebook/nllb-200-distilled-1.3B | 23.63 | 53.56 | 86.08 | 49.36 |
100
+ | facebook/m2m100_418M | 22.11 | 52.52 | 81.47 | 22.18 |
101
+ | facebook/m2m100_1.2B | 28.75 | 58.55 | 87.66 | 42.55 |
102
+
README.md CHANGED
@@ -1,3 +1,102 @@
1
- ---
2
- license: cc-by-4.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - lv
5
+ tags:
6
+ - translation
7
+ license: cc-by-4.0
8
+ datasets:
9
+ - quickmt/quickmt-train.lv-en
10
+ model-index:
11
+ - name: quickmt-en-lv
12
+ results:
13
+ - task:
14
+ name: Translation eng-lav
15
+ type: translation
16
+ args: eng-lav
17
+ dataset:
18
+ name: flores101-devtest
19
+ type: flores_101
20
+ args: eng_Latn lvs_Latn devtest
21
+ metrics:
22
+ - name: BLEU
23
+ type: bleu
24
+ value: 35.3
25
+ - name: CHRF
26
+ type: chrf
27
+ value: 62.91
28
+ - name: COMET
29
+ type: comet
30
+ value: 86.98
31
+ ---
32
+
33
+
34
+ # `quickmt-en-lv` Neural Machine Translation Model
35
+
36
+ `quickmt-en-lv` is a reasonably fast and reasonably accurate neural machine translation model for translation from `en` into `lv`.
37
+
38
+
39
+ ## Model Information
40
+
41
+ * Trained using [`eole`](https://github.com/eole-nlp/eole)
42
+ * 200M parameter transformer 'big' with 8 encoder layers and 2 decoder layers
43
+ * 32k 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.lv-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-lv ./quickmt-en-lv
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-lv/", 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
+
76
+ > 'Dr. Ehud Uhr, Professor of Medicine at Dalhuzy University in Halifax, Nova Scotia, and Chair of the Clinical and Scientific Department of the Canadian Diabetes Association, warned that the study is still in its early stages.'
77
+
78
+ ```python
79
+ # Get alternative translations by sampling
80
+ # You can pass any cTranslate2 `translate_batch` arguments
81
+ t([sample_text], sampling_temperature=1.2, beam_size=1, sampling_topk=50, sampling_topp=0.9)
82
+ ```
83
+
84
+ > 'Dr. Ehud Uurs, a professor of medicine at Dalhuzy University, Halifax, Nova Scotia, and chair of the clinical and scientific department of the Canadian Diabeta Association warned that the research was still under the start.'
85
+
86
+
87
+ 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`.
88
+
89
+
90
+ ## Metrics
91
+
92
+ `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"->"lvs_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 with a larger batch size).
93
+
94
+ | | bleu | chrf2 | comet22 | Time (s) |
95
+ |:----------------------------------|-------:|--------:|----------:|-----------:|
96
+ | quickmt/quickmt-en-lv | 31.46 | 60.49 | 86.22 | 1.39 |
97
+ | Helsinki-NLP/opus-mt-tc-big-en-lv | 30.8 | 60.11 | 86.00 | 3.43 |
98
+ | facebook/nllb-200-distilled-600M | 18.9 | 49.28 | 79.11 | 24.48 |
99
+ | facebook/nllb-200-distilled-1.3B | 23.63 | 53.56 | 86.08 | 49.36 |
100
+ | facebook/m2m100_418M | 22.11 | 52.52 | 81.47 | 22.18 |
101
+ | facebook/m2m100_1.2B | 28.75 | 58.55 | 87.66 | 42.55 |
102
+
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,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: lv.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.lv-en/en
22
+ # path_tgt: hf://quickmt/quickmt-train.lv-en/lv
23
+ # path_sco: hf://quickmt/quickmt-train.lv-en/sco
24
+ path_src: train.en
25
+ path_tgt: train.lv
26
+ valid:
27
+ path_src: valid.en
28
+ path_tgt: valid.lv
29
+
30
+ transforms: [sentencepiece, filtertoolong]
31
+ transforms_configs:
32
+ sentencepiece:
33
+ src_subword_model: "en.spm.model"
34
+ tgt_subword_model: "lv.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-lv-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: 6000
55
+ valid_batch_size: 2048
56
+ batch_size_multiple: 8
57
+ accum_count: [15]
58
+ accum_steps: [0]
59
+
60
+ # Optimizer & Compute
61
+ compute_dtype: "fp16"
62
+ optim: "adamw"
63
+ #use_amp: False
64
+ learning_rate: 2.0
65
+ warmup_steps: 2000
66
+ decay_method: "noam"
67
+ adam_beta2: 0.998
68
+
69
+ # Data loading
70
+ bucket_size: 128000
71
+ num_workers: 4
72
+ prefetch_factor: 32
73
+
74
+ # Hyperparams
75
+ dropout_steps: [0]
76
+ dropout: [0.1]
77
+ attention_dropout: [0.1]
78
+ max_grad_norm: 0
79
+ label_smoothing: 0.1
80
+ average_decay: 0.0001
81
+ param_init_method: xavier_uniform
82
+ normalization: "tokens"
83
+
84
+ model:
85
+ architecture: "transformer"
86
+ share_embeddings: false
87
+ share_decoder_embeddings: true
88
+ hidden_size: 1024
89
+ encoder:
90
+ layers: 8
91
+ decoder:
92
+ layers: 2
93
+ heads: 8
94
+ transformer_ff: 4096
95
+ embeddings:
96
+ word_vec_size: 1024
97
+ position_encoding_type: "SinusoidalInterleaved"
98
+
eole-model/config.json ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "src_vocab": "en.eole.vocab",
3
+ "seed": 1234,
4
+ "tensorboard_log_dir_dated": "tensorboard/Oct-02_06-26-30",
5
+ "save_data": "data",
6
+ "valid_metrics": [
7
+ "BLEU"
8
+ ],
9
+ "tensorboard_log_dir": "tensorboard",
10
+ "tgt_vocab": "lv.eole.vocab",
11
+ "n_sample": 0,
12
+ "src_vocab_size": 32000,
13
+ "share_vocab": false,
14
+ "report_every": 100,
15
+ "tensorboard": true,
16
+ "transforms": [
17
+ "sentencepiece",
18
+ "filtertoolong"
19
+ ],
20
+ "tgt_vocab_size": 32000,
21
+ "vocab_size_multiple": 8,
22
+ "overwrite": true,
23
+ "training": {
24
+ "num_workers": 0,
25
+ "keep_checkpoint": 4,
26
+ "learning_rate": 2.0,
27
+ "optim": "adamw",
28
+ "valid_batch_size": 2048,
29
+ "gpu_ranks": [
30
+ 0
31
+ ],
32
+ "train_steps": 100000,
33
+ "param_init_method": "xavier_uniform",
34
+ "batch_size": 6000,
35
+ "batch_type": "tokens",
36
+ "valid_steps": 5000,
37
+ "accum_steps": [
38
+ 0
39
+ ],
40
+ "average_decay": 0.0001,
41
+ "accum_count": [
42
+ 15
43
+ ],
44
+ "decay_method": "noam",
45
+ "world_size": 1,
46
+ "model_path": "quickmt-en-lv-eole-model",
47
+ "normalization": "tokens",
48
+ "dropout_steps": [
49
+ 0
50
+ ],
51
+ "bucket_size": 128000,
52
+ "max_grad_norm": 0.0,
53
+ "save_checkpoint_steps": 5000,
54
+ "compute_dtype": "torch.float16",
55
+ "adam_beta2": 0.998,
56
+ "dropout": [
57
+ 0.1
58
+ ],
59
+ "label_smoothing": 0.1,
60
+ "attention_dropout": [
61
+ 0.1
62
+ ],
63
+ "batch_size_multiple": 8,
64
+ "prefetch_factor": 32,
65
+ "warmup_steps": 2000
66
+ },
67
+ "transforms_configs": {
68
+ "sentencepiece": {
69
+ "tgt_subword_model": "${MODEL_PATH}/lv.spm.model",
70
+ "src_subword_model": "${MODEL_PATH}/en.spm.model"
71
+ },
72
+ "filtertoolong": {
73
+ "src_seq_length": 256,
74
+ "tgt_seq_length": 256
75
+ }
76
+ },
77
+ "model": {
78
+ "share_embeddings": false,
79
+ "heads": 8,
80
+ "share_decoder_embeddings": true,
81
+ "transformer_ff": 4096,
82
+ "architecture": "transformer",
83
+ "position_encoding_type": "SinusoidalInterleaved",
84
+ "hidden_size": 1024,
85
+ "encoder": {
86
+ "heads": 8,
87
+ "layers": 8,
88
+ "n_positions": null,
89
+ "transformer_ff": 4096,
90
+ "encoder_type": "transformer",
91
+ "src_word_vec_size": 1024,
92
+ "position_encoding_type": "SinusoidalInterleaved",
93
+ "hidden_size": 1024
94
+ },
95
+ "embeddings": {
96
+ "word_vec_size": 1024,
97
+ "position_encoding_type": "SinusoidalInterleaved",
98
+ "tgt_word_vec_size": 1024,
99
+ "src_word_vec_size": 1024
100
+ },
101
+ "decoder": {
102
+ "heads": 8,
103
+ "layers": 2,
104
+ "decoder_type": "transformer",
105
+ "tgt_word_vec_size": 1024,
106
+ "n_positions": null,
107
+ "transformer_ff": 4096,
108
+ "position_encoding_type": "SinusoidalInterleaved",
109
+ "hidden_size": 1024
110
+ }
111
+ },
112
+ "data": {
113
+ "corpus_1": {
114
+ "transforms": [
115
+ "sentencepiece",
116
+ "filtertoolong"
117
+ ],
118
+ "path_align": null,
119
+ "path_src": "train.en",
120
+ "path_tgt": "train.lv"
121
+ },
122
+ "valid": {
123
+ "transforms": [
124
+ "sentencepiece",
125
+ "filtertoolong"
126
+ ],
127
+ "path_align": null,
128
+ "path_src": "valid.en",
129
+ "path_tgt": "valid.lv"
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:c593549fdec899677e1dff303ef1312d4b0ad31d09c83adb9e63ca2ec75cccfd
3
+ size 802099
eole-model/lv.spm.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ae6b5e8281042f96b731bed56a9eea36a37c72f274877d92e80ddc91477541cd
3
+ size 845062
eole-model/model.00.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:581ddbf0cb97a7f6d02dab25398ebdcf55f30a5523b7bde3ef3e0fbdcc5e3670
3
+ size 840314816
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:de3b29a1f9572d73814bd62677ba067b8c808513df337d574eab80a8efb4a1aa
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:c593549fdec899677e1dff303ef1312d4b0ad31d09c83adb9e63ca2ec75cccfd
3
+ size 802099
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:ae6b5e8281042f96b731bed56a9eea36a37c72f274877d92e80ddc91477541cd
3
+ size 845062