Fairseq
Catalan
Spanish
carlosep93 commited on
Commit
3af3027
1 Parent(s): 4ab520c

upload models

Browse files
Files changed (4) hide show
  1. README.md +175 -0
  2. model.bin +3 -0
  3. shared_vocabulary.txt +0 -0
  4. spm.model +3 -0
README.md CHANGED
@@ -1,3 +1,178 @@
1
  ---
2
  license: cc-by-4.0
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: cc-by-4.0
3
  ---
4
+ ## Aina Project's Catalan-Spanish 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 Catalan-Spanish datasets, up to 83 million sentences. Additionally, the model is evaluated on several public datasecomprising 5 different domains (general, adminstrative, technology, biomedical, and news).
30
+
31
+ ## Intended uses and limitations
32
+
33
+ You can use this model for machine translation from Catalan to Spanish.
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="projecte-aina/mt-aina-ca-es", revision="main")
50
+
51
+ tokenizer=pyonmttok.Tokenizer(mode="none", sp_model_path = model_dir + "/spm.model")
52
+ tokenized=tokenizer.tokenize("Benvingut al projecte Aina!")
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 | Tokens |
66
+ |-------------------|----------------|-------------------|
67
+ | DOCG v2 | 8.472.786 | 188.929.206 |
68
+ | El Periodico | 6.483.106 | 145.591.906 |
69
+ | EuroParl | 1.876.669 | 49.212.670 |
70
+ | WikiMatrix | 1.421.077 | 34.902.039 |
71
+ | Wikimedia | 335.955 | 8.682.025 |
72
+ | QED | 71.867 | 1.079.705 |
73
+ | TED2020 v1 | 52.177 | 836.882 |
74
+ | CCMatrix v1 | 56.103.820 | 1.064.182.320 |
75
+ | MultiCCAligned v1 | 2.433.418 | 48.294.144 |
76
+ | ParaCrawl | 15.327.808 | 334.199.408 |
77
+ |-------------------|----------------|-------------------|
78
+ | **Total** | **92.578.683** | **1.875.910.305** |
79
+
80
+ ### Training procedure
81
+
82
+ ### Data preparation
83
+
84
+ 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.
85
+
86
+ 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)
87
+
88
+
89
+ #### Tokenization
90
+
91
+ All data is tokenized using sentencepiece, using 50 thousand token sentencepiece model learned from the combination of all filtered training data. This model is included.
92
+
93
+ #### Hyperparameters
94
+
95
+ The model is based on the Transformer-XLarge proposed by [Subramanian et al.](https://aclanthology.org/2021.wmt-1.18.pdf)
96
+ The following hyperparamenters were set on the Fairseq toolkit:
97
+
98
+ | Hyperparameter | Value |
99
+ |------------------------------------|----------------------------------|
100
+ | Architecture | transformer_vaswani_wmt_en_de_bi |
101
+ | Embedding size | 1024 |
102
+ | Feedforward size | 4096 |
103
+ | Number of heads | 16 |
104
+ | Encoder layers | 24 |
105
+ | Decoder layers | 6 |
106
+ | Normalize before attention | True |
107
+ | --share-decoder-input-output-embed | True |
108
+ | --share-all-embeddings | True |
109
+ | Effective batch size | 96.000 |
110
+ | Optimizer | adam |
111
+ | Adam betas | (0.9, 0.980) |
112
+ | Clip norm | 0.0 |
113
+ | Learning rate | 1e-3 |
114
+ | Lr. schedurer | inverse sqrt |
115
+ | Warmup updates | 4000 |
116
+ | Dropout | 0.1 |
117
+ | Label smoothing | 0.1 |
118
+
119
+ The model was trained using shards of 10 million sentences, for a total of 13.000 updates. Weights were saved every 1000 updates and reported results are the average of the last 6 checkpoints.
120
+
121
+ ## Evaluation
122
+
123
+ ### Variable and metrics
124
+
125
+ We use the BLEU score for evaluation on test sets: [Flores-101](https://github.com/facebookresearch/flores), [Spanish Constitution](), [United Nations](), [Cybersecurity](), [wmt19 biomedical test set](), [wmt13 news test set](), [AAPP]()
126
+
127
+ ### Evaluation results
128
+
129
+ Below are the evaluation results on the machine translation from Catalan to Chinese compared with the original m2m100 on a testset: [Flores-101](https://github.com/facebookresearch/flores).
130
+
131
+ | Test set | SoftCatalà | Google Translate | mt-aina-ca-es |
132
+ |----------------------|------------|------------------|---------------|
133
+ | Spanish Constitution | 66,2 | **77,1** | 75,5 |
134
+ | United Nations | 72 | 84,3 | **86,3** |
135
+ | aina_aapp | 78,1 | 80,8 | **81,8** |
136
+ | Flores 101 dev | 23,8 | 24 | **24,1** |
137
+ | Flores 101 devtest | 23,9 | 24,2 | **24,4** |
138
+ | Cybersecurity | 73,5 | **76,9** | 75,1 |
139
+ | wmt 19 biomedical | 60,0 | 62,7 | **63,0** |
140
+ | wmt 13 news | 22,7 | 23,1 | **23,4** |
141
+ |----------------------|------------|------------------|---------------|
142
+ | Average | 52,5 | 56,6 | **56,7** |
143
+
144
+
145
+
146
+ - [Author](#author)
147
+ - [Licensing information](#licensing-information)
148
+ - [Funding](#funding)
149
+ - [Disclaimer](#disclaimer)
150
+
151
+ ## Additional information
152
+
153
+ ### Author
154
+ Text Mining Unit (TeMU) at the Barcelona Supercomputing Center ([email protected])
155
+
156
+ ### Contact information
157
+ For further information, send an email to [email protected]
158
+
159
+ ### Copyright
160
+ Copyright (c) 2022 Text Mining Unit at Barcelona Supercomputing Center
161
+
162
+
163
+ ### Licensing Information
164
+ [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)
165
+
166
+ ### Funding
167
+ This work was funded by the [Departament de la Vicepresidència i de Polítiques Digitals i Territori de la Generalitat de Catalunya](https://politiquesdigitals.gencat.cat/ca/inici/index.html#googtrans(ca|en) within the framework of [Projecte AINA](https://politiquesdigitals.gencat.cat/ca/economia/catalonia-ai/aina).
168
+
169
+
170
+ ## Disclaimer
171
+ <details>
172
+ <summary>Click to expand</summary>
173
+
174
+ 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.
175
+
176
+ 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.
177
+
178
+ 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.
model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bbe59eeaa3a9fd4160165bc56c32eea9a6aaf9814f32cd052fa6c9c3bcae1136
3
+ size 1842330402
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:3a03ff389284636d6493b49e6222a13d2e00ed0d108705da38f61906eb5f424a
3
+ size 1160661