radinplaid commited on
Commit
01e8d90
·
verified ·
1 Parent(s): 9ee41a4

Upload folder using huggingface_hub

Browse files
.ipynb_checkpoints/README-checkpoint.md ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - bn
5
+ tags:
6
+ - translation
7
+ license: cc-by-4.0
8
+ datasets:
9
+ - quickmt/quickmt-train.bn-en
10
+ model-index:
11
+ - name: quickmt-bn-en
12
+ results:
13
+ - task:
14
+ name: Translation ben-eng
15
+ type: translation
16
+ args: ben-eng
17
+ dataset:
18
+ name: flores101-devtest
19
+ type: flores_101
20
+ args: ben_Beng eng_Latn devtest
21
+ metrics:
22
+ - name: BLEU
23
+ type: bleu
24
+ value: 32.91
25
+ - name: CHRF
26
+ type: chrf
27
+ value: 59.69
28
+ - name: COMET
29
+ type: comet
30
+ value: 86.99
31
+ ---
32
+
33
+
34
+ # `quickmt-bn-en` Neural Machine Translation Model
35
+
36
+ `quickmt-bn-en` is a reasonably fast and reasonably accurate neural machine translation model for translation from `bn` 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
+ * Exbented for fast inference to [CTranslate2](https://github.com/OpenNMT/CTranslate2) format
45
+ * Training data: https://huggingface.co/datasets/quickmt/quickmt-train.bn-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-bn-en ./quickmt-bn-en
60
+ ```
61
+
62
+ Finally use the model in python:
63
+
64
+ ```python
65
+ from quickmt imbent Translator
66
+
67
+ # Auto-detects GPU, set to "cpu" to force CPU inference
68
+ t = Translator("./quickmt-bn-en/", device="auto")
69
+
70
+ # Translate - set beam size to 1 for faster speed (but lower quality)
71
+ sample_text = 'হেলিফ্যাক্সে ডালহৌসি বিশ্ববিদ্যালয়ের মেডিসিন বিভাগের প্রফেসর ডঃ ইহুড আর, নোভা স্কটিয়া এবং কানাডিয়ান ডায়াবেটিস এসোসিয়েশনের ক্লিনিক্যাল ও বৈজ্ঞানিক বিভাগের চেয়ার, আগে থেকেই সতর্ক করে দিয়েছিলেন যে গবেষণা এখনও তার শুরুর দিকে রয়েছে।'
72
+
73
+ t(sample_text, beam_size=5)
74
+ ```
75
+
76
+ > 'Dr. Ehud R, professor of medicine at Dalhousie University in Helfax, chair of the clinical and scientific department of Nova Scotia and the Canadian Diabetes Association, warned in advance that the research was 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. Youud Ar, the professor of medicine at Dalhousie University, at Helphax and chair of the clinical and scientific departments at Nova Scotia and the Canadian Diabetes Association, pre-ordered warned the research is still early.'
85
+
86
+ 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`.
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) ("ben_Beng"->"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).
91
+
92
+ | | bleu | chrf2 | comet22 | Time (s) |
93
+ |:---------------------------------|-------:|--------:|----------:|-----------:|
94
+ | quickmt/quickmt-bn-en | 32.91 | 59.69 | 86.99 | 1.37 |
95
+ | Helsink-NLP/opus-mt-bn-en | 17.89 | 45.94 | 78.62 | 3.45 |
96
+ | facebook/nllb-200-distilled-600M | 33.51 | 59.73 | 87.48 | 21.01 |
97
+ | facebook/nllb-200-distilled-1.3B | 36.4 | 62.18 | 88.61 | 36.62 |
98
+ | facebook/m2m100_418M | 23.84 | 52.67 | 82.94 | 20.86 |
99
+ | facebook/m2m100_1.2B | 27.26 | 54.86 | 84.28 | 36.28 |
README.md CHANGED
@@ -1,3 +1,99 @@
1
- ---
2
- license: cc-by-4.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - bn
5
+ tags:
6
+ - translation
7
+ license: cc-by-4.0
8
+ datasets:
9
+ - quickmt/quickmt-train.bn-en
10
+ model-index:
11
+ - name: quickmt-bn-en
12
+ results:
13
+ - task:
14
+ name: Translation ben-eng
15
+ type: translation
16
+ args: ben-eng
17
+ dataset:
18
+ name: flores101-devtest
19
+ type: flores_101
20
+ args: ben_Beng eng_Latn devtest
21
+ metrics:
22
+ - name: BLEU
23
+ type: bleu
24
+ value: 32.91
25
+ - name: CHRF
26
+ type: chrf
27
+ value: 59.69
28
+ - name: COMET
29
+ type: comet
30
+ value: 86.99
31
+ ---
32
+
33
+
34
+ # `quickmt-bn-en` Neural Machine Translation Model
35
+
36
+ `quickmt-bn-en` is a reasonably fast and reasonably accurate neural machine translation model for translation from `bn` 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
+ * Exbented for fast inference to [CTranslate2](https://github.com/OpenNMT/CTranslate2) format
45
+ * Training data: https://huggingface.co/datasets/quickmt/quickmt-train.bn-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-bn-en ./quickmt-bn-en
60
+ ```
61
+
62
+ Finally use the model in python:
63
+
64
+ ```python
65
+ from quickmt imbent Translator
66
+
67
+ # Auto-detects GPU, set to "cpu" to force CPU inference
68
+ t = Translator("./quickmt-bn-en/", device="auto")
69
+
70
+ # Translate - set beam size to 1 for faster speed (but lower quality)
71
+ sample_text = 'হেলিফ্যাক্সে ডালহৌসি বিশ্ববিদ্যালয়ের মেডিসিন বিভাগের প্রফেসর ডঃ ইহুড আর, নোভা স্কটিয়া এবং কানাডিয়ান ডায়াবেটিস এসোসিয়েশনের ক্লিনিক্যাল ও বৈজ্ঞানিক বিভাগের চেয়ার, আগে থেকেই সতর্ক করে দিয়েছিলেন যে গবেষণা এখনও তার শুরুর দিকে রয়েছে।'
72
+
73
+ t(sample_text, beam_size=5)
74
+ ```
75
+
76
+ > 'Dr. Ehud R, professor of medicine at Dalhousie University in Helfax, chair of the clinical and scientific department of Nova Scotia and the Canadian Diabetes Association, warned in advance that the research was 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. Youud Ar, the professor of medicine at Dalhousie University, at Helphax and chair of the clinical and scientific departments at Nova Scotia and the Canadian Diabetes Association, pre-ordered warned the research is still early.'
85
+
86
+ 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`.
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) ("ben_Beng"->"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).
91
+
92
+ | | bleu | chrf2 | comet22 | Time (s) |
93
+ |:---------------------------------|-------:|--------:|----------:|-----------:|
94
+ | quickmt/quickmt-bn-en | 32.91 | 59.69 | 86.99 | 1.37 |
95
+ | Helsink-NLP/opus-mt-bn-en | 17.89 | 45.94 | 78.62 | 3.45 |
96
+ | facebook/nllb-200-distilled-600M | 33.51 | 59.73 | 87.48 | 21.01 |
97
+ | facebook/nllb-200-distilled-1.3B | 36.4 | 62.18 | 88.61 | 36.62 |
98
+ | facebook/m2m100_418M | 23.84 | 52.67 | 82.94 | 20.86 |
99
+ | facebook/m2m100_1.2B | 27.26 | 54.86 | 84.28 | 36.28 |
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: bg.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.bg-en/bg
22
+ # path_tgt: hf://quickmt/quickmt-train.bg-en/en
23
+ # path_sco: hf://quickmt/quickmt-train.bg-en/sco
24
+ path_src: train.bg
25
+ path_tgt: train.en
26
+ valid:
27
+ path_src: dev.bg
28
+ path_tgt: dev.en
29
+
30
+ transforms: [sentencepiece, filtertoolong]
31
+ transforms_configs:
32
+ sentencepiece:
33
+ src_subword_model: "bg.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-bg-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/bg.spm.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c369113cd9a4199de2326aa56b83cdc4d39b2f23b5181b6a180af405f36357fd
3
+ size 768694
eole-model/config.json ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "tgt_vocab_size": 20000,
3
+ "n_sample": 0,
4
+ "src_vocab_size": 20000,
5
+ "valid_metrics": [
6
+ "BLEU"
7
+ ],
8
+ "tgt_vocab": "en.eole.vocab",
9
+ "tensorboard_log_dir": "tensorboard",
10
+ "tensorboard_log_dir_dated": "tensorboard/May-21_06-04-15",
11
+ "seed": 1234,
12
+ "transforms": [
13
+ "sentencepiece",
14
+ "filtertoolong"
15
+ ],
16
+ "overwrite": true,
17
+ "tensorboard": true,
18
+ "src_vocab": "bg.eole.vocab",
19
+ "share_vocab": false,
20
+ "vocab_size_multiple": 8,
21
+ "save_data": "data",
22
+ "report_every": 100,
23
+ "training": {
24
+ "gpu_ranks": [
25
+ 0
26
+ ],
27
+ "batch_size_multiple": 8,
28
+ "world_size": 1,
29
+ "accum_steps": [
30
+ 0
31
+ ],
32
+ "compute_dtype": "torch.float16",
33
+ "num_workers": 0,
34
+ "dropout": [
35
+ 0.1
36
+ ],
37
+ "learning_rate": 2.0,
38
+ "save_checkpoint_steps": 5000,
39
+ "max_grad_norm": 0.0,
40
+ "valid_batch_size": 4096,
41
+ "batch_size": 8000,
42
+ "train_steps": 100000,
43
+ "batch_type": "tokens",
44
+ "average_decay": 0.0001,
45
+ "prefetch_factor": 32,
46
+ "accum_count": [
47
+ 10
48
+ ],
49
+ "model_path": "quickmt-bg-en-eole-model",
50
+ "valid_steps": 5000,
51
+ "optim": "adamw",
52
+ "attention_dropout": [
53
+ 0.1
54
+ ],
55
+ "label_smoothing": 0.1,
56
+ "warmup_steps": 4000,
57
+ "dropout_steps": [
58
+ 0
59
+ ],
60
+ "normalization": "tokens",
61
+ "bucket_size": 128000,
62
+ "keep_checkpoint": 4,
63
+ "decay_method": "noam",
64
+ "adam_beta2": 0.998,
65
+ "param_init_method": "xavier_uniform"
66
+ },
67
+ "transforms_configs": {
68
+ "filtertoolong": {
69
+ "tgt_seq_length": 256,
70
+ "src_seq_length": 256
71
+ },
72
+ "sentencepiece": {
73
+ "tgt_subword_model": "${MODEL_PATH}/en.spm.model",
74
+ "src_subword_model": "${MODEL_PATH}/bg.spm.model"
75
+ }
76
+ },
77
+ "data": {
78
+ "corpus_1": {
79
+ "path_align": null,
80
+ "transforms": [
81
+ "sentencepiece",
82
+ "filtertoolong"
83
+ ],
84
+ "path_tgt": "train.en",
85
+ "path_src": "train.bg"
86
+ },
87
+ "valid": {
88
+ "path_align": null,
89
+ "transforms": [
90
+ "sentencepiece",
91
+ "filtertoolong"
92
+ ],
93
+ "path_tgt": "dev.en",
94
+ "path_src": "dev.bg"
95
+ }
96
+ },
97
+ "model": {
98
+ "transformer_ff": 4096,
99
+ "architecture": "transformer",
100
+ "heads": 8,
101
+ "share_decoder_embeddings": false,
102
+ "share_embeddings": false,
103
+ "position_encoding_type": "SinusoidalInterleaved",
104
+ "hidden_size": 1024,
105
+ "decoder": {
106
+ "decoder_type": "transformer",
107
+ "layers": 2,
108
+ "transformer_ff": 4096,
109
+ "heads": 8,
110
+ "tgt_word_vec_size": 1024,
111
+ "n_positions": null,
112
+ "position_encoding_type": "SinusoidalInterleaved",
113
+ "hidden_size": 1024
114
+ },
115
+ "encoder": {
116
+ "layers": 8,
117
+ "transformer_ff": 4096,
118
+ "heads": 8,
119
+ "src_word_vec_size": 1024,
120
+ "encoder_type": "transformer",
121
+ "n_positions": null,
122
+ "position_encoding_type": "SinusoidalInterleaved",
123
+ "hidden_size": 1024
124
+ },
125
+ "embeddings": {
126
+ "word_vec_size": 1024,
127
+ "src_word_vec_size": 1024,
128
+ "position_encoding_type": "SinusoidalInterleaved",
129
+ "tgt_word_vec_size": 1024
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:43a755c834037d2ae49fbf18450da93ebd81f60be9b9b27f26480098c372e235
3
+ size 587529
eole-model/model.00.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8d2dd3e4eeda431493fdbb403c08b440e79919a5a731481f8afc4e95a8ea690c
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:96587c29434faa11721b976c53c703221c8711c9e867e44250236b37820ca1d6
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:c369113cd9a4199de2326aa56b83cdc4d39b2f23b5181b6a180af405f36357fd
3
+ size 768694
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:43a755c834037d2ae49fbf18450da93ebd81f60be9b9b27f26480098c372e235
3
+ size 587529