nreimers commited on
Commit
0ff2d4c
1 Parent(s): 14212bb
CESoftmaxAccuracyEvaluator_AllNLI-dev_results.csv ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ epoch,steps,Accuracy
2
+ 0,10000,0.8377168438724119
3
+ 0,20000,0.8574553594139492
4
+ 0,30000,0.8687490461413238
5
+ 0,40000,0.871140051889912
6
+ 0,50000,0.8783639415984128
7
+ 0,-1,0.8795848807040749
8
+ 1,10000,0.88014447779417
9
+ 1,20000,0.885282596530498
10
+ 1,30000,0.8873174950399348
11
+ 1,40000,0.8881314544437097
12
+ 1,50000,0.8894032660121076
13
+ 1,-1,0.8895558834003154
README.md ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ pipeline_tag: zero-shot-classification
4
+ tags:
5
+ - MiniLMv2
6
+ datasets:
7
+ - multi_nli
8
+ - snli
9
+ metrics:
10
+ - accuracy
11
+ ---
12
+
13
+ # Cross-Encoder for Natural Language Inference
14
+ This model was trained using [SentenceTransformers](https://sbert.net) [Cross-Encoder](https://www.sbert.net/examples/applications/cross-encoder/README.html) class.
15
+
16
+ ## Training Data
17
+ 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.
18
+
19
+ ## Performance
20
+ For evaluation results, see [SBERT.net - Pretrained Cross-Encoder](https://www.sbert.net/docs/pretrained_cross-encoders.html#nli).
21
+
22
+ ## Usage
23
+
24
+ Pre-trained models can be used like this:
25
+ ```python
26
+ from sentence_transformers import CrossEncoder
27
+ model = CrossEncoder('cross-encoder/nli-MiniLM2-L6-H768')
28
+ 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.')])
29
+
30
+ #Convert scores to labels
31
+ label_mapping = ['contradiction', 'entailment', 'neutral']
32
+ labels = [label_mapping[score_max] for score_max in scores.argmax(axis=1)]
33
+ ```
34
+
35
+ ## Usage with Transformers AutoModel
36
+ You can use the model also directly with Transformers library (without SentenceTransformers library):
37
+ ```python
38
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
39
+ import torch
40
+
41
+ model = AutoModelForSequenceClassification.from_pretrained('cross-encoder/nli-MiniLM2-L6-H768')
42
+ tokenizer = AutoTokenizer.from_pretrained('cross-encoder/nli-MiniLM2-L6-H768')
43
+
44
+ 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")
45
+
46
+ model.eval()
47
+ with torch.no_grad():
48
+ scores = model(**features).logits
49
+ label_mapping = ['contradiction', 'entailment', 'neutral']
50
+ labels = [label_mapping[score_max] for score_max in scores.argmax(dim=1)]
51
+ print(labels)
52
+ ```
53
+
54
+ ## Zero-Shot Classification
55
+ This model can also be used for zero-shot-classification:
56
+ ```python
57
+ from transformers import pipeline
58
+
59
+ classifier = pipeline("zero-shot-classification", model='cross-encoder/nli-MiniLM2-L6-H768')
60
+
61
+ sent = "Apple just announced the newest iPhone X"
62
+ candidate_labels = ["technology", "sports", "politics"]
63
+ res = classifier(sent, candidate_labels)
64
+ print(res)
65
+ ```
config.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "nreimers/MiniLMv2-L6-H768-distilled-from-RoBERTa-Large",
3
+ "architectures": [
4
+ "RobertaForSequenceClassification"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "bos_token_id": 0,
8
+ "eos_token_id": 2,
9
+ "gradient_checkpointing": false,
10
+ "hidden_act": "gelu",
11
+ "hidden_dropout_prob": 0.1,
12
+ "hidden_size": 768,
13
+ "id2label": {
14
+ "0": "contradiction",
15
+ "1": "entailment",
16
+ "2": "neutral"
17
+ },
18
+ "initializer_range": 0.02,
19
+ "intermediate_size": 3072,
20
+ "label2id": {
21
+ "contradiction": 0,
22
+ "entailment": 1,
23
+ "neutral": 2
24
+ },
25
+ "layer_norm_eps": 1e-05,
26
+ "max_position_embeddings": 514,
27
+ "model_type": "roberta",
28
+ "num_attention_heads": 12,
29
+ "num_hidden_layers": 6,
30
+ "pad_token_id": 1,
31
+ "position_embedding_type": "absolute",
32
+ "transformers_version": "4.6.1",
33
+ "type_vocab_size": 1,
34
+ "use_cache": true,
35
+ "vocab_size": 50265
36
+ }
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:768059960825f2365e301878e8cbe816620f04546769e38063e4d21f297dc48a
3
+ size 328532073
special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"bos_token": "<s>", "eos_token": "</s>", "unk_token": "<unk>", "sep_token": "</s>", "pad_token": "<pad>", "cls_token": "<s>", "mask_token": {"content": "<mask>", "single_word": false, "lstrip": true, "rstrip": false, "normalized": false}}
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": "<unk>", "bos_token": "<s>", "eos_token": "</s>", "add_prefix_space": false, "errors": "replace", "sep_token": "</s>", "cls_token": "<s>", "pad_token": "<pad>", "mask_token": "<mask>", "model_max_length": 512, "special_tokens_map_file": null, "name_or_path": "nreimers/MiniLMv2-L6-H768-distilled-from-RoBERTa-Large"}
vocab.json ADDED
The diff for this file is too large to render. See raw diff