ahb commited on
Commit
9e884eb
1 Parent(s): aa95e0a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +88 -45
README.md CHANGED
@@ -1,44 +1,70 @@
1
  ---
2
- language:
3
- - pt
4
- tags:
5
- - albertina-pt*
6
- - albertina-ptpt
7
- - albertina-ptbr
8
- - fill-mask
9
- license: other
10
  datasets:
11
  - oscar
12
  - brwac
13
  - europarl
14
  widget:
15
- - text: "A culinária brasileira é rica em sabores e [MASK], tornando-se um dos maiores tesouros do país."
16
  ---
17
 
18
 
19
- # Albertina PT-* Model
20
 
21
- To advance the neural encoding of Portuguese (PT), and a fortiori the technological preparation of this language for the digital age, we developed a Transformer-based foundation model that sets a **new state of the art** in this respect for two of its variants, namely **European Portuguese from Portugal (PT-PT) and American Portuguese from Brazil (PT-BR)**.
22
 
23
- To develop this **encoder**, which we named **Albertina PT-***, a strong model was used as a starting point, DeBERTa, and its pre-training was done over data sets of Portuguese, namely over a data set we gathered for PT-PT and over the BrWaC corpus for PT-BR.
24
- The performance of Albertina and competing models was assessed by evaluating them on prominent downstream language processing tasks adapted for Portuguese.
 
 
 
25
 
26
- Both **Albertina PT-PT and PT-BR versions are distributed free of charge and under the most permissive license possible** and can be run on consumer-grade hardware, thus seeking to contribute to the advancement of research and innovation in language technology for Portuguese.
 
 
 
27
 
28
- Please check the [Albertina PT-* article]() for more details.
 
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
- ## Model Description
32
 
33
- **This model card is for the Albertina-PT-BR** model with a total of 900M parameters, 24 layers and a hidden size of 1536.
34
 
