初始化项目,由ModelHub XC社区提供模型
Model: cross-encoder/nli-MiniLM2-L6-H768 Source: Original Platform
This commit is contained in:
17
.gitattributes
vendored
Normal file
17
.gitattributes
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||
model.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
13
CESoftmaxAccuracyEvaluator_AllNLI-dev_results.csv
Normal file
13
CESoftmaxAccuracyEvaluator_AllNLI-dev_results.csv
Normal file
@@ -0,0 +1,13 @@
|
||||
epoch,steps,Accuracy
|
||||
0,10000,0.8377168438724119
|
||||
0,20000,0.8574553594139492
|
||||
0,30000,0.8687490461413238
|
||||
0,40000,0.871140051889912
|
||||
0,50000,0.8783639415984128
|
||||
0,-1,0.8795848807040749
|
||||
1,10000,0.88014447779417
|
||||
1,20000,0.885282596530498
|
||||
1,30000,0.8873174950399348
|
||||
1,40000,0.8881314544437097
|
||||
1,50000,0.8894032660121076
|
||||
1,-1,0.8895558834003154
|
||||
|
69
README.md
Normal file
69
README.md
Normal file
@@ -0,0 +1,69 @@
|
||||
---
|
||||
language: en
|
||||
pipeline_tag: zero-shot-classification
|
||||
tags:
|
||||
- transformers
|
||||
datasets:
|
||||
- nyu-mll/multi_nli
|
||||
- stanfordnlp/snli
|
||||
metrics:
|
||||
- accuracy
|
||||
license: apache-2.0
|
||||
base_model:
|
||||
- nreimers/MiniLMv2-L6-H768-distilled-from-RoBERTa-Large
|
||||
library_name: sentence-transformers
|
||||
---
|
||||
|
||||
# Cross-Encoder for Natural Language Inference
|
||||
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.
|
||||
|
||||
## Performance
|
||||
For evaluation results, see [SBERT.net - Pretrained Cross-Encoder](https://www.sbert.net/docs/pretrained_cross-encoders.html#nli).
|
||||
|
||||
## Usage
|
||||
|
||||
Pre-trained models can be used like this:
|
||||
```python
|
||||
from sentence_transformers import CrossEncoder
|
||||
model = CrossEncoder('cross-encoder/nli-MiniLM2-L6-H768')
|
||||
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('cross-encoder/nli-MiniLM2-L6-H768')
|
||||
tokenizer = AutoTokenizer.from_pretrained('cross-encoder/nli-MiniLM2-L6-H768')
|
||||
|
||||
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)
|
||||
```
|
||||
|
||||
## Zero-Shot Classification
|
||||
This model can also be used for zero-shot-classification:
|
||||
```python
|
||||
from transformers import pipeline
|
||||
|
||||
classifier = pipeline("zero-shot-classification", model='cross-encoder/nli-MiniLM2-L6-H768')
|
||||
|
||||
sent = "Apple just announced the newest iPhone X"
|
||||
candidate_labels = ["technology", "sports", "politics"]
|
||||
res = classifier(sent, candidate_labels)
|
||||
print(res)
|
||||
```
|
||||
36
config.json
Normal file
36
config.json
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"_name_or_path": "nreimers/MiniLMv2-L6-H768-distilled-from-RoBERTa-Large",
|
||||
"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,
|
||||
"position_embedding_type": "absolute",
|
||||
"transformers_version": "4.6.1",
|
||||
"type_vocab_size": 1,
|
||||
"use_cache": true,
|
||||
"vocab_size": 50265
|
||||
}
|
||||
50001
merges.txt
Normal file
50001
merges.txt
Normal file
File diff suppressed because it is too large
Load Diff
3
model.safetensors
Normal file
3
model.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ec9c5b6a08b60d7a01b465c7ed44b496244dfd1bed3274c95875a74cea89ab35
|
||||
size 328499560
|
||||
3
onnx/model.onnx
Normal file
3
onnx/model.onnx
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:807d33fffefd95ad60e2a91f54eed50a92aa53c077945a6842bb587a49a3fdf3
|
||||
size 328649957
|
||||
3
onnx/model_O1.onnx
Normal file
3
onnx/model_O1.onnx
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:8a9273f027fc3a82037af46fc9c8b9d5629f214c05a897e3d944abcc14da856c
|
||||
size 328598421
|
||||
3
onnx/model_O2.onnx
Normal file
3
onnx/model_O2.onnx
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1e320643f4e1dec3a1d2d2566b3b1e61b13427b106281442ccf862a39efae820
|
||||
size 328507853
|
||||
3
onnx/model_O3.onnx
Normal file
3
onnx/model_O3.onnx
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:3807cf1d57f0808f7ce24c5115fcee93d3989fa717f2c303bd44b6044d64ef73
|
||||
size 328507784
|
||||
3
onnx/model_O4.onnx
Normal file
3
onnx/model_O4.onnx
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:b031fdc4c90690c0e61e9ea5916623a1cc9be158526ee1cea48d0491da82a156
|
||||
size 164336758
|
||||
3
onnx/model_qint8_arm64.onnx
Normal file
3
onnx/model_qint8_arm64.onnx
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:449024a8711a3e655cad410cb2192158f9897fc2a32b65dbb817922351150db7
|
||||
size 82823065
|
||||
3
onnx/model_qint8_avx512.onnx
Normal file
3
onnx/model_qint8_avx512.onnx
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:449024a8711a3e655cad410cb2192158f9897fc2a32b65dbb817922351150db7
|
||||
size 82823065
|
||||
3
onnx/model_qint8_avx512_vnni.onnx
Normal file
3
onnx/model_qint8_avx512_vnni.onnx
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:449024a8711a3e655cad410cb2192158f9897fc2a32b65dbb817922351150db7
|
||||
size 82823065
|
||||
3
onnx/model_quint8_avx2.onnx
Normal file
3
onnx/model_quint8_avx2.onnx
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:44391a5241a62e0083c1a8899a71e69a092b95aea5ba89e14062925468eceac7
|
||||
size 82823063
|
||||
3
openvino/openvino_model.bin
Normal file
3
openvino/openvino_model.bin
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ff8b2c896de57a540162df07ef8d2be8b988a77e71f448fcde37c563f86b8d65
|
||||
size 328487100
|
||||
6795
openvino/openvino_model.xml
Normal file
6795
openvino/openvino_model.xml
Normal file
File diff suppressed because it is too large
Load Diff
3
openvino/openvino_model_qint8_quantized.bin
Normal file
3
openvino/openvino_model_qint8_quantized.bin
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:36b8abc214804436607864393bff1ede2d451fb2993ed6930badc9d6c9d0f48e
|
||||
size 82819176
|
||||
11467
openvino/openvino_model_qint8_quantized.xml
Normal file
11467
openvino/openvino_model_qint8_quantized.xml
Normal file
File diff suppressed because it is too large
Load Diff
3
pytorch_model.bin
Normal file
3
pytorch_model.bin
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:768059960825f2365e301878e8cbe816620f04546769e38063e4d21f297dc48a
|
||||
size 328532073
|
||||
1
special_tokens_map.json
Normal file
1
special_tokens_map.json
Normal file
@@ -0,0 +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}}
|
||||
1
tokenizer.json
Normal file
1
tokenizer.json
Normal file
File diff suppressed because one or more lines are too long
1
tokenizer_config.json
Normal file
1
tokenizer_config.json
Normal file
@@ -0,0 +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"}
|
||||
1
vocab.json
Normal file
1
vocab.json
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user