jarodrigues commited on
Commit
fa503e1
1 Parent(s): 80042b0

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +146 -0
README.md ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - pt
4
+ tags:
5
+ - albertina-pt-*
6
+ - albertina-pt-pt
7
+ - albertina-pt-br
8
+ - fill-mask
9
+ license: mit
10
+ datasets:
11
+ - oscar
12
+ - brwac
13
+ - europarl
14
+ ---
15
+
16
+
17
+ # Albertina PT-* Model
18
+
19
+ 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)**.
20
+
21
+ 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.
22
+ The performance of Albertina and competing models was assessed by evaluating them on prominent downstream language processing tasks adapted for Portuguese.
23
+
24
+ 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.
25
+
26
+ Please check the [Albertina PT-* article]() for more details.
27
+
28
+
29
+ ## Model Description
30
+
31
+ **This model card is the Albertina-PT-PT** model with a total of 900M parameters, 24 layers and a hidden size of 1536.
32
+
33
+ The Albertina-PT-PT is distributed free of charge under the [MIT](https://choosealicense.com/licenses/mit/) license (permits commercial use, distribution, modification and private use).
34
+
35
+
36
+ # Training Data
37
+
38
+ The **Albertina PT-PT** resorted to a data set that resulted from gathering some openly available corpora of European Portuguese from the following sources:
39
+
40
+ - [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.
41
+ - [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.
42
+ - [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.
43
+ - [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.
44
+
45
+
46
+ The **Albertina PT-BR** resorted to the [BrWac](https://huggingface.co/datasets/brwac) data set.
47
+
48
+
49
+ ## Preprocessing
50
+
51
+ 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.
52
+ 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.
53
+
54
+ # Training
55
+
56
+ As codebase, we resorted to the [DeBERTa V2 XLarge](https://huggingface.co/microsoft/deberta-v2-xlarge), for English.
57
+
58
+ 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.
59
+ The model was trained using the maximum available memory capacity -- it 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 -- resulting in a batch size of 896 samples (56 samples per GPU without gradient accumulation steps).
60
+ We chose a learning rate of 1e-5 with linear decay and 10k warm-up steps based on the results of exploratory experiments.
61
+ In total, around 200k training steps were taken across 50 epochs.
62
+ Additionally, we used the standard BERT masking procedure with a 15% masking probability for each example.
63
+
64
+ To train **Albertina-PT-PT**, the data set was tokenized with the original DeBERTa tokenizer with a 128 token sequence truncation and dynamic padding.
65
+ The model was trained using the maximum available memory capacity -- it was trained for 3 days on a2-highgpu-8gb Google Cloud A2 VMs with 8 GPUs, 96 vCPUs and 680 GB of RAM -- 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).
66
+ Similarly to the PT-BR variant above, we opted for a learning rate of 1e-5 with linear decay and 10k warm-up steps.
67
+ 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.
68
+
69
+
70
+ # Evaluation
71
+
72
+ The models were evaluated on downstream tasks organized into two groups.
73
+
74
+ 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).
75
+ 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.
76
+
77
+ ## ASSIN 2
78
+
79
+ [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.
80
+ This data set supports the task of semantic text 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.
81
+
82
+ | Model | RTE (Accuracy) | STS (Pearson)|
83
+ |---------------------|----------------|--------------|
84
+ | **Albertina-PT-BR** | **0.9130** | **0.8676** |
85
+ | BERTimbau-large | 0.8913 | 0.8531 |
86
+
87
+
88
+ ## GLUE tasks translated
89
+
90
+ 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**.
91
+ We address four tasks from those in PLUE, namely:
92
+ - two similarity tasks: MRPC, for detecting whether two sentences are paraphrases of each other, and STS-B, for semantic textual similarity;
93
+ - and two inference tasks: RTE, for recognizing textual entailment and WNLI, for coreference and natural language inference.
94
+
95
+
96
+ | Model | RTE (Accuracy) | WNLI (Accuracy)| MRPC (F1) | STS-B (Pearson) |
97
+ |---------------------|----------------|----------------|-----------|-----------------|
98
+ | **Albertina-PT-BR** | 0.7545 | 0.4601 | 0.9071 | **0.8910** |
99
+ | BERTimbau-large | 0.6546 | **0.5634** | 0.887 | 0.8842 |
100
+ | | | | | |
101
+ | **Albertina-PT-PT** | **0.7960** | 0.4507 | **0.9151**| 0.8799 |
102
+
103
+
104
+ We resorted to [GLUE-PT](https://huggingface.co/datasets/PORTULAN/glueptpt), a **PT-PT version of the GLUE** benchmark.
105
+ 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.
106
+
107
+ | Model | RTE (Accuracy) | WNLI (Accuracy)| MRPC (F1) | STS-B (Pearson) |
108
+ |---------------------|----------------|----------------|-----------|-----------------|
109
+ | **Albertina-PT-PT** | **0.8339** | **0.4225** | **0.9171**| 0.8801 |
110
+ | | | | | |
111
+ | **Albertina-PT-BR** | 0.7942 | 0.4085 | 0.9048 | **0.8847** |
112
+
113
+
114
+ ## How to use
115
+
116
+ You can use this model directly with a pipeline for masked language modeling:
117
+
118
+ ```python
119
+ >>> from transformers import pipeline
120
+ >>> unmasker = pipeline('fill-mask', model='portulan-albertina-pt-pt')
121
+ >>> unmasker("Países como [MASK] falam a língua portuguesa.")
122
+
123
+ [{'score': 0.5964823365211487, 'token': 34214, 'token_str': 'Angola', 'sequence': 'Países como Angola falam a língua portuguesa.'},
124
+ {'score': 0.12712880969047546, 'token': 9959, 'token_str': 'Portugal', 'sequence': 'Países como Portugal falam a língua portuguesa.'},
125
+ {'score': 0.07715518027544022, 'token': 30812, 'token_str': 'Macau', 'sequence': 'Países como Macau falam a língua portuguesa.'},
126
+ {'score': 0.05533565580844879, 'token': 41164, 'token_str': 'Timor', 'sequence': 'Países como Timor falam a língua portuguesa.'},
127
+ {'score': 0.02593935653567314, 'token': 9716, 'token_str': 'Cuba', 'sequence': 'Países como Cuba falam a língua portuguesa.'}]
128
+
129
+ ```
130
+
131
+
132
+ # Citation
133
+
134
+ If Albertina proves useful for your work, we kindly ask that you cite the following paper to acknowledge its contribution:
135
+
136
+ ``` latex
137
+ @misc{albertina-pt,
138
+ title={Advancing Neural Encoding of Portuguese with Transformer Albertina PT-*},
139
+ 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},
140
+ year={2023},
141
+ eprint={?},
142
+ archivePrefix={arXiv},
143
+ primaryClass={cs.CL}
144
+ }
145
+ ```
146
+