35
- The Albertina-PT-BR is distributed free of charge under the same permissions defined for the training dataset, [BrWac](https://huggingface.co/datasets/brwac):
36
- *It is available solely for academic research purposes and not for commercial use.*
37
 
 
 
 
 
 
 
 
 
38
 
39
  # Training Data
40
 
41
- The **Albertina PT-PT** resorted to a data set that resulted from gathering some openly available corpora of European Portuguese from the following sources:
42
 
43
  - [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.
44
  - [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's official website. We retained its European Portuguese portion.
@@ -46,38 +72,43 @@ The **Albertina PT-PT** resorted to a data set that resulted from gathering some
46
  - [ParlamentoPT](https://www.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.
47
 
48
 
49
- The **Albertina PT-BR** resorted to the [BrWac](https://huggingface.co/datasets/brwac) data set.
50
 
51
 
52
  ## Preprocessing
53
 
54
- 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.
55
  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.
56
 
57
- # Training
 
58
 
59
  As codebase, we resorted to the [DeBERTa V2 XLarge](https://huggingface.co/microsoft/deberta-v2-xlarge), for English.
60
 
 
 
 
 
 
 
61
  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.
62
  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).
63
  We chose a learning rate of 1e-5 with linear decay and 10k warm-up steps based on the results of exploratory experiments.
64
  In total, around 200k training steps were taken across 50 epochs.
65
  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.
66
 
67
- To train **Albertina-PT-PT**, the data set was tokenized with the original DeBERTa tokenizer with a 128 token sequence truncation and dynamic padding.
68
- 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).
69
- Similarly to the PT-BR variant above, we opted for a learning rate of 1e-5 with linear decay and 10k warm-up steps.
70
- 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.
71
- 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.
72
 
73
  # Evaluation
74
 
75
- The models were evaluated on downstream tasks organized into two groups.
76
 
77
  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).
78
  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.
79
 
80
- ### ASSIN 2
 
81
 
82
  [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.
83
  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.
@@ -88,7 +119,7 @@ This data set supports the task of semantic textual similarity (STS), which cons
88
  | BERTimbau-large | 0.8913 | 0.8531 |
89
 
90
 
91
- ### GLUE tasks translated
92
 
93
  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**.
94
  We address four tasks from those in PLUE, namely:
@@ -113,6 +144,7 @@ We automatically translated the same four tasks from GLUE using [DeepL Translate
113
  | | | | | |
114
  | **Albertina-PT-BR** | 0.7942 | 0.4085 | 0.9048 | **0.8847** |
115
 
 
116
 
117
  # How to use
118
 
@@ -120,14 +152,15 @@ You can use this model directly with a pipeline for masked language modeling:
120
 
121
  ```python
122
  >>> from transformers import pipeline
123
- >>> unmasker = pipeline('fill-mask', model='PORTULAN/albertina-ptbr')
124
- >>> unmasker("culinária brasileira")
 
 
 
 
 
 
125
 
126
- [{'score': 0.5964823365211487, 'token': 34214, 'token_str': 'Angola', 'sequence': 'Países como Angola falam a língua portuguesa.'},
127
- {'score': 0.12712880969047546, 'token': 9959, 'token_str': 'Portugal', 'sequence': 'Países como Portugal falam a língua portuguesa.'},
128
- {'score': 0.07715518027544022, 'token': 30812, 'token_str': 'Macau', 'sequence': 'Países como Macau falam a língua portuguesa.'},
129
- {'score': 0.05533565580844879, 'token': 41164, 'token_str': 'Timor', 'sequence': 'Países como Timor falam a língua portuguesa.'},
130
- {'score': 0.02593935653567314, 'token': 9716, 'token_str': 'Cuba', 'sequence': 'Países como Cuba falam a língua portuguesa.'}]
131
 
132
  ```
133
 
@@ -137,8 +170,8 @@ The model can be used by fine-tuning it for a specific task:
137
  >>> from transformers import AutoTokenizer, AutoModelForSequenceClassification, TrainingArguments, Trainer
138
  >>> from datasets import load_dataset
139
 
140
- >>> model = AutoModelForSequenceClassification.from_pretrained("PORTULAN/albertina-ptbr", num_labels=2)
141
- >>> tokenizer = AutoTokenizer.from_pretrained("PORTULAN/albertina-ptbr")
142
  >>> dataset = load_dataset("PORTULAN/glueptpt", "rte")
143
 
144
  >>> def tokenize_function(examples):
@@ -146,7 +179,7 @@ The model can be used by fine-tuning it for a specific task:
146
 
147
  >>> tokenized_datasets = dataset.map(tokenize_function, batched=True)
148
 
149
- >>> training_args = TrainingArguments(output_dir="albertina-ptbr-rte", evaluation_strategy="epoch")
150
  >>> trainer = Trainer(
151
  ... model=model,
152
  ... args=training_args,
@@ -158,14 +191,19 @@ The model can be used by fine-tuning it for a specific task:
158
 
159
  ```
160
 
 
 
161
  # Citation
162
 
163
- If Albertina proves useful for your work, we kindly ask that you cite the following paper to acknowledge its contribution:
164
 
165
  ``` latex
166
  @misc{albertina-pt,
167
- title={Advancing Neural Encoding of Portuguese with Transformer Albertina PT-*},
168
- author={João Rodrigues and Luís Gomes and João Silva and António Branco and Rodrigo Santos and Henrique Lopes and Tomás Osório},
 
 
 
169
  year={2023},
170
  eprint={?},
171
  archivePrefix={arXiv},
@@ -173,6 +211,11 @@ If Albertina proves useful for your work, we kindly ask that you cite the follow
173
  }
174
  ```
175
 
 
 
176
  # Acknowledgments
177
 
178
- TODO
 
 
 
 
1
  ---
2
+ language:
3
+ - pt
4
+ tags:
5
+ - albertina-pt*
6
+ - albertina-ptpt
7
+ - albertina-ptbr
8
+ - fill-mask
9
+ license: mit
10
  datasets:
11
  - oscar
12
  - brwac
13
  - europarl
14
  widget:
15
+ - text: "A culinária portuguesa é rica em sabores e [MASK], tornando-se um dos maiores tesouros do país."
16
  ---
17
 
18
 
19
+ # Albertina PT-PT
20
 
21
+ **Albertina PT-*** is a foundation, large language model for the **Portuguese language**.
22
 
23
+ It is an **encoder** of the BERT family, based on a Transformer architecture,
24
+ developed over the DeBERTa model, with most competitive performance for this language.
25
+ It has different versions that were trained for different variants of Portuguese (PT),
26
+ namely the European variant from Portugal (PT-PT) and the American variant from Brazil (PT-BR),
27
+ and it is distributed free of charge and under a most permissible license.
28
 
29
+ **Albertina PT-PT** is the version for **European Portuguese from Portugal**,
30
+ and to the best of our knowledge, at the time of its initial distribution,
31
+ it was the first competitive encoder for this language and variant
32
+ that had been made publicly available and distributed for reuse.
33
 
34
+ It was developped by a joint team from the University of Lisbon and the University of Porto, Portugal.
35
+ For further details, check the respective publication:
36
 
37
+ ``` latex
38
+ @misc{albertina-pt,
39
+ title={Advancing Neural Encoding of Portuguese
40
+ with Transformer Albertina PT-*},
41
+ author={João Rodrigues and Luís Gomes and João Silva and
42
+ António Branco and Rodrigo Santos and
43
+ Henrique Lopes Cardoso and Tomás Osório},
44
+ year={2023},
45
+ eprint={?},
46
+ archivePrefix={arXiv},
47
+ primaryClass={cs.CL}
48
+ }
49
+ ```
50
 
51
+ Please use the above cannonical reference when using or citing this model.
52
 
53
+ <br>
54
 
 
 
55
 
56
+ # Model Description
57
+
58
+ **This model card is for Albertina-PT-PT**, with 900M parameters, 24 layers and a hidden size of 1536.
59
+
60
+ This model is distributed free of charge under the [MIT](https://choosealicense.com/licenses/mit/) license (permits commercial use, distribution, modification and private use).
61
+
62
+
63
+ <br>
64
 
65
  # Training Data
66
 
67
+ **Albertina PT-PT** was trained over a data set that resulted from gathering some openly available corpora of European Portuguese from the following sources:
68
 
69
  - [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.
70
  - [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.
 
72
  - [ParlamentoPT](https://www.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.
73
 
74
 
75
+ **Albertina PT-BR**, in turn, was trained over the [BrWac](https://huggingface.co/datasets/brwac) data set.
76
 
77
 
78
  ## Preprocessing
79
 
80
+ 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.
81
  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.
82
 
83
+
84
+ ## Training
85
 
86
  As codebase, we resorted to the [DeBERTa V2 XLarge](https://huggingface.co/microsoft/deberta-v2-xlarge), for English.
87
 
88
+ To train **Albertina-PT-PT**, the data set was tokenized with the original DeBERTa tokenizer with a 128 token sequence truncation and dynamic padding.
89
+ 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).
90
+ Similarly to the PT-BR variant above, we opted for a learning rate of 1e-5 with linear decay and 10k warm-up steps.
91
+ 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.
92
+ 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.
93
+
94
  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.
95
  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).
96
  We chose a learning rate of 1e-5 with linear decay and 10k warm-up steps based on the results of exploratory experiments.
97
  In total, around 200k training steps were taken across 50 epochs.
98
  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.
99
 
100
+
101
+ <br>
 
 
 
102
 
103
  # Evaluation
104
 
105
+ The two model versions were evaluated on downstream tasks organized into two groups.
106
 
107
  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).
108
  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.
109
 
110
+
111
+ ## ASSIN 2
112
 
113
  [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.
114
  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.
 
119
  | BERTimbau-large | 0.8913 | 0.8531 |
120
 
121
 
122
+ ## GLUE tasks translated
123
 
124
  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**.
125
  We address four tasks from those in PLUE, namely:
 
144
  | | | | | |
145
  | **Albertina-PT-BR** | 0.7942 | 0.4085 | 0.9048 | **0.8847** |
146
 
147
+ <br>
148
 
149
  # How to use
150
 
 
152
 
153
  ```python
154
  >>> from transformers import pipeline
155
+ >>> unmasker = pipeline('fill-mask', model='PORTULAN/albertina-ptpt')
156
+ >>> unmasker("A culinária portuguesa é rica em sabores e [MASK], tornando-se um dos maiores tesouros do país.")
157
+
158
+ [{'score': 0.9166129231452942, 'token': 23395, 'token_str': 'aromas', 'sequence': 'A culinária portuguesa é rica em sabores e aromas, tornando-se um dos maiores tesouros do país.'},
159
+ {'score': 0.022932516410946846, 'token': 10392, 'token_str': 'costumes', 'sequence': 'A culinária portuguesa é rica em sabores e costumes, tornando-se um dos maiores tesouros do país.'},
160
+ {'score': 0.013932268135249615, 'token': 21925, 'token_str': 'cores', 'sequence': 'A culinária portuguesa é rica em sabores e cores, tornando-se um dos maiores tesouros do país.'},
161
+ {'score': 0.009870869107544422, 'token': 22647, 'token_str': 'nuances', 'sequence': 'A culinária portuguesa é rica em sabores e nuances, tornando-se um dos maiores tesouros do país.'},
162
+ {'score': 0.007260020822286606, 'token': 12881, 'token_str': 'aroma', 'sequence': 'A culinária portuguesa é rica em sabores e aroma, tornando-se um dos maiores tesouros do país.'}]
163
 
 
 
 
 
 
164
 
165
  ```
166
 
 
170
  >>> from transformers import AutoTokenizer, AutoModelForSequenceClassification, TrainingArguments, Trainer
171
  >>> from datasets import load_dataset
172
 
173
+ >>> model = AutoModelForSequenceClassification.from_pretrained("PORTULAN/albertina-ptpt", num_labels=2)
174
+ >>> tokenizer = AutoTokenizer.from_pretrained("PORTULAN/albertina-ptpt")
175
  >>> dataset = load_dataset("PORTULAN/glueptpt", "rte")
176
 
177
  >>> def tokenize_function(examples):
 
179
 
180
  >>> tokenized_datasets = dataset.map(tokenize_function, batched=True)
181
 
182
+ >>> training_args = TrainingArguments(output_dir="albertina-ptpt-rte", evaluation_strategy="epoch")
183
  >>> trainer = Trainer(
184
  ... model=model,
185
  ... args=training_args,
 
191
 
192
  ```
193
 
194
+ <br>
195
+
196
  # Citation
197
 
198
+ When using or citing this model, kindly cite the following publication:
199
 
200
  ``` latex
201
  @misc{albertina-pt,
202
+ title={Advancing Neural Encoding of Portuguese
203
+ with Transformer Albertina PT-*},
204
+ author={João Rodrigues and Luís Gomes and João Silva and
205
+ António Branco and Rodrigo Santos and
206
+ Henrique Lopes Cardoso and Tomás Osório},
207
  year={2023},
208
  eprint={?},
209
  archivePrefix={arXiv},
 
211
  }
212
  ```
213
 
214
+ <br>
215
+
216
  # Acknowledgments
217
 
218
+ The research reported here was partially supported by: PORTULAN CLARIN—Research Infrastructure for the Science and Technology of Language,
219
+ funded by Lisboa 2020, Alentejo 2020 and FCT—Fundação para a Ciência e Tecnologia under the
220
+ 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
221
+ grant CPCA-IAC/AV/478394/2022; and 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.