lrodrigues
commited on
Commit
•
90986fb
1
Parent(s):
4e5d8a3
upload
Browse files- .gitattributes +1 -1
- CESoftmaxAccuracyEvaluator_AllNLI-dev_results.csv +25 -0
- README.md +69 -0
- added_tokens.json +3 -0
- config.json +45 -0
- pytorch_model.bin +3 -0
- special_tokens_map.json +9 -0
- spm.model +3 -0
- tokenizer_config.json +18 -0
.gitattributes
CHANGED
@@ -17,7 +17,6 @@
|
|
17 |
*.pt filter=lfs diff=lfs merge=lfs -text
|
18 |
*.pth filter=lfs diff=lfs merge=lfs -text
|
19 |
*.rar filter=lfs diff=lfs merge=lfs -text
|
20 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
21 |
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
22 |
*.tflite filter=lfs diff=lfs merge=lfs -text
|
23 |
*.tgz filter=lfs diff=lfs merge=lfs -text
|
@@ -25,3 +24,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
25 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
26 |
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
27 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
17 |
*.pt filter=lfs diff=lfs merge=lfs -text
|
18 |
*.pth filter=lfs diff=lfs merge=lfs -text
|
19 |
*.rar filter=lfs diff=lfs merge=lfs -text
|
|
|
20 |
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
21 |
*.tflite filter=lfs diff=lfs merge=lfs -text
|
22 |
*.tgz filter=lfs diff=lfs merge=lfs -text
|
|
|
24 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
25 |
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
26 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
CESoftmaxAccuracyEvaluator_AllNLI-dev_results.csv
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
epoch,steps,Accuracy
|
2 |
+
0,10000,0.8450424785063845
|
3 |
+
0,20000,0.8602533448644248
|
4 |
+
0,30000,0.8755659561479371
|
5 |
+
0,40000,0.8786691763748283
|
6 |
+
0,50000,0.8844686371267233
|
7 |
+
0,-1,0.8870631327262553
|
8 |
+
1,10000,0.8886401790710688
|
9 |
+
1,20000,0.8880297095182378
|
10 |
+
1,30000,0.8925573587017348
|
11 |
+
1,40000,0.8941852775092842
|
12 |
+
1,50000,0.8943887673602279
|
13 |
+
1,-1,0.8943887673602279
|
14 |
+
2,10000,0.896271048481457
|
15 |
+
2,20000,0.8971867528107036
|
16 |
+
2,30000,0.8961184310932492
|
17 |
+
2,40000,0.8954570890776823
|
18 |
+
2,50000,0.8955079615404181
|
19 |
+
2,-1,0.8961184310932492
|
20 |
+
3,10000,0.8958640687795696
|
21 |
+
3,20000,0.8985603093045734
|
22 |
+
3,30000,0.8993742687083481
|
23 |
+
3,40000,0.8986111817673094
|
24 |
+
3,50000,0.8986111817673094
|
25 |
+
3,-1,0.8983059469908938
|
README.md
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
datasets:
|
3 |
+
- multi_nli
|
4 |
+
- snli
|
5 |
+
language: en
|
6 |
+
license: apache-2.0
|
7 |
+
metrics:
|
8 |
+
- accuracy
|
9 |
+
pipeline_tag: zero-shot-classification
|
10 |
+
tags:
|
11 |
+
- microsoft/deberta-v3-xsmall
|
12 |
+
---
|
13 |
+
|
14 |
+
# Cross-Encoder for Natural Language Inference
|
15 |
+
|
16 |
+
This model was trained using [SentenceTransformers](https://sbert.net) [Cross-Encoder](https://www.sbert.net/examples/applications/cross-encoder/README.html) class. This model is based on [microsoft/deberta-v3-xsmall](https://huggingface.co/microsoft/deberta-v3-xsmall)
|
17 |
+
|
18 |
+
## Training Data
|
19 |
+
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.
|
20 |
+
|
21 |
+
## Performance
|
22 |
+
- Accuracy on SNLI-test dataset: 91.64
|
23 |
+
- Accuracy on MNLI mismatched set: 87.77
|
24 |
+
|
25 |
+
For futher evaluation results, see [SBERT.net - Pretrained Cross-Encoder](https://www.sbert.net/docs/pretrained_cross-encoders.html#nli).
|
26 |
+
|
27 |
+
## Usage
|
28 |
+
Pre-trained models can be used like this:
|
29 |
+
```python
|
30 |
+
from sentence_transformers import CrossEncoder
|
31 |
+
model = CrossEncoder('cross-encoder/nli-deberta-v3-xsmall')
|
32 |
+
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.')])
|
33 |
+
|
34 |
+
#Convert scores to labels
|
35 |
+
label_mapping = ['contradiction', 'entailment', 'neutral']
|
36 |
+
labels = [label_mapping[score_max] for score_max in scores.argmax(axis=1)]
|
37 |
+
```
|
38 |
+
|
39 |
+
## Usage with Transformers AutoModel
|
40 |
+
You can use the model also directly with Transformers library (without SentenceTransformers library):
|
41 |
+
```python
|
42 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
43 |
+
import torch
|
44 |
+
|
45 |
+
model = AutoModelForSequenceClassification.from_pretrained('cross-encoder/nli-deberta-v3-xsmall')
|
46 |
+
tokenizer = AutoTokenizer.from_pretrained('cross-encoder/nli-deberta-v3-xsmall')
|
47 |
+
|
48 |
+
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")
|
49 |
+
|
50 |
+
model.eval()
|
51 |
+
with torch.no_grad():
|
52 |
+
scores = model(**features).logits
|
53 |
+
label_mapping = ['contradiction', 'entailment', 'neutral']
|
54 |
+
labels = [label_mapping[score_max] for score_max in scores.argmax(dim=1)]
|
55 |
+
print(labels)
|
56 |
+
```
|
57 |
+
|
58 |
+
## Zero-Shot Classification
|
59 |
+
This model can also be used for zero-shot-classification:
|
60 |
+
```python
|
61 |
+
from transformers import pipeline
|
62 |
+
|
63 |
+
classifier = pipeline("zero-shot-classification", model='cross-encoder/nli-deberta-v3-xsmall')
|
64 |
+
|
65 |
+
sent = "Apple just announced the newest iPhone X"
|
66 |
+
candidate_labels = ["technology", "sports", "politics"]
|
67 |
+
res = classifier(sent, candidate_labels)
|
68 |
+
print(res)
|
69 |
+
```
|
added_tokens.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"[MASK]": 128000
|
3 |
+
}
|
config.json
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "microsoft/deberta-v3-xsmall",
|
3 |
+
"architectures": [
|
4 |
+
"DebertaV2ForSequenceClassification"
|
5 |
+
],
|
6 |
+
"attention_probs_dropout_prob": 0.1,
|
7 |
+
"hidden_act": "gelu",
|
8 |
+
"hidden_dropout_prob": 0.1,
|
9 |
+
"hidden_size": 384,
|
10 |
+
"id2label": {
|
11 |
+
"0": "contradiction",
|
12 |
+
"1": "entailment",
|
13 |
+
"2": "neutral"
|
14 |
+
},
|
15 |
+
"initializer_range": 0.02,
|
16 |
+
"intermediate_size": 1536,
|
17 |
+
"label2id": {
|
18 |
+
"contradiction": 0,
|
19 |
+
"entailment": 1,
|
20 |
+
"neutral": 2
|
21 |
+
},
|
22 |
+
"layer_norm_eps": 1e-7,
|
23 |
+
"max_position_embeddings": 512,
|
24 |
+
"max_relative_positions": -1,
|
25 |
+
"model_type": "deberta-v2",
|
26 |
+
"norm_rel_ebd": "layer_norm",
|
27 |
+
"num_attention_heads": 6,
|
28 |
+
"num_hidden_layers": 12,
|
29 |
+
"pad_token_id": 0,
|
30 |
+
"pooler_dropout": 0,
|
31 |
+
"pooler_hidden_act": "gelu",
|
32 |
+
"pooler_hidden_size": 384,
|
33 |
+
"pos_att_type": [
|
34 |
+
"p2c",
|
35 |
+
"c2p"
|
36 |
+
],
|
37 |
+
"position_biased_input": false,
|
38 |
+
"position_buckets": 256,
|
39 |
+
"relative_attention": true,
|
40 |
+
"share_att_key": true,
|
41 |
+
"torch_dtype": "float32",
|
42 |
+
"transformers_version": "4.11.3",
|
43 |
+
"type_vocab_size": 0,
|
44 |
+
"vocab_size": 128100
|
45 |
+
}
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7bfaa3c5238c1cddcf8a8f76bc82686a653473218f880452dded766a93f41461
|
3 |
+
size 283416722
|
special_tokens_map.json
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": "[CLS]",
|
3 |
+
"cls_token": "[CLS]",
|
4 |
+
"eos_token": "[SEP]",
|
5 |
+
"mask_token": "[MASK]",
|
6 |
+
"pad_token": "[PAD]",
|
7 |
+
"sep_token": "[SEP]",
|
8 |
+
"unk_token": "[UNK]"
|
9 |
+
}
|
spm.model
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c679fbf93643d19aab7ee10c0b99e460bdbc02fedf34b92b05af343b4af586fd
|
3 |
+
size 2464616
|
tokenizer_config.json
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": "[CLS]",
|
3 |
+
"cls_token": "[CLS]",
|
4 |
+
"do_lower_case": false,
|
5 |
+
"eos_token": "[SEP]",
|
6 |
+
"mask_token": "[MASK]",
|
7 |
+
"model_max_length": 512,
|
8 |
+
"name_or_path": "microsoft/deberta-v3-xsmall",
|
9 |
+
"pad_token": "[PAD]",
|
10 |
+
"sep_token": "[SEP]",
|
11 |
+
"sp_model_kwargs": {},
|
12 |
+
"special_tokens_map_file": null,
|
13 |
+
"split_by_punct": false,
|
14 |
+
"tokenizer_class": "DebertaV2Tokenizer",
|
15 |
+
"tokenizer_file": null,
|
16 |
+
"unk_token": "[UNK]",
|
17 |
+
"vocab_type": "spm"
|
18 |
+
}
|