gonzalez-agirre commited on
Commit
64436b5
1 Parent(s): b511b80

Upload model.

Browse files
README.md CHANGED
@@ -1,3 +1,129 @@
1
  ---
 
 
 
 
 
 
2
  license: apache-2.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ pipeline_tag: text-classification
3
+
4
+ language:
5
+
6
+ - ca
7
+
8
  license: apache-2.0
9
+
10
+ tags:
11
+
12
+ - "catalan"
13
+
14
+ - "semantic textual similarity"
15
+
16
+ - "sts-ca"
17
+
18
+ - "CaText"
19
+
20
+ - "Catalan Textual Corpus"
21
+
22
+ datasets:
23
+
24
+ - "projecte-aina/sts-ca"
25
+
26
+ metrics:
27
+
28
+ - "combined_score"
29
+
30
+ model-index:
31
+
32
+ - name: roberta-base-ca-v2-cased-sts
33
+ results:
34
+ - task:
35
+ type: text-classification
36
+ dataset:
37
+ type: projecte-aina/sts-ca
38
+ name: STS-ca
39
+ metrics:
40
+ - name: Combined score
41
+ type: combined_score
42
+ value: 0.7907
43
+
44
  ---
45
+
46
+ # Catalan BERTa-v2 (roberta-base-ca-v2) finetuned for Semantic Textual Similarity.
47
+
48
+ The **roberta-base-ca-v2-cased-sts** is a Semantic Textual Similarity (STS) model for the Catalan language fine-tuned from the [roberta-base-ca-v2](https://huggingface.co/projecte-aina/roberta-base-ca-v2) model, a [RoBERTa](https://arxiv.org/abs/1907.11692) base model pre-trained on a medium-size corpus collected from publicly available corpora and crawlers (check the roberta-base-ca-v2 model card for more details).
49
+
50
+ ## Datasets
51
+ We used the STS dataset in Catalan called [STS-ca](https://huggingface.co/datasets/projecte-aina/sts-ca) for training and evaluation.
52
+
53
+ ## Evaluation and results
54
+ We evaluated the _roberta-base-ca-v2-cased-sts_ on the STS-ca test set against standard multilingual and monolingual baselines:
55
+
56
+ | Model | STS-ca (Combined score) |
57
+ | ------------|:-------------|
58
+ | roberta-base-ca-v2-cased-sts | 79.07 |
59
+ | roberta-base-ca-cased-sts | **80.19** |
60
+ | mBERT | 74.26 |
61
+ | XLM-RoBERTa | 61.61 |
62
+
63
+
64
+
65
+ For more details, check the fine-tuning and evaluation scripts in the official [GitHub repository](https://github.com/projecte-aina/club).
66
+
67
+ ## How to use
68
+ To get the correct<sup>1</sup> model's prediction scores with values between 0.0 and 5.0, use the following code:
69
+
70
+ ```python
71
+ from transformers import pipeline, AutoTokenizer
72
+ from scipy.special import logit
73
+
74
+ model = 'projecte-aina/roberta-base-ca-v2-cased-sts'
75
+ tokenizer = AutoTokenizer.from_pretrained(model)
76
+ pipe = pipeline('text-classification', model=model, tokenizer=tokenizer)
77
+
78
+ def prepare(sentence_pairs):
79
+ sentence_pairs_prep = []
80
+ for s1, s2 in sentence_pairs:
81
+ sentence_pairs_prep.append(f"{tokenizer.cls_token} {s1}{tokenizer.sep_token}{tokenizer.sep_token} {s2}{tokenizer.sep_token}")
82
+ return sentence_pairs_prep
83
+
84
+ sentence_pairs = [("El llibre va caure per la finestra.", "El llibre va sortir volant."),
85
+ ("M'agrades.", "T'estimo."),
86
+ ("M'agrada el sol i la calor", "A la Garrotxa plou molt.")]
87
+
88
+ predictions = pipe(prepare(sentence_pairs), add_special_tokens=False)
89
+
90
+ # convert back to scores to the original 1 and 5 interval
91
+ for prediction in predictions:
92
+ prediction['score'] = logit(prediction['score'])
93
+ print(predictions)
94
+ ```
95
+ Expected output:
96
+ ```
97
+ [{'label': 'LABEL_0', 'score': 2.2975975792221486},
98
+ {'label': 'LABEL_0', 'score': 2.4812691815397376},
99
+ {'label': 'LABEL_0', 'score': 1.090076983490159}]
100
+ ```
101
+
102
+ <sup>1</sup> _**avoid using the widget** scores since they are normalized and do not reflect the original annotation values._
103
+
104
+ ## Citing
105
+ If you use any of these resources (datasets or models) in your work, please cite our latest paper:
106
+ ```bibtex
107
+ @inproceedings{armengol-estape-etal-2021-multilingual,
108
+ title = "Are Multilingual Models the Best Choice for Moderately Under-resourced Languages? {A} Comprehensive Assessment for {C}atalan",
109
+ author = "Armengol-Estap{\'e}, Jordi and
110
+ Carrino, Casimiro Pio and
111
+ Rodriguez-Penagos, Carlos and
112
+ de Gibert Bonet, Ona and
113
+ Armentano-Oller, Carme and
114
+ Gonzalez-Agirre, Aitor and
115
+ Melero, Maite and
116
+ Villegas, Marta",
117
+ booktitle = "Findings of the Association for Computational Linguistics: ACL-IJCNLP 2021",
118
+ month = aug,
119
+ year = "2021",
120
+ address = "Online",
121
+ publisher = "Association for Computational Linguistics",
122
+ url = "https://aclanthology.org/2021.findings-acl.437",
123
+ doi = "10.18653/v1/2021.findings-acl.437",
124
+ pages = "4933--4946",
125
+ }
126
+ ```
127
+
128
+ ### Funding
129
+ This work was funded by the [Catalan Government](https://politiquesdigitals.gencat.cat/en/inici/index.html) within the framework of the [AINA project.](https://politiquesdigitals.gencat.cat/ca/economia/catalonia-ai/aina).
config.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "projecte-aina/roberta-base-ca-v2-cased-sts",
3
+ "architectures": [
4
+ "RobertaForSequenceClassification"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "bos_token_id": 0,
8
+ "eos_token_id": 2,
9
+ "finetuning_task": "stsb",
10
+ "gradient_checkpointing": false,
11
+ "hidden_act": "gelu",
12
+ "hidden_dropout_prob": 0.1,
13
+ "hidden_size": 768,
14
+ "id2label": {
15
+ "0": "SIMILARITY"
16
+ },
17
+ "initializer_range": 0.02,
18
+ "intermediate_size": 3072,
19
+ "label2id": {
20
+ "SIMILARITY": 0
21
+ },
22
+ "layer_norm_eps": 1e-05,
23
+ "max_position_embeddings": 514,
24
+ "model_type": "roberta",
25
+ "num_attention_heads": 12,
26
+ "num_hidden_layers": 12,
27
+ "pad_token_id": 1,
28
+ "position_embedding_type": "absolute",
29
+ "problem_type": "regression",
30
+ "transformers_version": "4.6.1",
31
+ "type_vocab_size": 1,
32
+ "use_cache": true,
33
+ "vocab_size": 50262
34
+ }
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:975baf008a16b632ff4df7c422bd26f02b3ba49291552521ab482a6f837ac1d8
3
+ size 498661805
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.json ADDED
The diff for this file is too large to render. See raw diff
 
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/BERTs/models/roberta_base_ca_jsc/transformed_lr0.0005"}
vocab.json ADDED
The diff for this file is too large to render. See raw diff