This commit is contained in:
nreimers 2021-01-03 21:22:09 +01:00
parent cb68b8c714
commit 3616151782
8 changed files with 50090 additions and 0 deletions

View File

@ -0,0 +1,13 @@
epoch,steps,Accuracy
0,10000,0.8128608857121055
0,20000,0.8258336936891105
0,30000,0.8371785414493933
0,40000,0.849668048737059
0,50000,0.8555439676442906
0,-1,0.854857171927861
1,10000,0.8612418284028184
1,20000,0.8619540609976344
1,30000,0.8658459033907359
1,40000,0.8682115330806603
1,50000,0.8688474550403175
1,-1,0.8696614351486786
1 epoch steps Accuracy
2 0 10000 0.8128608857121055
3 0 20000 0.8258336936891105
4 0 30000 0.8371785414493933
5 0 40000 0.849668048737059
6 0 50000 0.8555439676442906
7 0 -1 0.854857171927861
8 1 10000 0.8612418284028184
9 1 20000 0.8619540609976344
10 1 30000 0.8658459033907359
11 1 40000 0.8682115330806603
12 1 50000 0.8688474550403175
13 1 -1 0.8696614351486786

38
README.md Executable file
View File

@ -0,0 +1,38 @@
# Cross-Encoder for Quora Duplicate Questions Detection
This model was trained using [SentenceTransformers](https://sbert.net) [Cross-Encoder](https://www.sbert.net/examples/applications/cross-encoder/README.html) class.
## Training Data
The model was trained on the [SNLI](https://nlp.stanford.edu/projects/snli/) and [MultiNLI](https://cims.nyu.edu/~sbowman/multinli/) datasets. For a given sentence pair, it will output three scores corresponding to the labels: contradiction, entailment, neutral.
## Usage
Pre-trained models can be used like this:
```python
from sentence_transformers import CrossEncoder
model = CrossEncoder('model_name')
scores = model.predict([('A man is eating pizza', 'A man eats something'), ('A black race car starts up in front of a crowd of people.', 'A man is driving down a lonely road.')])
#Convert scores to labels
label_mapping = ['contradiction', 'entailment', 'neutral']
labels = [label_mapping[score_max] for score_max in scores.argmax(axis=1)]
```
## Usage with Transformers AutoModel
You can use the model also directly with Transformers library (without SentenceTransformers library):
```python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model = AutoModelForSequenceClassification.from_pretrained('model_name')
tokenizer = AutoTokenizer.from_pretrained('model_name')
features = tokenizer(['A man is eating pizza', 'A black race car starts up in front of a crowd of people.'], ['A man eats something', 'A man is driving down a lonely road.'], padding=True, truncation=True, return_tensors="pt")
model.eval()
with torch.no_grad():
scores = model(**features).logits
label_mapping = ['contradiction', 'entailment', 'neutral']
labels = [label_mapping[score_max] for score_max in scores.argmax(dim=1)]
print(labels)
```

32
config.json Normal file
View File

@ -0,0 +1,32 @@
{
"architectures": [
"RobertaForSequenceClassification"
],
"attention_probs_dropout_prob": 0.1,
"bos_token_id": 0,
"eos_token_id": 2,
"gradient_checkpointing": false,
"hidden_act": "gelu",
"hidden_dropout_prob": 0.1,
"hidden_size": 768,
"id2label": {
"0": "contradiction",
"1": "entailment",
"2": "neutral"
},
"initializer_range": 0.02,
"intermediate_size": 3072,
"label2id": {
"contradiction": 0,
"entailment": 1,
"neutral": 2
},
"layer_norm_eps": 1e-05,
"max_position_embeddings": 514,
"model_type": "roberta",
"num_attention_heads": 12,
"num_hidden_layers": 6,
"pad_token_id": 1,
"type_vocab_size": 1,
"vocab_size": 50265
}

50001
merges.txt Normal file

File diff suppressed because it is too large Load Diff

BIN
pytorch_model.bin (Stored with Git LFS) Normal file

Binary file not shown.

1
special_tokens_map.json Normal file
View File

@ -0,0 +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}}

1
tokenizer_config.json Normal file
View File

@ -0,0 +1 @@
{"model_max_length": 512}

1
vocab.json Normal file

File diff suppressed because one or more lines are too long