jarodrigues commited on
Commit
726a33c
1 Parent(s): 0ce5f88

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +251 -1
README.md CHANGED
@@ -1,3 +1,253 @@
1
  ---
2
- license: mit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - pt
4
+ tags:
5
+ - albertina-pt*
6
+ - albertina-ptpt
7
+ - albertina-ptbr
8
+ - fill-mask
9
+ - bert
10
+ - deberta
11
+ - portuguese
12
+ - encoder
13
+ - foundation model
14
+ license: other
15
+ datasets:
16
+ - brwac
17
+ - PORTULAN/glue-ptpt
18
+ - assin2
19
+ - dlb/plue
20
+ widget:
21
+ - text: >-
22
+ A culinária brasileira é rica em sabores e [MASK], tornando-se um dos
23
+ maiores patrimônios do país.
24
  ---
25
+
26
+
27
+ # Albertina PT-BR
28
+
29
+ ---
30
+ <img align="left" width="40" height="40" src="https://github.githubassets.com/images/icons/emoji/unicode/1f917.png">
31
+ <p style="text-align: center;">&nbsp;&nbsp;&nbsp;&nbsp;<b>We just released</b> the base models and <b>Albertina PT-BR v2</b>,
32
+ trained on a data set with most permissive license.</p>
33
+
34
+ ---
35
+
36
+ **Albertina PT-*** is a foundation, large language model for the **Portuguese language**.
37
+
38
+ It is an **encoder** of the BERT family, based on the neural architecture Transformer and
39
+ developed over the DeBERTa model, and with most competitive performance for this language.
40
+ It has different versions that were trained for different variants of Portuguese (PT),
41
+ namely the European variant from Portugal (**PT-PT**) and the American variant from Brazil (**PT-BR**),
42
+ and it is distributed free of charge and under a most permissible license.
43
+
44
+ **Albertina PT-BR** is the version for American **Portuguese** from **Brazil**,
45
+ and to the best of our knowledge, at the time of its initial distribution,
46
+ it is an encoder specifically for this language and variant
47
+ that sets a new state of the art for it, and is made publicly available
48
+ and distributed for reuse.
49
+
50
+
51
+
52
+ It is developed by a joint team from the University of Lisbon and the University of Porto, Portugal.
53
+ For further details, check the respective [publication](https://arxiv.org/abs/2305.06721):
54
+
55
+ ``` latex
56
+ @misc{albertina-pt,
57
+ title={Advancing Neural Encoding of Portuguese
58
+ with Transformer Albertina PT-*},
59
+ author={João Rodrigues and Luís Gomes and João Silva and
60
+ António Branco and Rodrigo Santos and
61
+ Henrique Lopes Cardoso and Tomás Osório},
62
+ year={2023},
63
+ eprint={2305.06721},
64
+ archivePrefix={arXiv},
65
+ primaryClass={cs.CL}
66
+ }
67
+ ```
68
+
69
+ Please use the above cannonical reference when using or citing this model.
70
+
71
+ <br>
72
+
73
+
74
+ # Model Description
75
+
76
+ **This model card is for Albertina-PT-BR-V2**, with 900M parameters, 24 layers and a hidden size of 1536.
77
+
78
+ TODO:Licence
79
+
80
+
81
+
82
+ <br>
83
+
84
+ # Training Data
85
+
86
+
87
+ **Albertina PT-BR** was trained over the 2.7 billion token [BrWac](https://huggingface.co/datasets/brwac) data set.
88
+
89
+ TODO:
90
+ **Albertina PT-BR-V2** was trained with [OSCAR](https://huggingface.co/datasets/oscar-corpus/OSCAR-2301): the OSCAR data set includes documents in more than one hundred languages, including Portuguese, and it is widely used in the literature. It is the result of a selection performed over the [Common Crawl](https://commoncrawl.org/) data set, crawled from the Web, that retains only pages whose metadata indicates permission to be crawled, that performs deduplication, and that removes some boilerplate, among other filters. Given that it does not discriminate between the Portuguese variants, we performed extra filtering by retaining only documents whose meta-data indicate the Internet country code top-level domain of Brazil. We used the January 2023 version of OSCAR, which is based on the November/December 2022 version of Common Crawl.
91
+
92
+
93
+ [**Albertina PT-PT**](https://huggingface.co/PORTULAN/albertina-ptpt), in turn, was trained over a 2.2 billion token data set that resulted from gathering some openly available corpora of European Portuguese from the following sources:
94
+
95
+ - [OSCAR](https://huggingface.co/datasets/oscar-corpus/OSCAR-2301): the OSCAR data set includes documents in more than one hundred languages, including Portuguese, and it is widely used in the literature. It is the result of a selection performed over the [Common Crawl](https://commoncrawl.org/) data set, crawled from the Web, that retains only pages whose metadata indicates permission to be crawled, that performs deduplication, and that removes some boilerplate, among other filters. Given that it does not discriminate between the Portuguese variants, we performed extra filtering by retaining only documents whose meta-data indicate the Internet country code top-level domain of Portugal. We used the January 2023 version of OSCAR, which is based on the November/December 2022 version of Common Crawl.
96
+ - [DCEP](https://joint-research-centre.ec.europa.eu/language-technology-resources/dcep-digital-corpus-european-parliament_en): the Digital Corpus of the European Parliament is a multilingual corpus including documents in all official EU languages published on the European Parliament&#39;s official website. We retained its European Portuguese portion.
97
+ - [Europarl](https://www.statmt.org/europarl/): the European Parliament Proceedings Parallel Corpus is extracted from the proceedings of the European Parliament from 1996 to 2011. We retained its European Portuguese portion.
98
+ - [ParlamentoPT](https://huggingface.co/datasets/PORTULAN/parlamento-pt): the ParlamentoPT is a data set we obtained by gathering the publicly available documents with the transcription of the debates in the Portuguese Parliament.
99
+
100
+
101
+
102
+ ## Preprocessing
103
+
104
+ We filtered the PT-PT corpora using the [BLOOM pre-processing](https://github.com/bigscience-workshop/data-preparation) pipeline, resulting in a data set of 8 million documents, containing around 2.2 billion tokens.
105
+ We skipped the default filtering of stopwords since it would disrupt the syntactic structure, and also the filtering for language identification given the corpus was pre-selected as Portuguese.
106
+
107
+
108
+ ## Training
109
+
110
+ As codebase, we resorted to the [DeBERTa V2 XLarge](https://huggingface.co/microsoft/deberta-v2-xlarge), for English.
111
+
112
+ To train **Albertina-PT-BR** the BrWac data set was tokenized with the original DeBERTA tokenizer with a 128 token sequence truncation and dynamic padding.
113
+ The model was trained using the maximum available memory capacity resulting in a batch size of 896 samples (56 samples per GPU without gradient accumulation steps).
114
+ We chose a learning rate of 1e-5 with linear decay and 10k warm-up steps based on the results of exploratory experiments.
115
+ In total, around 200k training steps were taken across 50 epochs.
116
+ The model was trained for 1 day and 11 hours on a2-megagpu-16gb Google Cloud A2 VMs with 16 GPUs, 96 vCPUs and 1.360 GB of RAM.
117
+
118
+ TODO:
119
+ To train **Albertina-PT-BR-V2** the OSCAR data set was tokenized with the original DeBERTA tokenizer with a 128 token sequence truncation and dynamic padding.
120
+ The model was trained using the maximum available memory capacity resulting in a batch size of 896 samples (56 samples per GPU without gradient accumulation steps).
121
+ We chose a learning rate of 1e-5 with linear decay and 10k warm-up steps based on the results of exploratory experiments.
122
+ In total, around 200k training steps were taken across 50 epochs.
123
+ The model was trained for 1 day and 13 hours on a2-megagpu-16gb Google Cloud A2 VMs with 16 GPUs, 96 vCPUs and 1.360 GB of RAM.
124
+
125
+
126
+ To train [**Albertina PT-PT**](https://huggingface.co/PORTULAN/albertina-ptpt), the data set was tokenized with the original DeBERTa tokenizer with a 128 token sequence truncation and dynamic padding.
127
+ The model was trained using the maximum available memory capacity resulting in a batch size of 832 samples (52 samples per GPU and applying gradient accumulation in order to approximate the batch size of the PT-BR model).
128
+ Similarly to the PT-BR variant above, we opted for a learning rate of 1e-5 with linear decay and 10k warm-up steps.
129
+ However, since the number of training examples is approximately twice of that in the PT-BR variant, we reduced the number of training epochs to half and completed only 25 epochs, which resulted in approximately 245k steps.
130
+ The model was trained for 3 days on a2-highgpu-8gb Google Cloud A2 VMs with 8 GPUs, 96 vCPUs and 680 GB of RAM.
131
+
132
+
133
+ <br>
134
+
135
+ # Evaluation
136
+
137
+ The two model versions were evaluated on downstream tasks organized into two groups.
138
+
139
+ In one group, we have the two data sets from the [ASSIN 2 benchmark](https://huggingface.co/datasets/assin2), namely STS and RTE, that were used to evaluate the previous state-of-the-art model [BERTimbau Large](https://huggingface.co/neuralmind/bert-large-portuguese-cased).
140
+ In the other group of data sets, we have the translations into PT-BR and PT-PT of the English data sets used for a few of the tasks in the widely-used [GLUE benchmark](https://huggingface.co/datasets/glue), which allowed us to test both Albertina-PT-* variants on a wider variety of downstream tasks.
141
+
142
+
143
+ ## ASSIN 2
144
+
145
+ [ASSIN 2](https://huggingface.co/datasets/assin2) is a **PT-BR data** set of approximately 10.000 sentence pairs, split into 6.500 for training, 500 for validation, and 2.448 for testing, annotated with semantic relatedness scores (range 1 to 5) and with binary entailment judgments.
146
+ This data set supports the task of semantic textual similarity (STS), which consists of assigning a score of how semantically related two sentences are; and the task of recognizing textual entailment (RTE), which given a pair of sentences, consists of determining whether the first entails the second.
147
+
148
+ | Model | RTE (Accuracy) | STS (Pearson)|
149
+ |---------------------|----------------|--------------|
150
+ | **Albertina-PT-BR** | **0.9130** | **0.8676** |
151
+ | BERTimbau-large | 0.8913 | 0.8531 |
152
+
153
+
154
+ ## GLUE tasks translated
155
+
156
+ We resort to [PLUE](https://huggingface.co/datasets/dlb/plue) (Portuguese Language Understanding Evaluation), a data set that was obtained by automatically translating GLUE into **PT-BR**.
157
+ We address four tasks from those in PLUE, namely:
158
+ - two similarity tasks: MRPC, for detecting whether two sentences are paraphrases of each other, and STS-B, for semantic textual similarity;
159
+ - and two inference tasks: RTE, for recognizing textual entailment and WNLI, for coreference and natural language inference.
160
+
161
+
162
+ | Model | RTE (Accuracy) | WNLI (Accuracy)| MRPC (F1) | STS-B (Pearson) |
163
+ |---------------------|----------------|----------------|-----------|-----------------|
164
+ | **Albertina-PT-BR** | 0.7545 | 0.4601 | 0.9071 | **0.8910** |
165
+ | BERTimbau-large | 0.6546 | **0.5634** | 0.887 | 0.8842 |
166
+ | | | | | |
167
+ | **Albertina-PT-PT** | **0.7960** | 0.4507 | **0.9151**| 0.8799 |
168
+
169
+
170
+ We resorted to [GLUE-PT](https://huggingface.co/datasets/PORTULAN/glue-ptpt), a **PT-PT version of the GLUE** benchmark.
171
+ We automatically translated the same four tasks from GLUE using [DeepL Translate](https://www.deepl.com/), which specifically provides translation from English to PT-PT as an option.
172
+
173
+ | Model | RTE (Accuracy) | WNLI (Accuracy)| MRPC (F1) | STS-B (Pearson) |
174
+ |---------------------|----------------|----------------|-----------|-----------------|
175
+ | **Albertina-PT-PT** | **0.8339** | **0.4225** | **0.9171**| 0.8801 |
176
+ | | | | | |
177
+ | **Albertina-PT-BR** | 0.7942 | 0.4085 | 0.9048 | **0.8847** |
178
+
179
+ <br>
180
+
181
+ # How to use
182
+
183
+ You can use this model directly with a pipeline for masked language modeling:
184
+
185
+ ```python
186
+ >>> from transformers import pipeline
187
+ >>> unmasker = pipeline('fill-mask', model='PORTULAN/albertina-ptbr')
188
+ >>> unmasker("A culinária brasileira é rica em sabores e [MASK], tornando-se um dos maiores patrimônios do país.")
189
+
190
+ [{'score': 0.6145166158676147, 'token': 23395, 'token_str': 'aromas', 'sequence': 'A culinária brasileira é rica em sabores e aromas, tornando-se um dos maiores patrimônios do país.'},
191
+ {'score': 0.1720353364944458, 'token': 21925, 'token_str': 'cores', 'sequence': 'A culinária brasileira é rica em sabores e cores, tornando-se um dos maiores patrimônios do país.'},
192
+ {'score': 0.1438736468553543, 'token': 10392, 'token_str': 'costumes', 'sequence': 'A culinária brasileira é rica em sabores e costumes, tornando-se um dos maiores patrimônios do país.'},
193
+ {'score': 0.02997930906713009, 'token': 117371, 'token_str': 'cultura', 'sequence': 'A culinária brasileira é rica em sabores e cultura, tornando-se um dos maiores patrimônios do país.'},
194
+ {'score': 0.015540072694420815, 'token': 22647, 'token_str': 'nuances', 'sequence': 'A culinária brasileira é rica em sabores e nuances, tornando-se um dos maiores patrimônios do país.'}]
195
+
196
+
197
+ ```
198
+
199
+ The model can be used by fine-tuning it for a specific task:
200
+
201
+ ```python
202
+ >>> from transformers import AutoTokenizer, AutoModelForSequenceClassification, TrainingArguments, Trainer
203
+ >>> from datasets import load_dataset
204
+
205
+ >>> model = AutoModelForSequenceClassification.from_pretrained("PORTULAN/albertina-ptbr", num_labels=2)
206
+ >>> tokenizer = AutoTokenizer.from_pretrained("PORTULAN/albertina-ptbr")
207
+ >>> dataset = load_dataset("PORTULAN/glue-ptpt", "rte")
208
+
209
+ >>> def tokenize_function(examples):
210
+ ... return tokenizer(examples["sentence1"], examples["sentence2"], padding="max_length", truncation=True)
211
+
212
+ >>> tokenized_datasets = dataset.map(tokenize_function, batched=True)
213
+
214
+ >>> training_args = TrainingArguments(output_dir="albertina-ptbr-rte", evaluation_strategy="epoch")
215
+ >>> trainer = Trainer(
216
+ ... model=model,
217
+ ... args=training_args,
218
+ ... train_dataset=tokenized_datasets["train"],
219
+ ... eval_dataset=tokenized_datasets["validation"],
220
+ ... )
221
+
222
+ >>> trainer.train()
223
+
224
+ ```
225
+
226
+ <br>
227
+
228
+ # Citation
229
+
230
+ When using or citing this model, kindly cite the following [publication](https://arxiv.org/abs/2305.06721):
231
+
232
+ ``` latex
233
+ @misc{albertina-pt,
234
+ title={Advancing Neural Encoding of Portuguese
235
+ with Transformer Albertina PT-*},
236
+ author={João Rodrigues and Luís Gomes and João Silva and
237
+ António Branco and Rodrigo Santos and
238
+ Henrique Lopes Cardoso and Tomás Osório},
239
+ year={2023},
240
+ eprint={2305.06721},
241
+ archivePrefix={arXiv},
242
+ primaryClass={cs.CL}
243
+ }
244
+ ```
245
+
246
+ <br>
247
+
248
+ # Acknowledgments
249
+
250
+ The research reported here was partially supported by: PORTULAN CLARIN—Research Infrastructure for the Science and Technology of Language,
251
+ funded by Lisboa 2020, Alentejo 2020 and FCT—Fundação para a Ciência e Tecnologia under the
252
+ grant PINFRA/22117/2016; research project ALBERTINA - Foundation Encoder Model for Portuguese and AI, funded by FCT—Fundação para a Ciência e Tecnologia under the
253
+ grant CPCA-IAC/AV/478394/2022; innovation project ACCELERAT.AI - Multilingual Intelligent Contact Centers, funded by IAPMEI, I.P. - Agência para a Competitividade e Inovação under the grant C625734525-00462629, of Plano de Recuperação e Resiliência, call RE-C05-i01.01 – Agendas/Alianças Mobilizadoras para a Reindustrialização; and LIACC - Laboratory for AI and Computer Science, funded by FCT—Fundação para a Ciência e Tecnologia under the grant FCT/UID/CEC/0027/2020.