carlosep93
commited on
Commit
•
310609f
1
Parent(s):
876a69c
initial commit
Browse files- README.md +174 -1
- model.bin +3 -0
- shared_vocabulary.txt +0 -0
- spm.model +3 -0
README.md
CHANGED
@@ -1,3 +1,176 @@
|
|
1 |
---
|
2 |
-
license:
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
license: license: cc-by-4.0
|
3 |
---
|
4 |
+
## PlanTL Project's Spanish-Catalan 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-Catalan datasets, up to 92 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 Spanish to Catalan.
|
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-es-ca", 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 | 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 |
+
| **Total** | **92.578.683** | **1.875.910.305** |
|
78 |
+
|
79 |
+
### Training procedure
|
80 |
+
|
81 |
+
### Data preparation
|
82 |
+
|
83 |
+
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.
|
84 |
+
|
85 |
+
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)
|
86 |
+
|
87 |
+
|
88 |
+
#### Tokenization
|
89 |
+
|
90 |
+
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.
|
91 |
+
|
92 |
+
#### Hyperparameters
|
93 |
+
|
94 |
+
The model is based on the Transformer-XLarge proposed by [Subramanian et al.](https://aclanthology.org/2021.wmt-1.18.pdf)
|
95 |
+
The following hyperparamenters were set on the Fairseq toolkit:
|
96 |
+
|
97 |
+
| Hyperparameter | Value |
|
98 |
+
|------------------------------------|----------------------------------|
|
99 |
+
| Architecture | transformer_vaswani_wmt_en_de_bi |
|
100 |
+
| Embedding size | 1024 |
|
101 |
+
| Feedforward size | 4096 |
|
102 |
+
| Number of heads | 16 |
|
103 |
+
| Encoder layers | 24 |
|
104 |
+
| Decoder layers | 6 |
|
105 |
+
| Normalize before attention | True |
|
106 |
+
| --share-decoder-input-output-embed | True |
|
107 |
+
| --share-all-embeddings | True |
|
108 |
+
| Effective batch size | 96.000 |
|
109 |
+
| Optimizer | adam |
|
110 |
+
| Adam betas | (0.9, 0.980) |
|
111 |
+
| Clip norm | 0.0 |
|
112 |
+
| Learning rate | 1e-3 |
|
113 |
+
| Lr. schedurer | inverse sqrt |
|
114 |
+
| Warmup updates | 4000 |
|
115 |
+
| Dropout | 0.1 |
|
116 |
+
| Label smoothing | 0.1 |
|
117 |
+
|
118 |
+
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.
|
119 |
+
|
120 |
+
## Evaluation
|
121 |
+
|
122 |
+
### Variable and metrics
|
123 |
+
|
124 |
+
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]()
|
125 |
+
|
126 |
+
### Evaluation results
|
127 |
+
|
128 |
+
Below are the evaluation results on the machine translation from Spanish to Catalan compared to [Softcatalà](https://www.softcatala.org/) and [Google Translate](https://translate.google.es/?hl=es):
|
129 |
+
|
130 |
+
| Test set | SoftCatalà | Google Translate | mt-aina-ca-es |
|
131 |
+
|----------------------|------------|------------------|---------------|
|
132 |
+
| Spanish Constitution | | 61,7 | 63,0 |
|
133 |
+
| United Nations | | 74,8 | 74,9 |
|
134 |
+
| aina_aapp | | 76,8 | |
|
135 |
+
| Flores 101 dev | | 23,1 | 22,5 |
|
136 |
+
| Flores 101 devtest | | 23,6 | 23,1 |
|
137 |
+
| Cybersecurity | | 69,5 | 67,3 |
|
138 |
+
| wmt 19 biomedical | | 59,7 | 60,6 |
|
139 |
+
| wmt 13 news | | 22,4 | 22,0 |
|
140 |
+
| Average | | 51,4 | |
|
141 |
+
|
142 |
+
## Additional information
|
143 |
+
|
144 |
+
### Author
|
145 |
+
Text Mining Unit (TeMU) at the Barcelona Supercomputing Center ([email protected])
|
146 |
+
|
147 |
+
### Contact information
|
148 |
+
For further information, send an email to <[email protected]>
|
149 |
+
|
150 |
+
### Copyright
|
151 |
+
Copyright by the Spanish State Secretariat for Digitalization and Artificial Intelligence (SEDIA) (2022)
|
152 |
+
|
153 |
+
### Licensing information
|
154 |
+
This work is licensed under a [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
155 |
+
|
156 |
+
### Funding
|
157 |
+
This work was funded by the Spanish State Secretariat for Digitalization and Artificial Intelligence (SE
|
158 |
+
|
159 |
+
### Disclaimer
|
160 |
+
|
161 |
+
<details>
|
162 |
+
<summary>Click to expand</summary>
|
163 |
+
|
164 |
+
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.
|
165 |
+
|
166 |
+
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.
|
167 |
+
|
168 |
+
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.
|
169 |
+
|
170 |
+
|
171 |
+
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.
|
172 |
+
|
173 |
+
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.
|
174 |
+
|
175 |
+
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.
|
176 |
+
</details>
|
model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:dd2064e9a527c7259bd21dc06cdca6ea736ba290e3eca3dfdba729c59a0db280
|
3 |
+
size 1909668642
|
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:9272e653f605db5b943a7a3485d8bec07d9c3f9c910ea9bb7613794c8673de81
|
3 |
+
size 1427175
|