carlosep93 commited on
Commit
45fbd28
1 Parent(s): 5961534

Initial Commit

Browse files
Files changed (4) hide show
  1. README.md +167 -1
  2. model.bin +3 -0
  3. shared_vocabulary.txt +0 -0
  4. spm.model +3 -0
README.md CHANGED
@@ -1,3 +1,169 @@
1
  ---
2
- license: apache-2.0
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ license: apache-2.0
3
  ---
4
+ ## PlanTL Project's Spanish-Galician machine translation model
5
+
6
+ ## Table of Contents
7
+ - [Model Description](#model-description)
8
+ - [Intended Uses and Limitations](#intended-use)
9
+ - [How to Use](#how-to-use)
10
+ - [Training](#training)
11
+ - [Training data](#training-data)
12
+ - [Training procedure](#training-procedure)
13
+ - [Data Preparation](#data-preparation)
14
+ - [Tokenization](#tokenization)
15
+ - [Hyperparameters](#hyperparameters)
16
+ - [Evaluation](#evaluation)
17
+ - [Variable and Metrics](#variable-and-metrics)
18
+ - [Evaluation Results](#evaluation-results)
19
+ - [Additional Information](#additional-information)
20
+ - [Author](#author)
21
+ - [Contact Information](#contact-information)
22
+ - [Copyright](#copyright)
23
+ - [Licensing Information](#licensing-information)
24
+ - [Funding](#funding)
25
+ - [Disclaimer](#disclaimer)
26
+
27
+ ## Model description
28
+
29
+ This model was trained from scratch using the [Fairseq toolkit](https://fairseq.readthedocs.io/en/latest/) on a combination of Spanish-Galician datasets, up to 31 million sentences. Additionally, the model is evaluated on several public datasets, Flores 101, Spanish Constitutioni (TaCon) and Tatoeba.
30
+
31
+ ## Intended uses and limitations
32
+
33
+ You can use this model for machine translation from Spanish to Galician.
34
+
35
+ ## How to use
36
+
37
+ ### Usage
38
+ Required libraries:
39
+
40
+ ```bash
41
+ pip install ctranslate2 pyonmttok
42
+ ```
43
+
44
+ Translate a sentence using python
45
+ ```python
46
+ import ctranslate2
47
+ import pyonmttok
48
+ from huggingface_hub import snapshot_download
49
+ model_dir = snapshot_download(repo_id="PlanTL-GOB-ES/mt-plantl-es-gl", revision="main")
50
+
51
+ tokenizer=pyonmttok.Tokenizer(mode="none", sp_model_path = model_dir + "/spm.model")
52
+ tokenized=tokenizer.tokenize("Bienvenido al Proyecto PlanTL!")
53
+
54
+ translator = ctranslate2.Translator(model_dir)
55
+ translated = translator.translate_batch([tokenized[0]])
56
+ print(tokenizer.detokenize(translated[0][0]['tokens']))
57
+ ```
58
+
59
+ ## Training
60
+
61
+ ### Training data
62
+
63
+ The was trained on a combination of the following datasets:
64
+
65
+ | Dataset | Sentences |
66
+ |-------------------|----------------|
67
+ | CLUVI | 318.612 |
68
+ | WikiMatrix | 438.181 |
69
+ | WikiMedia | 83.511 |
70
+ | QED | 30.211 |
71
+ | TED 2020 v1 | 33.324 |
72
+ | CCMatrix v1 | 24.165.978 |
73
+ | ParaCrawl | 6.537.374 |
74
+ | OpenSubtitles | 197.519 |
75
+ | **Total** | **31.804.710** |
76
+
77
+ ### Training procedure
78
+
79
+ ### Data preparation
80
+
81
+ All datasets are concatenated and filtered using the [mBERT Gencata parallel filter](https://huggingface.co/projecte-aina/mbert-base-gencata) and cleaned using the clean-corpus-n.pl script from [moses](https://github.com/moses-smt/mosesdecoder), allowing sentences between 5 and 150 words.
82
+
83
+ Before training, the punctuation is normalized using a modified version of the join-single-file.py script from [SoftCatalà](https://github.com/Softcatala/nmt-models/blob/master/data-processing-tools/join-single-file.py)
84
+
85
+
86
+ #### Tokenization
87
+
88
+ All data is tokenized using sentencepiece, with 50 thousand token sentencepiece model learned from the combination of all filtered training data. This model is included.
89
+
90
+ #### Hyperparameters
91
+
92
+ The model is based on the Transformer-XLarge proposed by [Subramanian et al.](https://aclanthology.org/2021.wmt-1.18.pdf)
93
+ The following hyperparamenters were set on the Fairseq toolkit:
94
+
95
+ | Hyperparameter | Value |
96
+ |------------------------------------|-----------------------------------|
97
+ | Architecture | transformer_vaswani_wmt_en_de_big |
98
+ | Embedding size | 1024 |
99
+ | Feedforward size | 4096 |
100
+ | Number of heads | 16 |
101
+ | Encoder layers | 24 |
102
+ | Decoder layers | 6 |
103
+ | Normalize before attention | True |
104
+ | --share-decoder-input-output-embed | True |
105
+ | --share-all-embeddings | True |
106
+ | Effective batch size | 96.000 |
107
+ | Optimizer | adam |
108
+ | Adam betas | (0.9, 0.980) |
109
+ | Clip norm | 0.0 |
110
+ | Learning rate | 1e-3 |
111
+ | Lr. schedurer | inverse sqrt |
112
+ | Warmup updates | 4000 |
113
+ | Dropout | 0.1 |
114
+ | Label smoothing | 0.1 |
115
+
116
+ The model was trained using shards of 10 million sentences, for a total of 8.000 updates. Weights were saved every 1000 updates and reported results are the average of the last 6 checkpoints. After this, the model was trained an extra epoch on the CLUVI dataset.
117
+
118
+ ## Evaluation
119
+
120
+ ### Variable and metrics
121
+
122
+ We use the BLEU score for evaluation on test sets: [Flores-101](https://github.com/facebookresearch/flores), [TaCon](https://elrc-share.eu/repository/browse/tacon-spanish-constitution-mt-test-set/84a96138b98611ec9c1a00155d02670628f3e6857b0f422abd82abc3795ec8c2/), [Tatoeba](https://opus.nlpl.eu/Tatoeba.php)
123
+
124
+ ### Evaluation results
125
+
126
+ Below are the evaluation results on the machine translation from Spanish to Galician compared to [Apertium](https://apertium.org/), [Google Translate](https://translate.google.es/?hl=es) and [M2M 100 418M](https://huggingface.co/facebook/m2m100_418M):
127
+
128
+ | Test set | Apertium | Google Translate | M2M-100 418M | mt-plantl-es-gl |
129
+ |----------------------|------------|------------------|--------------|-----------------|
130
+ | Spanish Constitution | 74,5 | 60,4 | 70,7 | 84,3 |
131
+ | Flores 101 devtest | 21,4 | 25,6 | 21,6 | 21,8 |
132
+ | Tatoeba | 67,9 | 52,8 | 53,9 | 66,6 |
133
+ | Average | 54,3 | 46,3 | 48,7 | 57,6 |
134
+
135
+ ## Additional information
136
+
137
+ ### Author
138
+ Text Mining Unit (TeMU) at the Barcelona Supercomputing Center (bsc-temu@bsc.es)
139
+
140
+ ### Contact information
141
+ For further information, send an email to <plantl-gob-es@bsc.es>
142
+
143
+ ### Copyright
144
+ Copyright by the Spanish State Secretariat for Digitalization and Artificial Intelligence (SEDIA) (2022)
145
+
146
+ ### Licensing information
147
+ This work is licensed under a [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)
148
+
149
+ ### Funding
150
+ This work was funded by the Spanish State Secretariat for Digitalization and Artificial Intelligence (SEDIA)
151
+
152
+ ### Disclaimer
153
+
154
+ <details>
155
+ <summary>Click to expand</summary>
156
+
157
+ The models published in this repository are intended for a generalist purpose and are available to third parties. These models may have bias and/or any other undesirable distortions.
158
+
159
+ When third parties, deploy or provide systems and/or services to other parties using any of these models (or using systems based on these models) or become users of the models, they should note that it is their responsibility to mitigate the risks arising from their use and, in any event, to comply with applicable regulations, including regulations regarding the use of Artificial Intelligence.
160
+
161
+ In no event shall the owner of the models (SEDIA – State Secretariat for Digitalization and Artificial Intelligence) nor the creator (BSC – Barcelona Supercomputing Center) be liable for any results arising from the use made by third parties of these models.
162
+
163
+
164
+ Los modelos publicados en este repositorio tienen una finalidad generalista y están a disposición de terceros. Estos modelos pueden tener sesgos y/u otro tipo de distorsiones indeseables.
165
+
166
+ Cuando terceros desplieguen o proporcionen sistemas y/o servicios a otras partes usando alguno de estos modelos (o utilizando sistemas basados en estos modelos) o se conviertan en usuarios de los modelos, deben tener en cuenta que es su responsabilidad mitigar los riesgos derivados de su uso y, en todo caso, cumplir con la normativa aplicable, incluyendo la normativa en materia de uso de inteligencia artificial.
167
+
168
+ En ningún caso el propietario de los modelos (SEDIA – Secretaría de Estado de Digitalización e Inteligencia Artificial) ni el creador (BSC – Barcelona Supercomputing Center) serán responsables de los resultados derivados del uso que hagan terceros de estos modelos.
169
+ </details>
model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:78af6f485d9332be6f0fec92989ae91ae23e4d33c55db020a241661bbe8ebcd0
3
+ size 1832893218
shared_vocabulary.txt ADDED
The diff for this file is too large to render. See raw diff
 
spm.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6b50633ce0fc4bbb3fde4c933868e8c9337dd7eb4d55548e95d741ae25d4c592
3
+ size 1170352