mplaza
commited on
Commit
·
c847f9e
1
Parent(s):
15b4fb4
First commit
Browse files- README.md +56 -0
- config.json +37 -0
- merges.txt +0 -0
- pytorch_model.bin +3 -0
- special_tokens_map.json +1 -0
- tokenizer.json +0 -0
- tokenizer_config.json +1 -0
- training_args.bin +3 -0
- vocab.json +0 -0
README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
|
| 3 |
+
pipeline_tag: text-classification
|
| 4 |
+
inference: false
|
| 5 |
+
language: en
|
| 6 |
+
tags:
|
| 7 |
+
- transformers
|
| 8 |
+
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# Prompsit/paraphrase-roberta-es
|
| 12 |
+
|
| 13 |
+
This model allows to evaluate paraphrases for a given phrase.
|
| 14 |
+
|
| 15 |
+
We have fine-tuned this model from pretrained "PlanTL-GOB-ES/roberta-base-bne".
|
| 16 |
+
|
| 17 |
+
Model built under a TSI-100905-2019-4 project, co-financed by Ministry of Economic Affairs and Digital Transformation from the Government of Spain.
|
| 18 |
+
|
| 19 |
+
# How to use it
|
| 20 |
+
|
| 21 |
+
The model answer the following question: Is "phrase B" a paraphrase of "phrase A".
|
| 22 |
+
|
| 23 |
+
Please note that we're considering phrases instead of sentences. Therefore, we must take into account that the model doesn't expect to find punctuation marks or long pieces of text.
|
| 24 |
+
|
| 25 |
+
Resulting probabilities correspond to classes:
|
| 26 |
+
|
| 27 |
+
* 0: Not a paraphrase
|
| 28 |
+
* 1: It's a paraphrase
|
| 29 |
+
|
| 30 |
+
So, considering the phrase "se buscarán acuerdos" and a candidate paraphrase like "se deberá obtener el acuerdo", you can use the model like this:
|
| 31 |
+
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
import torch
|
| 35 |
+
|
| 36 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 37 |
+
tokenizer = AutoTokenizer.from_pretrained("Prompsit/paraphrase-roberta-es")
|
| 38 |
+
model = AutoModelForSequenceClassification.from_pretrained("Prompsit/paraphrase-roberta-es")
|
| 39 |
+
|
| 40 |
+
input = tokenizer('se buscarán acuerdos','se deberá obtener el acuerdo',return_tensors='pt')
|
| 41 |
+
logits = model(**input).logits
|
| 42 |
+
soft = torch.nn.Softmax(dim=1)
|
| 43 |
+
print(soft(logits))
|
| 44 |
+
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
Code output is:
|
| 48 |
+
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
tensor([[0.2266, 0.7734]], grad_fn=<SoftmaxBackward>)
|
| 52 |
+
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
As the probability of 1 (=It's a paraphrase) is 0.77 and the probability of 0 (=It is not a paraphrase) is 0.22, we can conclude, for our previous example, that "se deberá obtener el acuerdo" is a paraphrase of "se buscarán acuerdos".
|
| 56 |
+
|
config.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_name_or_path": "PlanTL-GOB-ES/roberta-base-bne",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"RobertaForSequenceClassification"
|
| 5 |
+
],
|
| 6 |
+
"attention_probs_dropout_prob": 0.0,
|
| 7 |
+
"bos_token_id": 0,
|
| 8 |
+
"classifier_dropout": null,
|
| 9 |
+
"eos_token_id": 2,
|
| 10 |
+
"gradient_checkpointing": false,
|
| 11 |
+
"hidden_act": "gelu",
|
| 12 |
+
"hidden_dropout_prob": 0.0,
|
| 13 |
+
"hidden_size": 768,
|
| 14 |
+
"id2label": {
|
| 15 |
+
"0": "Not Paraphrase",
|
| 16 |
+
"1": "Paraphrase"
|
| 17 |
+
},
|
| 18 |
+
"initializer_range": 0.02,
|
| 19 |
+
"intermediate_size": 3072,
|
| 20 |
+
"label2id": {
|
| 21 |
+
"Not Paraphrase": 0,
|
| 22 |
+
"Paraphrase": 1
|
| 23 |
+
},
|
| 24 |
+
"layer_norm_eps": 1e-05,
|
| 25 |
+
"max_position_embeddings": 514,
|
| 26 |
+
"model_type": "roberta",
|
| 27 |
+
"num_attention_heads": 12,
|
| 28 |
+
"num_hidden_layers": 12,
|
| 29 |
+
"pad_token_id": 1,
|
| 30 |
+
"position_embedding_type": "absolute",
|
| 31 |
+
"problem_type": "single_label_classification",
|
| 32 |
+
"torch_dtype": "float32",
|
| 33 |
+
"transformers_version": "4.11.3",
|
| 34 |
+
"type_vocab_size": 1,
|
| 35 |
+
"use_cache": true,
|
| 36 |
+
"vocab_size": 50262
|
| 37 |
+
}
|
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:47c73c5e6e7e2a1856d003f044ad44a463017df3ce54d2c58878f5abe42616eb
|
| 3 |
+
size 498664877
|
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": false, "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": "PlanTL-GOB-ES/roberta-base-bne", "tokenizer_class": "RobertaTokenizer"}
|
training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0a5bc90de40c0c9489ac705d5176d0991e203c34e0c667b2630a0bdcdffe6854
|
| 3 |
+
size 2799
|
vocab.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|