Fairseq
Spanish
Catalan
fdelucaf commited on
Commit
91a7154
·
verified ·
1 Parent(s): 9993fef

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +181 -0
README.md CHANGED
@@ -1,3 +1,184 @@
1
  ---
2
  license: apache-2.0
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ language:
4
+ - es
5
+ - ca
6
  ---
7
+ ## Aina Project's Spanish-Catalan machine translation model
8
+
9
+ ## Table of Contents
10
+ - [Model Description](#model-description)
11
+ - [Intended Uses and Limitations](#intended-use)
12
+ - [How to Use](#how-to-use)
13
+ - [Training](#training)
14
+ - [Training data](#training-data)
15
+ - [Training procedure](#training-procedure)
16
+ - [Data Preparation](#data-preparation)
17
+ - [Tokenization](#tokenization)
18
+ - [Hyperparameters](#hyperparameters)
19
+ - [Evaluation](#evaluation)
20
+ - [Variable and Metrics](#variable-and-metrics)
21
+ - [Evaluation Results](#evaluation-results)
22
+ - [Additional Information](#additional-information)
23
+ - [Author](#author)
24
+ - [Contact Information](#contact-information)
25
+ - [Copyright](#copyright)
26
+ - [Licensing Information](#licensing-information)
27
+ - [Funding](#funding)
28
+ - [Disclaimer](#disclaimer)
29
+
30
+ ## Model description
31
+
32
+ This model was trained from scratch using the [Fairseq toolkit](https://fairseq.readthedocs.io/en/latest/) on a combination of Catalan-Spanish datasets,
33
+ up to 92 million sentences. Additionally, the model is evaluated on several public datasecomprising 5 different domains
34
+ (general, adminstrative, technology, biomedical, and news).
35
+
36
+ ## Intended uses and limitations
37
+
38
+ You can use this model for machine translation from Spanish to Catalan.
39
+
40
+ ## How to use
41
+
42
+ ### Usage
43
+ Required libraries:
44
+
45
+ ```bash
46
+ pip install ctranslate2 pyonmttok
47
+ ```
48
+
49
+ Translate a sentence using python
50
+ ```python
51
+ import ctranslate2
52
+ import pyonmttok
53
+ from huggingface_hub import snapshot_download
54
+ model_dir = snapshot_download(repo_id="projecte-aina/mt-aina-es-ca", revision="main")
55
+
56
+ tokenizer=pyonmttok.Tokenizer(mode="none", sp_model_path = model_dir + "/spm.model")
57
+ tokenized=tokenizer.tokenize("Bienvenido al Proyecto Aina!")
58
+
59
+ translator = ctranslate2.Translator(model_dir)
60
+ translated = translator.translate_batch([tokenized[0]])
61
+ print(tokenizer.detokenize(translated[0][0]['tokens']))
62
+ ```
63
+
64
+ ## Training
65
+
66
+ ### Training data
67
+
68
+ The madel was trained on a combination of the following datasets:
69
+
70
+ | Dataset | Sentences | Tokens |
71
+ |-------------------|----------------|-------------------|
72
+ | DOCG v2 | 8.472.786 | 188.929.206 |
73
+ | El Periodico | 6.483.106 | 145.591.906 |
74
+ | EuroParl | 1.876.669 | 49.212.670 |
75
+ | WikiMatrix | 1.421.077 | 34.902.039 |
76
+ | Wikimedia | 335.955 | 8.682.025 |
77
+ | QED | 71.867 | 1.079.705 |
78
+ | TED2020 v1 | 52.177 | 836.882 |
79
+ | CCMatrix v1 | 56.103.820 | 1.064.182.320 |
80
+ | MultiCCAligned v1 | 2.433.418 | 48.294.144 |
81
+ | ParaCrawl | 15.327.808 | 334.199.408 |
82
+ | **Total** | **92.578.683** | **1.875.910.305** |
83
+
84
+ ### Training procedure
85
+
86
+ ### Data preparation
87
+
88
+ All datasets are concatenated and filtered using the [mBERT Gencata parallel filter](https://huggingface.co/projecte-aina/mbert-base-gencata)
89
+ and cleaned using the clean-corpus-n.pl script from [moses](https://github.com/moses-smt/mosesdecoder), allowing sentences between 5 and 150 words.
90
+
91
+ Before training, the punctuation is normalized using a modified version of the join-single-file.py script from
92
+ [SoftCatalà](https://github.com/Softcatala/nmt-models/blob/master/data-processing-tools/join-single-file.py)
93
+
94
+
95
+ #### Tokenization
96
+
97
+ All data is tokenized using sentencepiece, with 50 thousand token sentencepiece model
98
+ learned from the combination of all filtered training data. This model is included.
99
+
100
+ #### Hyperparameters
101
+
102
+ The model is based on the Transformer-XLarge proposed by [Subramanian et al.](https://aclanthology.org/2021.wmt-1.18.pdf)
103
+ The following hyperparamenters were set on the Fairseq toolkit:
104
+
105
+ | Hyperparameter | Value |
106
+ |------------------------------------|----------------------------------|
107
+ | Architecture | transformer_vaswani_wmt_en_de_bi |
108
+ | Embedding size | 1024 |
109
+ | Feedforward size | 4096 |
110
+ | Number of heads | 16 |
111
+ | Encoder layers | 24 |
112
+ | Decoder layers | 6 |
113
+ | Normalize before attention | True |
114
+ | --share-decoder-input-output-embed | True |
115
+ | --share-all-embeddings | True |
116
+ | Effective batch size | 96.000 |
117
+ | Optimizer | adam |
118
+ | Adam betas | (0.9, 0.980) |
119
+ | Clip norm | 0.0 |
120
+ | Learning rate | 1e-3 |
121
+ | Lr. schedurer | inverse sqrt |
122
+ | Warmup updates | 4000 |
123
+ | Dropout | 0.1 |
124
+ | Label smoothing | 0.1 |
125
+
126
+ The model was trained using shards of 10 million sentences, for a total of 8.000 updates.
127
+ Weights were saved every 1000 updates and reported results are the average of the last 6 checkpoints.
128
+
129
+ ## Evaluation
130
+
131
+ ### Variable and metrics
132
+
133
+ We use the BLEU score for evaluation on test sets:
134
+ [Flores-101](https://github.com/facebookresearch/flores),
135
+ [TaCon](https://elrc-share.eu/repository/browse/tacon-spanish-constitution-mt-test-set/84a96138b98611ec9c1a00155d02670628f3e6857b0f422abd82abc3795ec8c2/),
136
+ [United Nations](https://zenodo.org/record/3888414#.Y33-_tLMIW0),
137
+ [Cybersecurity](https://elrc-share.eu/repository/browse/cyber-mt-test-set/2bd93faab98c11ec9c1a00155d026706b96a490ed3e140f0a29a80a08c46e91e/),
138
+ [wmt19 biomedical test set](),
139
+ [wmt13 news test set](https://elrc-share.eu/repository/browse/catalan-wmt2013-machine-translation-shared-task-test-set/84a96139b98611ec9c1a00155d0267061a0aa1b62e2248e89aab4952f3c230fc/)
140
+
141
+ ### Evaluation results
142
+
143
+ Below are the evaluation results on the machine translation from Spanish to Catalan
144
+ compared to [Softcatalà](https://www.softcatala.org/) and [Google Translate](https://translate.google.es/?hl=es):
145
+
146
+ | Test set | SoftCatalà | Google Translate | mt-aina-es-ca |
147
+ |----------------------|------------|------------------|---------------|
148
+ | Spanish Constitution | **63,6** | 61,7 | 63,0 |
149
+ | United Nations | 73,8 | 74,8 | **74,9** |
150
+ | Flores 101 dev | 22 | **23,1** | 22,5 |
151
+ | Flores 101 devtest | 22,7 | **23,6** | 23,1 |
152
+ | Cybersecurity | 61,4 | **69,5** | 67,3 |
153
+ | wmt 19 biomedical | 60,2 | 59,7 | **60,6** |
154
+ | wmt 13 news | 21,3 | **22,4** | 22,0 |
155
+ | Average | 46,4 | **47,8** | 47,6 |
156
+
157
+
158
+ ## Additional information
159
+
160
+ ### Author
161
+ Language Technologies Unit (LangTech) at the Barcelona Supercomputing Center
162
+
163
+ ### Contact information
164
+ For further information, please send an email to [email protected].
165
+
166
+ ### Copyright
167
+ Copyright Language Technologies Unit at Barcelona Supercomputing Center (2023)
168
+
169
+
170
+ ### Licensing Information
171
+ This work is licensed under a [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)
172
+
173
+ ### Funding
174
+ This work has been promoted and financed by the Generalitat de Catalunya through the [Aina project] (https://projecteaina.cat/).
175
+
176
+ ## Disclaimer
177
+
178
+ <details>
179
+ <summary>Click to expand</summary>
180
+
181
+ 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.
182
+ 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.
183
+ In no event shall the owner and creator of the models (BSC – Barcelona Supercomputing Center) be liable for any results arising from the use made by third parties of these models.
184
+ </details>