Fairseq
Catalan
English
carlosep93 commited on
Commit
c9930fc
·
1 Parent(s): 30313d2

initial commit

Browse files
Files changed (4) hide show
  1. README.md +186 -1
  2. model.bin +3 -0
  3. shared_vocabulary.txt +0 -0
  4. spm.model +3 -0
README.md CHANGED
@@ -1,3 +1,188 @@
1
  ---
2
- license: apache-2.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-English datasets, up to 11 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-en", 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
+ | Global Voices | 21.342 | 438.032 |
68
+ | Memories Lluires | 1.173.055 | 9.452.382 |
69
+ | Wikimatrix | 1.205.908 | 28.111.517 |
70
+ | TED Talks | 50.979 | 770.774 |
71
+ | Tatoeba | 5.500 | 34.872 |
72
+ | CoVost 2 ca-en | 79.633 | 809.660 |
73
+ | CoVost 2 en-ca | 263.891 | 2.953.096 |
74
+ | Europarl | 1.965.734 | 50.417.289 |
75
+ | jw300 | 97.081 | 1.809.252 |
76
+ | Crawled Generalitat| 38.595 | 858.385 |
77
+ | Opus Books | 4.580 | 73.416 |
78
+ | CC Aligned | 5.787.682 | 89.606.874 |
79
+ | COVID_Wikipedia | 1.531 | 34.836 |
80
+ | EuroBooks | 3.746 | 82.067 |
81
+ | Gnome | 2.183 | 30.228 |
82
+ | KDE 4 | 144.153 | 1.450.631 |
83
+ | OpenSubtitles | 427.913 | 2.796.350 |
84
+ | QED | 69.823 | 1.058.003 |
85
+ | Ubuntu | 6.781 | 33.321 |
86
+ | Wikimedia | 208.073 | 5.761.409 |
87
+ |--------------------|----------------|-------------------|
88
+ | **Total** | **11.558.183** | **196.582.394** |
89
+
90
+ ### Training procedure
91
+
92
+ ### Data preparation
93
+
94
+ All datasets are concatenated and filtered using the [mBERT Gencata parallel filter](https://huggingface.co/projecte-aina/mbert-base-gencata). 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)
95
+
96
+
97
+ #### Tokenization
98
+
99
+ 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.
100
+
101
+ #### Hyperparameters
102
+
103
+ The model is based on the Transformer-XLarge proposed by [Subramanian et al.](https://aclanthology.org/2021.wmt-1.18.pdf)
104
+ The following hyperparamenters were set on the Fairseq toolkit:
105
+
106
+ | Hyperparameter | Value |
107
+ |------------------------------------|----------------------------------|
108
+ | Architecture | transformer_vaswani_wmt_en_de_bi |
109
+ | Embedding size | 1024 |
110
+ | Feedforward size | 4096 |
111
+ | Number of heads | 16 |
112
+ | Encoder layers | 24 |
113
+ | Decoder layers | 6 |
114
+ | Normalize before attention | True |
115
+ | --share-decoder-input-output-embed | True |
116
+ | --share-all-embeddings | True |
117
+ | Effective batch size | 96.000 |
118
+ | Optimizer | adam |
119
+ | Adam betas | (0.9, 0.980) |
120
+ | Clip norm | 0.0 |
121
+ | Learning rate | 1e-3 |
122
+ | Lr. schedurer | inverse sqrt |
123
+ | Warmup updates | 4000 |
124
+ | Dropout | 0.1 |
125
+ | Label smoothing | 0.1 |
126
+
127
+ The model was trained for a total of 35.000 updates. Weights were saved every 1000 updates and reported results are the average of the last 16 checkpoints.
128
+
129
+ ## Evaluation
130
+
131
+ ### Variable and metrics
132
+
133
+ 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/), [United Nations](https://zenodo.org/record/3888414#.Y33-_tLMIW0), [Cybersecurity](https://elrc-share.eu/repository/browse/cyber-mt-test-set/2bd93faab98c11ec9c1a00155d026706b96a490ed3e140f0a29a80a08c46e91e/), [wmt19 biomedical test set](), [wmt13 news test set](https://elrc-share.eu/repository/browse/catalan-wmt2013-machine-translation-shared-task-test-set/84a96139b98611ec9c1a00155d0267061a0aa1b62e2248e89aab4952f3c230fc/), [aina aapp]()
134
+
135
+ ### Evaluation results
136
+
137
+ Below are the evaluation results on the machine translation from Catalan to English compared to [Softcatalà](https://www.softcatala.org/) and [Google Translate](https://translate.google.es/?hl=es):
138
+
139
+
140
+ | Test set | SoftCatalà | Google Translate | mt-aina-ca-es |
141
+ |----------------------|------------|------------------|---------------|
142
+ | Spanish Constitution | | 43,2 | 40,3 |
143
+ | United Nations | | 47,4 | 44,8 |
144
+ | aina_aapp | | 53 | 51,5 |
145
+ | aina_eu_comission | | | |
146
+ | Flores 101 dev | | 47,5 | 46,1 |
147
+ | Flores 101 devtest | | 46,9 | 45,2 |
148
+ | Cybersecurity | | 58 | 54,2 |
149
+ | wmt 19 biomedical | | 23,4 | 21,6 |
150
+ | wmt 13 news | | 39,8 | 39,3 |
151
+ |----------------------|------------|------------------|---------------|
152
+ | Average | | | |
153
+
154
+
155
+
156
+ - [Author](#author)
157
+ - [Licensing information](#licensing-information)
158
+ - [Funding](#funding)
159
+ - [Disclaimer](#disclaimer)
160
+
161
+ ## Additional information
162
+
163
+ ### Author
164
+ Text Mining Unit (TeMU) at the Barcelona Supercomputing Center (bsc-temu@bsc.es)
165
+
166
+ ### Contact information
167
+ For further information, send an email to aina@bsc.es
168
+
169
+ ### Copyright
170
+ Copyright (c) 2022 Text Mining Unit at Barcelona Supercomputing Center
171
+
172
+
173
+ ### Licensing Information
174
+ [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)
175
+
176
+ ### Funding
177
+ 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).
178
+
179
+
180
+ ## Disclaimer
181
+ <details>
182
+ <summary>Click to expand</summary>
183
+
184
+ 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.
185
+
186
+ 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.
187
+
188
+ 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:e3c98ee65a7e2e9097863b52fb444214b6913a94284becfb8e2fe52313a720fb
3
+ size 1925987106
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:995f1faf20948334827be8408f8526f67c27d4bf56482933e57f5ac64b923349
3
+ size 1146189