Asier Gutiérrez Fandiño commited on
Commit
b8dc262
1 Parent(s): f53d5e2

Initial commit

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