bsc-temu
commited on
Commit
·
a08e306
1
Parent(s):
9777f8c
remove description
Browse files
README.md
CHANGED
@@ -8,239 +8,19 @@ license: apache-2.0
|
|
8 |
---
|
9 |
# BERTa: RoBERTa-based Catalan language model
|
10 |
|
11 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
|
|
13 |
|
14 |
```python
|
15 |
from transformers import AutoModel
|
16 |
model = AutoModel.from_pretrained("BSC-TeMU/roberta-base-ca-cased")
|
17 |
```
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
## BibTeX citation
|
23 |
-
|
24 |
-
If you use any of these resources (datasets or models) in your work, please cite our latest paper:
|
25 |
-
|
26 |
-
```bibtex
|
27 |
-
@inproceedings{armengol-estape-etal-2021-multilingual,
|
28 |
-
title = "Are Multilingual Models the Best Choice for Moderately Under-resourced Languages? {A} Comprehensive Assessment for {C}atalan",
|
29 |
-
author = "Armengol-Estap{\'e}, Jordi and
|
30 |
-
Carrino, Casimiro Pio and
|
31 |
-
Rodriguez-Penagos, Carlos and
|
32 |
-
de Gibert Bonet, Ona and
|
33 |
-
Armentano-Oller, Carme and
|
34 |
-
Gonzalez-Agirre, Aitor and
|
35 |
-
Melero, Maite and
|
36 |
-
Villegas, Marta",
|
37 |
-
booktitle = "Findings of the Association for Computational Linguistics: ACL-IJCNLP 2021",
|
38 |
-
month = aug,
|
39 |
-
year = "2021",
|
40 |
-
address = "Online",
|
41 |
-
publisher = "Association for Computational Linguistics",
|
42 |
-
url = "https://aclanthology.org/2021.findings-acl.437",
|
43 |
-
doi = "10.18653/v1/2021.findings-acl.437",
|
44 |
-
pages = "4933--4946",
|
45 |
-
}
|
46 |
-
```
|
47 |
-
|
48 |
-
|
49 |
-
## Model description
|
50 |
-
|
51 |
-
BERTa is a transformer-based masked language model for the Catalan language.
|
52 |
-
It is based on the [RoBERTA](https://github.com/pytorch/fairseq/tree/master/examples/roberta) base model
|
53 |
-
and has been trained on a medium-size corpus collected from publicly available corpora and crawlers.
|
54 |
-
|
55 |
-
## Training corpora and preprocessing
|
56 |
-
|
57 |
-
The training corpus consists of several corpora gathered from web crawling and public corpora.
|
58 |
-
|
59 |
-
The publicly available corpora are:
|
60 |
-
|
61 |
-
1. the Catalan part of the [DOGC](http://opus.nlpl.eu/DOGC-v2.php) corpus, a set of documents from the Official Gazette of the Catalan Government
|
62 |
-
|
63 |
-
2. the [Catalan Open Subtitles](http://opus.nlpl.eu/download.php?f=OpenSubtitles/v2018/mono/OpenSubtitles.raw.ca.gz), a collection of translated movie subtitles
|
64 |
-
|
65 |
-
3. the non-shuffled version of the Catalan part of the [OSCAR](https://traces1.inria.fr/oscar/) corpus \\\\cite{suarez2019asynchronous},
|
66 |
-
a collection of monolingual corpora, filtered from [Common Crawl](https://commoncrawl.org/about/)
|
67 |
-
|
68 |
-
4. The [CaWac](http://nlp.ffzg.hr/resources/corpora/cawac/) corpus, a web corpus of Catalan built from the .cat top-level-domain in late 2013
|
69 |
-
the non-deduplicated version
|
70 |
-
|
71 |
-
5. the [Catalan Wikipedia articles](https://ftp.acc.umu.se/mirror/wikimedia.org/dumps/cawiki/20200801/) downloaded on 18-08-2020.
|
72 |
-
|
73 |
-
The crawled corpora are:
|
74 |
-
|
75 |
-
6. The Catalan General Crawling, obtained by crawling the 500 most popular .cat and .ad domains
|
76 |
-
7. the Catalan Government Crawling, obtained by crawling the .gencat domain and subdomains, belonging to the Catalan Government
|
77 |
-
|
78 |
-
8. the ACN corpus with 220k news items from March 2015 until October 2020, crawled from the [Catalan News Agency](https://www.acn.cat/)
|
79 |
-
|
80 |
-
To obtain a high-quality training corpus, each corpus have preprocessed with a pipeline of operations, including among the others,
|
81 |
-
sentence splitting, language detection, filtering of bad-formed sentences and deduplication of repetitive contents.
|
82 |
-
During the process, we keep document boundaries are kept.
|
83 |
-
Finally, the corpora are concatenated and further global deduplication among the corpora is applied.
|
84 |
-
The final training corpus consists of about 1,8B tokens.
|
85 |
-
|
86 |
-
|
87 |
-
## Tokenization and pretraining
|
88 |
-
|
89 |
-
The training corpus has been tokenized using a byte version of [Byte-Pair Encoding (BPE)](https://github.com/openai/gpt-2)
|
90 |
-
used in the original [RoBERTA](https://github.com/pytorch/fairseq/tree/master/examples/roberta) model with a vocabulary size of 52,000 tokens.
|
91 |
-
The BERTa pretraining consists of a masked language model training that follows the approach employed for the RoBERTa base model
|
92 |
-
with the same hyperparameters as in the original work.
|
93 |
-
The training lasted a total of 48 hours with 16 NVIDIA V100 GPUs of 16GB DDRAM.
|
94 |
-
|
95 |
-
## Evaluation
|
96 |
-
|
97 |
-
## CLUB benchmark
|
98 |
-
|
99 |
-
The BERTa model has been fine-tuned on the downstream tasks of the Catalan Language Understanding Evaluation benchmark (CLUB),
|
100 |
-
that has been created along with the model.
|
101 |
-
|
102 |
-
It contains the following tasks and their related datasets:
|
103 |
-
|
104 |
-
1. Part-of-Speech Tagging (POS)
|
105 |
-
|
106 |
-
Catalan-Ancora: from the [Universal Dependencies treebank](https://github.com/UniversalDependencies/UD_Catalan-AnCora) of the well-known Ancora corpus
|
107 |
-
|
108 |
-
2. Named Entity Recognition (NER)
|
109 |
-
|
110 |
-
**[AnCora Catalan 2.0.0](https://zenodo.org/record/4762031#.YKaFjqGxWUk)**: extracted named entities from the original [Ancora](https://doi.org/10.5281/zenodo.4762030) version,
|
111 |
-
filtering out some unconventional ones, like book titles, and transcribed them into a standard CONLL-IOB format
|
112 |
-
|
113 |
-
3. Text Classification (TC)
|
114 |
-
|
115 |
-
**[TeCla](https://doi.org/10.5281/zenodo.4627197)**: consisting of 137k news pieces from the Catalan News Agency ([ACN](https://www.acn.cat/)) corpus
|
116 |
-
|
117 |
-
4. Semantic Textual Similarity (STS)
|
118 |
-
|
119 |
-
**[Catalan semantic textual similarity](https://doi.org/10.5281/zenodo.4529183)**: consisting of more than 3000 sentence pairs, annotated with the semantic similarity between them,
|
120 |
-
scraped from the [Catalan Textual Corpus](https://doi.org/10.5281/zenodo.4519349)
|
121 |
-
|
122 |
-
5. Question Answering (QA):
|
123 |
-
|
124 |
-
**[ViquiQuAD](https://doi.org/10.5281/zenodo.4562344)**: consisting of more than 15,000 questions outsourced from Catalan Wikipedia randomly chosen from a set of 596 articles that were originally written in Catalan.
|
125 |
-
|
126 |
-
**[XQuAD](https://doi.org/10.5281/zenodo.4526223)**: the Catalan translation of XQuAD, a multilingual collection of manual translations of 1,190 question-answer pairs from English Wikipedia used only as a _test set_
|
127 |
-
|
128 |
-
Here are the train/dev/test splits of the datasets:
|
129 |
-
|
130 |
-
| Task (Dataset) | Total | Train | Dev | Test |
|
131 |
-
|:--|:--|:--|:--|:--|
|
132 |
-
| NER (Ancora) |13,581 | 10,628 | 1,427 | 1,526 |
|
133 |
-
| POS (Ancora)| 16,678 | 13,123 | 1,709 | 1,846 |
|
134 |
-
| STS | 3,073 | 2,073 | 500 | 500 |
|
135 |
-
| TC (TeCla) | 137,775 | 110,203 | 13,786 | 13,786|
|
136 |
-
| QA (ViquiQuAD) | 14,239 | 11,255 | 1,492 | 1,429 |
|
137 |
-
|
138 |
-
|
139 |
-
_The fine-tuning on downstream tasks have been performed with the HuggingFace [**Transformers**](https://github.com/huggingface/transformers) library_
|
140 |
-
|
141 |
-
## Results
|
142 |
-
|
143 |
-
Below the evaluation results on the CLUB tasks compared with the multilingual mBERT, XLM-RoBERTa models and
|
144 |
-
the Catalan WikiBERT-ca model
|
145 |
-
|
146 |
-
|
147 |
-
| Task | NER (F1) | POS (F1) | STS (Pearson) | TC (accuracy) | QA (ViquiQuAD) (F1/EM) | QA (XQuAD) (F1/EM) |
|
148 |
-
| ------------|:-------------:| -----:|:------|:-------|:------|:----|
|
149 |
-
| BERTa | **88.13** | **98.97** | **79.73** | **74.16** | **86.97/72.29** | **68.89/48.87** |
|
150 |
-
| mBERT | 86.38 | 98.82 | 76.34 | 70.56 | 86.97/72.22 | 67.15/46.51 |
|
151 |
-
| XLM-RoBERTa | 87.66 | 98.89 | 75.40 | 71.68 | 85.50/70.47 | 67.10/46.42 |
|
152 |
-
| WikiBERT-ca | 77.66 | 97.60 | 77.18 | 73.22 | 85.45/70.75 | 65.21/36.60 |
|
153 |
-
|
154 |
-
|
155 |
-
## Intended uses & limitations
|
156 |
-
The model is ready-to-use only for masked language modelling to perform the Fill Mask task (try the inference API or read the next section)
|
157 |
-
However, the is intended to be fine-tuned on non-generative downstream tasks such as Question Answering, Text Classification or Named Entity Recognition.
|
158 |
-
|
159 |
-
---
|
160 |
-
|
161 |
-
## Using BERTa
|
162 |
-
## Load model and tokenizer
|
163 |
-
|
164 |
-
``` python
|
165 |
-
from transformers import AutoTokenizer, AutoModelForMaskedLM
|
166 |
-
|
167 |
-
tokenizer = AutoTokenizer.from_pretrained("bsc/roberta-base-ca-cased")
|
168 |
-
|
169 |
-
model = AutoModelForMaskedLM.from_pretrained("bsc/roberta-base-ca-cased")
|
170 |
-
```
|
171 |
-
|
172 |
-
## Fill Mask task
|
173 |
-
|
174 |
-
Below, an example of how to use the masked language modelling task with a pipeline.
|
175 |
-
|
176 |
-
```python
|
177 |
-
>>> from transformers import pipeline
|
178 |
-
>>> unmasker = pipeline('fill-mask', model='bsc/roberta-base-ca-cased')
|
179 |
-
>>> unmasker("Situada a la costa de la mar Mediterrània, <mask> s'assenta en una plana formada "
|
180 |
-
"entre els deltes de les desembocadures dels rius Llobregat, al sud-oest, "
|
181 |
-
"i Besòs, al nord-est, i limitada pel sud-est per la línia de costa,"
|
182 |
-
"i pel nord-oest per la serralada de Collserola "
|
183 |
-
"(amb el cim del Tibidabo, 516,2 m, com a punt més alt) que segueix paral·lela "
|
184 |
-
"la línia de costa encaixant la ciutat en un perímetre molt definit.")
|
185 |
-
|
186 |
-
[
|
187 |
-
{
|
188 |
-
"sequence": " Situada a la costa de la mar Mediterrània, <mask> s'assenta en una plana formada "
|
189 |
-
"entre els deltes de les desembocadures dels rius Llobregat, al sud-oest, "
|
190 |
-
"i Besòs, al nord-est, i limitada pel sud-est per la línia de costa,"
|
191 |
-
"i pel nord-oest per la serralada de Collserola "
|
192 |
-
"(amb el cim del Tibidabo, 516,2 m, com a punt més alt) que segueix paral·lela "
|
193 |
-
"la línia de costa encaixant la ciutat en un perímetre molt definit.",
|
194 |
-
"score": 0.4177263379096985,
|
195 |
-
"token": 734,
|
196 |
-
"token_str": " Barcelona"
|
197 |
-
},
|
198 |
-
{
|
199 |
-
"sequence": " Situada a la costa de la mar Mediterrània, <mask> s'assenta en una plana formada "
|
200 |
-
"entre els deltes de les desembocadures dels rius Llobregat, al sud-oest, "
|
201 |
-
"i Besòs, al nord-est, i limitada pel sud-est per la línia de costa,"
|
202 |
-
"i pel nord-oest per la serralada de Collserola "
|
203 |
-
"(amb el cim del Tibidabo, 516,2 m, com a punt més alt) que segueix paral·lela "
|
204 |
-
"la línia de costa encaixant la ciutat en un perímetre molt definit.",
|
205 |
-
"score": 0.10696165263652802,
|
206 |
-
"token": 3849,
|
207 |
-
"token_str": " Badalona"
|
208 |
-
},
|
209 |
-
{
|
210 |
-
"sequence": " Situada a la costa de la mar Mediterrània, <mask> s'assenta en una plana formada "
|
211 |
-
"entre els deltes de les desembocadures dels rius Llobregat, al sud-oest, "
|
212 |
-
"i Besòs, al nord-est, i limitada pel sud-est per la línia de costa,"
|
213 |
-
"i pel nord-oest per la serralada de Collserola "
|
214 |
-
"(amb el cim del Tibidabo, 516,2 m, com a punt més alt) que segueix paral·lela "
|
215 |
-
"la línia de costa encaixant la ciutat en un perímetre molt definit.",
|
216 |
-
"score": 0.08135009557008743,
|
217 |
-
"token": 19349,
|
218 |
-
"token_str": " Collserola"
|
219 |
-
},
|
220 |
-
{
|
221 |
-
"sequence": " Situada a la costa de la mar Mediterrània, <mask> s'assenta en una plana formada "
|
222 |
-
"entre els deltes de les desembocadures dels rius Llobregat, al sud-oest, "
|
223 |
-
"i Besòs, al nord-est, i limitada pel sud-est per la línia de costa,"
|
224 |
-
"i pel nord-oest per la serralada de Collserola "
|
225 |
-
"(amb el cim del Tibidabo, 516,2 m, com a punt més alt) que segueix paral·lela "
|
226 |
-
"la línia de costa encaixant la ciutat en un perímetre molt definit.",
|
227 |
-
"score": 0.07330769300460815,
|
228 |
-
"token": 4974,
|
229 |
-
"token_str": " Terrassa"
|
230 |
-
},
|
231 |
-
{
|
232 |
-
"sequence": " Situada a la costa de la mar Mediterrània, <mask> s'assenta en una plana formada "
|
233 |
-
"entre els deltes de les desembocadures dels rius Llobregat, al sud-oest, "
|
234 |
-
"i Besòs, al nord-est, i limitada pel sud-est per la línia de costa,"
|
235 |
-
"i pel nord-oest per la serralada de Collserola "
|
236 |
-
"(amb el cim del Tibidabo, 516,2 m, com a punt més alt) que segueix paral·lela "
|
237 |
-
"la línia de costa encaixant la ciutat en un perímetre molt definit.",
|
238 |
-
"score": 0.03317456692457199,
|
239 |
-
"token": 14333,
|
240 |
-
"token_str": " Gavà"
|
241 |
-
}
|
242 |
-
]
|
243 |
-
```
|
244 |
-
|
245 |
-
|
246 |
-
|
|
|
8 |
---
|
9 |
# BERTa: RoBERTa-based Catalan language model
|
10 |
|
11 |
+
<font size="+2">
|
12 |
+
<strong>
|
13 |
+
<span style="color:red">
|
14 |
+
WARNING
|
15 |
+
</span>
|
16 |
+
</strong>
|
17 |
+
</font>
|
18 |
|
19 |
+
This repository is now superseded by [BSC-TeMU/roberta-base-ca-cased](https://huggingface.co/BSC-TeMU/roberta-base-ca-cased). Future updates will be released in the new repository, so it is highly recommended to load the model using the new path:
|
20 |
|
21 |
```python
|
22 |
from transformers import AutoModel
|
23 |
model = AutoModel.from_pretrained("BSC-TeMU/roberta-base-ca-cased")
|
24 |
```
|
25 |
|
26 |
+
From now on, all models and datasets from the BSC's Text Mining Unit will be published on the [official organization account](https://huggingface.co/BSC-TeMU).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|