radinplaid commited on
Commit
99b3e46
·
verified ·
1 Parent(s): 7d6b471

Upload folder using huggingface_hub

Browse files
.ipynb_checkpoints/README-checkpoint.md ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - hi
5
+ tags:
6
+ - translation
7
+ license: cc-by-4.0
8
+ datasets:
9
+ - quickmt/quickmt-train.hi-en
10
+ model-index:
11
+ - name: quickmt-hi-en
12
+ results:
13
+ - task:
14
+ name: Translation hin-eng
15
+ type: translation
16
+ args: hin-eng
17
+ dataset:
18
+ name: flores101-devtest
19
+ type: flores_101
20
+ args: hin_Deva eng_Latn devtest
21
+ metrics:
22
+ - name: CHRF
23
+ type: chrf
24
+ value: 65.04
25
+ - name: BLEU
26
+ type: bleu
27
+ value: 39.9
28
+ - name: COMET
29
+ type: comet
30
+ value: 88.77
31
+ ---
32
+
33
+
34
+ # `quickmt-hi-en` Neural Machine Translation Model
35
+
36
+ `quickmt-hi-en` is a reasonably fast and reasonably accurate neural machine translation model for translation from `hi` into `en`.
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
+ * 50k joint Sentencepiece vocabulary
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
+ ## Usage with `quickmt`
50
+
51
+ You must install the Nvidia cuda toolkit first, if you want to do GPU inference.
52
+
53
+ Next, install the `quickmt` python library and download the model:
54
+
55
+ ```bash
56
+ git clone https://github.com/quickmt/quickmt.git
57
+ pip install ./quickmt/
58
+
59
+ quickmt-model-download quickmt/quickmt-hi-en ./quickmt-hi-en
60
+ ```
61
+
62
+ Finally use the model in python:
63
+
64
+ ```python
65
+ from quickmt import Translator
66
+
67
+ # Auto-detects GPU, set to "cpu" to force CPU inference
68
+ t = Translator("./quickmt-hi-en/", device="auto")
69
+
70
+ # Translate - set beam size to 1 for faster speed (but lower quality)
71
+ sample_text = 'डॉ. एहुड उर, नोवा स्कोटिया के हैलिफ़ैक्स में डलहौज़ी विश्वविद्यालय में चिकित्सा के प्रोफ़ेसर और कनाडाई डायबिटीज़ एसोसिएशन के नैदानिक \u200b\u200bऔर वैज्ञानिक विभाग के अध्यक्ष ने आगाह किया कि शोध अभी भी अपने शुरुआती दिनों में है.'
72
+ t(sample_text, beam_size=5)
73
+
74
+ > 'On the other hand, Dr Ehud ur, professor of medicine at Dalhousie University in Halifax, Nova Scotia and chairman of the clinical and scientific department of the Canadian Diabetes Association, cautioned that the research is still in its early days.'
75
+
76
+ # Get alternative translations by sampling
77
+ # You can pass any cTranslate2 `translate_batch` arguments
78
+ t([sample_text], sampling_temperature=1.2, beam_size=1, sampling_topk=50, sampling_topp=0.9)
79
+
80
+ > 'A group of young men Ehud ur, professor of medicine at Dalhousie University in Halifax, Nova Scotia, and president of the Diagnostics and Scientific Department of the Canadian Diabetes Association warned that the research is still in its early days.'
81
+ ```
82
+
83
+ 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`.
84
+
85
+
86
+ ## Metrics
87
+
88
+ `bleu` and `chrf2` are calculated with [sacrebleu](https://github.com/mjpost/sacrebleu) on the [Flores200 `devtest` test set](https://huggingface.co/datasets/facebook/flores) ("hin_Deva"->"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).
89
+
90
+ ## it -> en flores-devtest metrics
91
+
92
+ | model | bleu | chrf2 | comet22 | Time (s) |
93
+ |:---------------------------------|-------:|--------:|----------:|-----------:|
94
+ | quickmt/quickmt-hi-en | 39.9 | 65.04 | 88.77 | 1.14 |
95
+ | Helsink-NLP/opus-mt-hi-en | 18.83 | 45.9 | 75.81 | 4.38 |
96
+ | facebook/nllb-200-distilled-600M | 38.8 | 64.29 | 88.87 | 22.49 |
97
+ | facebook/nllb-200-distilled-1.3B | 41.71 | 66.67 | 89.69 | 38.91 |
98
+ | facebook/m2m100_418M | 29.81 | 57.66 | 85 | 19.65 |
99
+ | facebook/m2m100_1.2B | 33.79 | 60.21 | 86.3 | 38.33 |
100
+
101
+
102
+ `quickmt-hi-en` is the fastest and second highest quality next to `nllb-200-distilled-1.3B` (which has a non-commercial license).
README.md CHANGED
@@ -1,3 +1,102 @@
1
- ---
2
- license: cc-by-4.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - hi
5
+ tags:
6
+ - translation
7
+ license: cc-by-4.0
8
+ datasets:
9
+ - quickmt/quickmt-train.hi-en
10
+ model-index:
11
+ - name: quickmt-hi-en
12
+ results:
13
+ - task:
14
+ name: Translation hin-eng
15
+ type: translation
16
+ args: hin-eng
17
+ dataset:
18
+ name: flores101-devtest
19
+ type: flores_101
20
+ args: hin_Deva eng_Latn devtest
21
+ metrics:
22
+ - name: CHRF
23
+ type: chrf
24
+ value: 65.04
25
+ - name: BLEU
26
+ type: bleu
27
+ value: 39.9
28
+ - name: COMET
29
+ type: comet
30
+ value: 88.77
31
+ ---
32
+
33
+
34
+ # `quickmt-hi-en` Neural Machine Translation Model
35
+
36
+ `quickmt-hi-en` is a reasonably fast and reasonably accurate neural machine translation model for translation from `hi` into `en`.
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
+ * 50k joint Sentencepiece vocabulary
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
+ ## Usage with `quickmt`
50
+
51
+ You must install the Nvidia cuda toolkit first, if you want to do GPU inference.
52
+
53
+ Next, install the `quickmt` python library and download the model:
54
+
55
+ ```bash
56
+ git clone https://github.com/quickmt/quickmt.git
57
+ pip install ./quickmt/
58
+
59
+ quickmt-model-download quickmt/quickmt-hi-en ./quickmt-hi-en
60
+ ```
61
+
62
+ Finally use the model in python:
63
+
64
+ ```python
65
+ from quickmt import Translator
66
+
67
+ # Auto-detects GPU, set to "cpu" to force CPU inference
68
+ t = Translator("./quickmt-hi-en/", device="auto")
69
+
70
+ # Translate - set beam size to 1 for faster speed (but lower quality)
71
+ sample_text = 'डॉ. एहुड उर, नोवा स्कोटिया के हैलिफ़ैक्स में डलहौज़ी विश्वविद्यालय में चिकित्सा के प्रोफ़ेसर और कनाडाई डायबिटीज़ एसोसिएशन के नैदानिक \u200b\u200bऔर वैज्ञानिक विभाग के अध्यक्ष ने आगाह किया कि शोध अभी भी अपने शुरुआती दिनों में है.'
72
+ t(sample_text, beam_size=5)
73
+
74
+ > 'On the other hand, Dr Ehud ur, professor of medicine at Dalhousie University in Halifax, Nova Scotia and chairman of the clinical and scientific department of the Canadian Diabetes Association, cautioned that the research is still in its early days.'
75
+
76
+ # Get alternative translations by sampling
77
+ # You can pass any cTranslate2 `translate_batch` arguments
78
+ t([sample_text], sampling_temperature=1.2, beam_size=1, sampling_topk=50, sampling_topp=0.9)
79
+
80
+ > 'A group of young men Ehud ur, professor of medicine at Dalhousie University in Halifax, Nova Scotia, and president of the Diagnostics and Scientific Department of the Canadian Diabetes Association warned that the research is still in its early days.'
81
+ ```
82
+
83
+ 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`.
84
+
85
+
86
+ ## Metrics
87
+
88
+ `bleu` and `chrf2` are calculated with [sacrebleu](https://github.com/mjpost/sacrebleu) on the [Flores200 `devtest` test set](https://huggingface.co/datasets/facebook/flores) ("hin_Deva"->"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).
89
+
90
+ ## it -> en flores-devtest metrics
91
+
92
+ | model | bleu | chrf2 | comet22 | Time (s) |
93
+ |:---------------------------------|-------:|--------:|----------:|-----------:|
94
+ | quickmt/quickmt-hi-en | 39.9 | 65.04 | 88.77 | 1.14 |
95
+ | Helsink-NLP/opus-mt-hi-en | 18.83 | 45.9 | 75.81 | 4.38 |
96
+ | facebook/nllb-200-distilled-600M | 38.8 | 64.29 | 88.87 | 22.49 |
97
+ | facebook/nllb-200-distilled-1.3B | 41.71 | 66.67 | 89.69 | 38.91 |
98
+ | facebook/m2m100_418M | 29.81 | 57.66 | 85 | 19.65 |
99
+ | facebook/m2m100_1.2B | 33.79 | 60.21 | 86.3 | 38.33 |
100
+
101
+
102
+ `quickmt-hi-en` is the fastest and second highest quality next to `nllb-200-distilled-1.3B` (which has a non-commercial license).
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: hi.eole.vocab
12
+ tgt_vocab: en.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.hi-en/hi
22
+ # path_tgt: hf://quickmt/quickmt-train.hi-en/en
23
+ # path_sco: hf://quickmt/quickmt-train.hi-en/sco
24
+ path_src: train.hi
25
+ path_tgt: train.en
26
+ valid:
27
+ path_src: dev.hi
28
+ path_tgt: dev.en
29
+
30
+ transforms: [sentencepiece, filtertoolong]
31
+ transforms_configs:
32
+ sentencepiece:
33
+ src_subword_model: "hi.spm.model"
34
+ tgt_subword_model: "en.spm.model"
35
+ filtertoolong:
36
+ src_seq_length: 256
37
+ tgt_seq_length: 256
38
+
39
+ training:
40
+ # Run configuration
41
+ model_path: quickmt-hi-en-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
+ #use_amp: False
64
+ learning_rate: 2.0
65
+ warmup_steps: 4000
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: false
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
+ "transforms": [
3
+ "sentencepiece",
4
+ "filtertoolong"
5
+ ],
6
+ "src_vocab": "hi.eole.vocab",
7
+ "tgt_vocab": "en.eole.vocab",
8
+ "share_vocab": false,
9
+ "tensorboard_log_dir": "tensorboard",
10
+ "src_vocab_size": 20000,
11
+ "report_every": 100,
12
+ "vocab_size_multiple": 8,
13
+ "tgt_vocab_size": 20000,
14
+ "seed": 1234,
15
+ "tensorboard": true,
16
+ "n_sample": 0,
17
+ "overwrite": true,
18
+ "valid_metrics": [
19
+ "BLEU"
20
+ ],
21
+ "tensorboard_log_dir_dated": "tensorboard/Apr-24_17-46-43",
22
+ "save_data": "data",
23
+ "training": {
24
+ "average_decay": 0.0001,
25
+ "normalization": "tokens",
26
+ "save_checkpoint_steps": 5000,
27
+ "accum_steps": [
28
+ 0
29
+ ],
30
+ "warmup_steps": 4000,
31
+ "compute_dtype": "torch.float16",
32
+ "batch_size": 8000,
33
+ "adam_beta2": 0.998,
34
+ "batch_type": "tokens",
35
+ "dropout": [
36
+ 0.1
37
+ ],
38
+ "max_grad_norm": 0.0,
39
+ "valid_batch_size": 4096,
40
+ "attention_dropout": [
41
+ 0.1
42
+ ],
43
+ "param_init_method": "xavier_uniform",
44
+ "accum_count": [
45
+ 10
46
+ ],
47
+ "bucket_size": 128000,
48
+ "learning_rate": 2.0,
49
+ "num_workers": 0,
50
+ "gpu_ranks": [
51
+ 0
52
+ ],
53
+ "valid_steps": 5000,
54
+ "decay_method": "noam",
55
+ "keep_checkpoint": 4,
56
+ "train_steps": 100000,
57
+ "batch_size_multiple": 8,
58
+ "dropout_steps": [
59
+ 0
60
+ ],
61
+ "label_smoothing": 0.1,
62
+ "world_size": 1,
63
+ "optim": "adamw",
64
+ "prefetch_factor": 32,
65
+ "model_path": "quickmt-hi-en-eole-model"
66
+ },
67
+ "model": {
68
+ "position_encoding_type": "SinusoidalInterleaved",
69
+ "heads": 8,
70
+ "share_decoder_embeddings": false,
71
+ "transformer_ff": 4096,
72
+ "share_embeddings": false,
73
+ "architecture": "transformer",
74
+ "hidden_size": 1024,
75
+ "encoder": {
76
+ "src_word_vec_size": 1024,
77
+ "position_encoding_type": "SinusoidalInterleaved",
78
+ "heads": 8,
79
+ "transformer_ff": 4096,
80
+ "n_positions": null,
81
+ "encoder_type": "transformer",
82
+ "hidden_size": 1024,
83
+ "layers": 8
84
+ },
85
+ "embeddings": {
86
+ "tgt_word_vec_size": 1024,
87
+ "src_word_vec_size": 1024,
88
+ "word_vec_size": 1024,
89
+ "position_encoding_type": "SinusoidalInterleaved"
90
+ },
91
+ "decoder": {
92
+ "position_encoding_type": "SinusoidalInterleaved",
93
+ "tgt_word_vec_size": 1024,
94
+ "heads": 8,
95
+ "transformer_ff": 4096,
96
+ "n_positions": null,
97
+ "decoder_type": "transformer",
98
+ "hidden_size": 1024,
99
+ "layers": 2
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}/hi.spm.model"
110
+ }
111
+ },
112
+ "data": {
113
+ "corpus_1": {
114
+ "transforms": [
115
+ "sentencepiece",
116
+ "filtertoolong"
117
+ ],
118
+ "path_align": null,
119
+ "path_src": "train.hi",
120
+ "path_tgt": "train.en"
121
+ },
122
+ "valid": {
123
+ "transforms": [
124
+ "sentencepiece",
125
+ "filtertoolong"
126
+ ],
127
+ "path_align": null,
128
+ "path_src": "dev.hi",
129
+ "path_tgt": "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:134b26724a53a8f16871e33194f99d31a8729550f6dcfba80ef947516c8f0c04
3
+ size 586288
eole-model/hi.spm.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5bf816522cc2183f2b179621f1c791ac610aa01a348f286ba7fe1945f26a3171
3
+ size 725360
eole-model/model.00.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d2a1c824cf6fa9bd17114ab81193add60a63034936fdc4d4c6900d7a0635507a
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:161616ff429b3c614b7c073cb396d3bfe2fc9eaaa78e98a3a68f180d797ee645
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:5bf816522cc2183f2b179621f1c791ac610aa01a348f286ba7fe1945f26a3171
3
+ size 725360
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:134b26724a53a8f16871e33194f99d31a8729550f6dcfba80ef947516c8f0c04
3
+ size 586288