jarodrigues commited on
Commit
409493f
1 Parent(s): 3452308

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +212 -0
README.md CHANGED
@@ -1,3 +1,215 @@
1
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  license: mit
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - pt
4
+ tags:
5
+ - albertina-pt*
6
+ - albertina-ptpt
7
+ - albertina-ptbr
8
+ - albertina-ptpt-base
9
+ - albertina-ptbr-base
10
+ - fill-mask
11
+ - bert
12
+ - deberta
13
+ - portuguese
14
+ - encoder
15
+ - foundation model
16
  license: mit
17
+ datasets:
18
+ - dlb/plue
19
+ - oscar-corpus/OSCAR-2301
20
+ - PORTULAN/glue-ptpt
21
+ widget:
22
+ - text: >-
23
+ A culinária portuguesa é rica em sabores e [MASK], tornando-se um dos
24
+ maiores tesouros do país.
25
  ---
26
+
27
+
28
+ # Albertina PT-PT Base
29
+
30
+
31
+ **Albertina PT-*** is a foundation, large language model for the **Portuguese language**.
32
+
33
+ It is an **encoder** of the BERT family, based on the neural architecture Transformer and
34
+ developed over the DeBERTa model, with most competitive performance for this language.
35
+ It has different versions that were trained for different variants of Portuguese (PT),
36
+ namely the European variant from Portugal (**PT-PT**) and the American variant from Brazil (**PT-BR**),
37
+ and it is distributed free of charge and under a most permissible license.
38
+
39
+ **Albertina PT-PT** is the version for European **Portuguese** from **Portugal**,
40
+ and to the best of our knowledge, at the time of its initial distribution,
41
+ it is the first competitive encoder specifically for this language and variant
42
+ that is made publicly available and distributed for reuse.
43
+
44
+ It is developed by a joint team from the University of Lisbon and the University of Porto, Portugal.
45
+ For further details, check the respective [publication](https://arxiv.org/abs/2305.06721):
46
+
47
+ ``` latex
48
+ @misc{albertina-pt,
49
+ title={Advancing Neural Encoding of Portuguese
50
+ with Transformer Albertina PT-*},
51
+ author={João Rodrigues and Luís Gomes and João Silva and
52
+ António Branco and Rodrigo Santos and
53
+ Henrique Lopes Cardoso and Tomás Osório},
54
+ year={2023},
55
+ eprint={2305.06721},
56
+ archivePrefix={arXiv},
57
+ primaryClass={cs.CL}
58
+ }
59
+ ```
60
+
61
+ Please use the above cannonical reference when using or citing this model.
62
+
63
+ <br>
64
+
65
+
66
+ # Model Description
67
+
68
+ **This model card is for Albertina-PT-PT Base**, with 100M parameters, 12 layers and a hidden size of 768.
69
+
70
+ Albertina-PT-PT is distributed under an [MIT license](https://huggingface.co/PORTULAN/albertina-ptpt/blob/main/LICENSE).
71
+
72
+ DeBERTa is distributed under an [MIT license](https://github.com/microsoft/DeBERTa/blob/master/LICENSE).
73
+
74
+
75
+ <br>
76
+
77
+ # Training Data
78
+
79
+ **Albertina PT-PT Base** 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:
80
+
81
+ - [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.
82
+ - [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.
83
+ - [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.
84
+ - [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.
85
+
86
+
87
+ [**Albertina PT-BR Base**](https://huggingface.co/PORTULAN/albertina-ptbr), in turn, was trained over a 3.7 billion token curated selection of documents from the OSCAR data set, specifically filtered by the Internet country code top-level domain of Brazil.
88
+
89
+
90
+ ## Preprocessing
91
+
92
+ We filtered the PT-PT and PT-BR corpora using the [BLOOM pre-processing](https://github.com/bigscience-workshop/data-preparation) pipeline.
93
+ 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.
94
+
95
+
96
+ ## Training
97
+
98
+ As codebase, we resorted to the [DeBERTa V1 Base](https://huggingface.co/microsoft/deberta-base), for English.
99
+
100
+ To train **Albertina-PT-PT Base**, the data set was tokenized with the original DeBERTa tokenizer with a 128 token sequence truncation and dynamic padding.
101
+ The model was trained using the maximum available memory capacity resulting in a batch size of 3072 samples (192 samples per GPU and applying gradient accumulation in order to approximate the batch size of the PT-BR model).
102
+ We opted for a learning rate of 1e-5 with linear decay and 10k warm-up steps.
103
+ A total of 200 training epochs were performed resulting in approximately 180k steps.
104
+ The model was trained for one day on a2-megagpu-16gb Google Cloud A2 VMs with 16 GPUs, 96 vCPUs and 1.360 GB of RAM.
105
+
106
+ To train [**Albertina PT-BR Base**](https://huggingface.co/PORTULAN/albertina-ptbr-base) we followed the same hyperparameterization as the Albertina-PT-PT Base model.
107
+ The model was trained with a total of 150 training epochs resulting in approximately 180k steps.
108
+
109
+
110
+ <br>
111
+
112
+ # Evaluation
113
+
114
+ The two base model versions were evaluated on downstream tasks_
115
+ 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.
116
+
117
+
118
+ ## GLUE tasks translated
119
+
120
+ 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**.
121
+ We address four tasks from those in PLUE, namely:
122
+ - two similarity tasks: MRPC, for detecting whether two sentences are paraphrases of each other, and STS-B, for semantic textual similarity;
123
+ - and two inference tasks: RTE, for recognizing textual entailment and WNLI, for coreference and natural language inference.
124
+
125
+
126
+ | Model | RTE (Accuracy) | WNLI (Accuracy)| MRPC (F1) | STS-B (Pearson) |
127
+ |--------------------------|----------------|----------------|-----------|-----------------|
128
+ | **Albertina-PT-BR Base** | 0.6462 | **0.5493** | 0.8779 | 0.8501 |
129
+ | **Albertina-PT-PT Base** | **0.6643** | 0.4366 | **0.8966** | **0.8608** |
130
+
131
+
132
+ We resorted to [GLUE-PT](https://huggingface.co/datasets/PORTULAN/glue-ptpt), a **PT-PT version of the GLUE** benchmark.
133
+ 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.
134
+
135
+ | Model | RTE (Accuracy) | WNLI (Accuracy)| MRPC (F1) | STS-B (Pearson) |
136
+ |--------------------------|----------------|----------------|-----------|-----------------|
137
+ | **Albertina-PT-PT Base** | **0.6787** | 0.4507 | 0.8829 | **0.8581** |
138
+ | **Albertina-PT-BR Base** | 0.6570 | **0.5070** | **0.8900** | 0.8516 |
139
+
140
+ <br>
141
+
142
+ # How to use
143
+
144
+ You can use this model directly with a pipeline for masked language modeling:
145
+
146
+ ```python
147
+ >>> from transformers import pipeline
148
+ >>> unmasker = pipeline('fill-mask', model='PORTULAN/albertina-ptpt-base')
149
+ >>> unmasker("A culinária portuguesa é rica em sabores e [MASK], tornando-se um dos maiores tesouros do país.")
150
+
151
+ [{'score': 0.8332648277282715, 'token': 14690, 'token_str': ' costumes', 'sequence': 'A culinária portuguesa é rica em sabores e costumes, tornando-se um dos maiores tesouros do país.'},
152
+ {'score': 0.07860890030860901, 'token': 29829, 'token_str': ' cores', 'sequence': 'A culinária portuguesa é rica em sabores e cores, tornando-se um dos maiores tesouros do país.'},
153
+ {'score': 0.03278181701898575, 'token': 35277, 'token_str': ' arte', 'sequence': 'A culinária portuguesa é rica em sabores e arte, tornando-se um dos maiores tesouros do país.'},
154
+ {'score': 0.009515956044197083, 'token': 9240, 'token_str': ' cor', 'sequence': 'A culinária portuguesa é rica em sabores e cor, tornando-se um dos maiores tesouros do país.'},
155
+ {'score': 0.009381960146129131, 'token': 33455, 'token_str': ' nuances', 'sequence': 'A culinária portuguesa é rica em sabores e nuances, tornando-se um dos maiores tesouros do país.'}]
156
+
157
+
158
+
159
+ ```
160
+
161
+ The model can be used by fine-tuning it for a specific task:
162
+
163
+ ```python
164
+ >>> from transformers import AutoTokenizer, AutoModelForSequenceClassification, TrainingArguments, Trainer
165
+ >>> from datasets import load_dataset
166
+
167
+ >>> model = AutoModelForSequenceClassification.from_pretrained("PORTULAN/albertina-ptpt-base", num_labels=2)
168
+ >>> tokenizer = AutoTokenizer.from_pretrained("PORTULAN/albertina-ptpt-base")
169
+ >>> dataset = load_dataset("PORTULAN/glue-ptpt", "rte")
170
+
171
+ >>> def tokenize_function(examples):
172
+ ... return tokenizer(examples["sentence1"], examples["sentence2"], padding="max_length", truncation=True)
173
+
174
+ >>> tokenized_datasets = dataset.map(tokenize_function, batched=True)
175
+
176
+ >>> training_args = TrainingArguments(output_dir="albertina-ptpt-rte", evaluation_strategy="epoch")
177
+ >>> trainer = Trainer(
178
+ ... model=model,
179
+ ... args=training_args,
180
+ ... train_dataset=tokenized_datasets["train"],
181
+ ... eval_dataset=tokenized_datasets["validation"],
182
+ ... )
183
+
184
+ >>> trainer.train()
185
+
186
+ ```
187
+
188
+ <br>
189
+
190
+ # Citation
191
+
192
+ When using or citing this model, kindly cite the following [publication](https://arxiv.org/abs/2305.06721):
193
+
194
+ ``` latex
195
+ @misc{albertina-pt,
196
+ title={Advancing Neural Encoding of Portuguese
197
+ with Transformer Albertina PT-*},
198
+ author={João Rodrigues and Luís Gomes and João Silva and
199
+ António Branco and Rodrigo Santos and
200
+ Henrique Lopes Cardoso and Tomás Osório},
201
+ year={2023},
202
+ eprint={2305.06721},
203
+ archivePrefix={arXiv},
204
+ primaryClass={cs.CL}
205
+ }
206
+ ```
207
+
208
+ <br>
209
+
210
+ # Acknowledgments
211
+
212
+ The research reported here was partially supported by: PORTULAN CLARIN—Research Infrastructure for the Science and Technology of Language,
213
+ funded by Lisboa 2020, Alentejo 2020 and FCT—Fundação para a Ciência e Tecnologia under the
214
+ 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
215
+ 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.