mplaza
commited on
Commit
路
4c928e3
1
Parent(s):
eb859f0
First commit
Browse files- README.md +56 -0
- config.json +41 -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.txt +0 -0
README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
|
| 3 |
+
pipeline_tag: text-classification
|
| 4 |
+
inference: false
|
| 5 |
+
language: pt
|
| 6 |
+
tags:
|
| 7 |
+
- transformers
|
| 8 |
+
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# Prompsit/paraphrase-bert-pt
|
| 12 |
+
|
| 13 |
+
This model allows to evaluate paraphrases for a given phrase.
|
| 14 |
+
|
| 15 |
+
We have fine-tuned this model from pretrained "neuralmind/bert-base-portuguese-cased".
|
| 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 "logo ap贸s o homic铆dio" and a candidate paraphrase like "pouco depois do assassinato", 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-bert-pt")
|
| 38 |
+
model = AutoModelForSequenceClassification.from_pretrained("Prompsit/paraphrase-bert-pt")
|
| 39 |
+
|
| 40 |
+
input = tokenizer('logo ap贸s o homic铆dio','pouco depois do assassinato',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.2137, 0.7863]], grad_fn=<SoftmaxBackward>)
|
| 52 |
+
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
As the probability of 1 (=It's a paraphrase) is 0.7863 and the probability of 0 (=It is not a paraphrase) is 0.2137, we can conclude, for our previous example, that "pouco depois do assassinato" is a paraphrase of "logo ap贸s o homicidio".
|
| 56 |
+
|
config.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_name_or_path": "neuralmind/bert-base-portuguese-cased",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"BertForSequenceClassification"
|
| 5 |
+
],
|
| 6 |
+
"attention_probs_dropout_prob": 0.1,
|
| 7 |
+
"classifier_dropout": null,
|
| 8 |
+
"directionality": "bidi",
|
| 9 |
+
"hidden_act": "gelu",
|
| 10 |
+
"hidden_dropout_prob": 0.1,
|
| 11 |
+
"hidden_size": 768,
|
| 12 |
+
"id2label": {
|
| 13 |
+
"0": "Not Paraphrase",
|
| 14 |
+
"1": "Paraphrase"
|
| 15 |
+
},
|
| 16 |
+
"initializer_range": 0.02,
|
| 17 |
+
"intermediate_size": 3072,
|
| 18 |
+
"label2id": {
|
| 19 |
+
"Not Paraphrase": 0,
|
| 20 |
+
"Paraphrase": 1
|
| 21 |
+
},
|
| 22 |
+
"layer_norm_eps": 1e-12,
|
| 23 |
+
"max_position_embeddings": 512,
|
| 24 |
+
"model_type": "bert",
|
| 25 |
+
"num_attention_heads": 12,
|
| 26 |
+
"num_hidden_layers": 12,
|
| 27 |
+
"output_past": true,
|
| 28 |
+
"pad_token_id": 0,
|
| 29 |
+
"pooler_fc_size": 768,
|
| 30 |
+
"pooler_num_attention_heads": 12,
|
| 31 |
+
"pooler_num_fc_layers": 3,
|
| 32 |
+
"pooler_size_per_head": 128,
|
| 33 |
+
"pooler_type": "first_token_transform",
|
| 34 |
+
"position_embedding_type": "absolute",
|
| 35 |
+
"problem_type": "single_label_classification",
|
| 36 |
+
"torch_dtype": "float32",
|
| 37 |
+
"transformers_version": "4.11.3",
|
| 38 |
+
"type_vocab_size": 2,
|
| 39 |
+
"use_cache": true,
|
| 40 |
+
"vocab_size": 29794
|
| 41 |
+
}
|
pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bff4e0b43c243a7e7668cee0be15c0e062f237164ed8393bfac8d5ad73397f15
|
| 3 |
+
size 435782829
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"do_lower_case": false, "unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]", "tokenize_chinese_chars": true, "strip_accents": null, "special_tokens_map_file": "/home/mplaza/.cache/huggingface/transformers/eecc45187d085a1169eed91017d358cc0e9cbdd5dc236bcd710059dbf0a2f816.dd8bd9bfd3664b530ea4e645105f557769387b3da9f79bdb55ed556bdd80611d", "name_or_path": "neuralmind/bert-base-portuguese-cased", "do_basic_tokenize": true, "never_split": null, "tokenizer_class": "BertTokenizer"}
|
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.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|