bsc-temu commited on
Commit
c512b0b
1 Parent(s): 6a00662

update readme

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