初始化项目,由ModelHub XC社区提供模型
Model: cross-encoder/nli-roberta-base Source: Original Platform
This commit is contained in:
10
.gitattributes
vendored
Normal file
10
.gitattributes
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
*.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
|
||||||
|
*.msgpack 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.8567649378068324
|
||||||
|
0,20000,0.8696614351486786
|
||||||
|
0,30000,0.8731971612443721
|
||||||
|
0,40000,0.8798107496248061
|
||||||
|
0,50000,0.880522982219622
|
||||||
|
0,-1,0.886246279856536
|
||||||
|
1,10000,0.8877216188029405
|
||||||
|
1,20000,0.8890952102357998
|
||||||
|
1,30000,0.8895276371683667
|
||||||
|
1,40000,0.8935212270750134
|
||||||
|
1,50000,0.8950728766565768
|
||||||
|
1,-1,0.8953272454404395
|
||||||
|
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:
|
||||||
|
- FacebookAI/roberta-base
|
||||||
|
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-roberta-base')
|
||||||
|
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-roberta-base')
|
||||||
|
tokenizer = AutoTokenizer.from_pretrained('cross-encoder/nli-roberta-base')
|
||||||
|
|
||||||
|
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-roberta-base')
|
||||||
|
|
||||||
|
sent = "Apple just announced the newest iPhone X"
|
||||||
|
candidate_labels = ["technology", "sports", "politics"]
|
||||||
|
res = classifier(sent, candidate_labels)
|
||||||
|
print(res)
|
||||||
|
```
|
||||||
32
config.json
Normal file
32
config.json
Normal 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": 12,
|
||||||
|
"pad_token_id": 1,
|
||||||
|
"type_vocab_size": 1,
|
||||||
|
"vocab_size": 50265
|
||||||
|
}
|
||||||
3
flax_model.msgpack
Normal file
3
flax_model.msgpack
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:3ad22f6bb3aaa47b834f79265c8ece95fcfa18351bb23242a7f40787585b31f1
|
||||||
|
size 498598977
|
||||||
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:efc90996d2ed80123c26c9091c91385ffddc6d2fd0b2bacf3187fbd6c5b87953
|
||||||
|
size 498620100
|
||||||
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:50dbf8939f1fdc45ae31fd6c1e6680489c6560b0f5e37b13da0e7979b8384ad0
|
||||||
|
size 498911192
|
||||||
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:8fa0c1aee4f30833b396dd3103ee765f68d93d7b0ba87e3ccbab7a8372f4540e
|
||||||
|
size 498809573
|
||||||
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:54ec3f780c5e28633d4a02f686b2a59ceb6a044b3ddc753cc6083283b41e2e55
|
||||||
|
size 498632570
|
||||||
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:a9f3e5c35fe5b195998a15b54762a21837176a6972958b9c2c8d32601017286f
|
||||||
|
size 498632425
|
||||||
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:83dda61de01e3dfbd6fb9d5e5174c03b138c24dfe4fed5457cb5b7f53b9bab1e
|
||||||
|
size 249473754
|
||||||
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:8fef91c2f379da98bec3c7e81082989e2fb6f454a56679808c3361c654452639
|
||||||
|
size 126019381
|
||||||
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:8fef91c2f379da98bec3c7e81082989e2fb6f454a56679808c3361c654452639
|
||||||
|
size 126019381
|
||||||
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:8fef91c2f379da98bec3c7e81082989e2fb6f454a56679808c3361c654452639
|
||||||
|
size 126019381
|
||||||
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:0243ee7d1d5a5cfa7d8b7dff2691d06b2c483995150888f1b1533fe75f99c68f
|
||||||
|
size 126019378
|
||||||
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:3790d001dc4bb37662c335a231303f3ad1efd8772a51b827c24f832f40dc9373
|
||||||
|
size 498596028
|
||||||
12477
openvino/openvino_model.xml
Normal file
12477
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:f33639cd4bf61095ae6518cbdc21d21e90d93b6f3ad49543ba211075f1083dee
|
||||||
|
size 125821320
|
||||||
21421
openvino/openvino_model_qint8_quantized.xml
Normal file
21421
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:841b6e05e67fb1d920ea8f081eba18f12ea43890b6e8c0c13d558ab51c61890c
|
||||||
|
size 498682313
|
||||||
51
special_tokens_map.json
Normal file
51
special_tokens_map.json
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
{
|
||||||
|
"bos_token": {
|
||||||
|
"content": "<s>",
|
||||||
|
"lstrip": false,
|
||||||
|
"normalized": true,
|
||||||
|
"rstrip": false,
|
||||||
|
"single_word": false
|
||||||
|
},
|
||||||
|
"cls_token": {
|
||||||
|
"content": "<s>",
|
||||||
|
"lstrip": false,
|
||||||
|
"normalized": true,
|
||||||
|
"rstrip": false,
|
||||||
|
"single_word": false
|
||||||
|
},
|
||||||
|
"eos_token": {
|
||||||
|
"content": "</s>",
|
||||||
|
"lstrip": false,
|
||||||
|
"normalized": true,
|
||||||
|
"rstrip": false,
|
||||||
|
"single_word": false
|
||||||
|
},
|
||||||
|
"mask_token": {
|
||||||
|
"content": "<mask>",
|
||||||
|
"lstrip": true,
|
||||||
|
"normalized": true,
|
||||||
|
"rstrip": false,
|
||||||
|
"single_word": false
|
||||||
|
},
|
||||||
|
"pad_token": {
|
||||||
|
"content": "<pad>",
|
||||||
|
"lstrip": false,
|
||||||
|
"normalized": true,
|
||||||
|
"rstrip": false,
|
||||||
|
"single_word": false
|
||||||
|
},
|
||||||
|
"sep_token": {
|
||||||
|
"content": "</s>",
|
||||||
|
"lstrip": false,
|
||||||
|
"normalized": true,
|
||||||
|
"rstrip": false,
|
||||||
|
"single_word": false
|
||||||
|
},
|
||||||
|
"unk_token": {
|
||||||
|
"content": "<unk>",
|
||||||
|
"lstrip": false,
|
||||||
|
"normalized": true,
|
||||||
|
"rstrip": false,
|
||||||
|
"single_word": false
|
||||||
|
}
|
||||||
|
}
|
||||||
250357
tokenizer.json
Normal file
250357
tokenizer.json
Normal file
File diff suppressed because it is too large
Load Diff
58
tokenizer_config.json
Normal file
58
tokenizer_config.json
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
{
|
||||||
|
"add_prefix_space": false,
|
||||||
|
"added_tokens_decoder": {
|
||||||
|
"0": {
|
||||||
|
"content": "<s>",
|
||||||
|
"lstrip": false,
|
||||||
|
"normalized": true,
|
||||||
|
"rstrip": false,
|
||||||
|
"single_word": false,
|
||||||
|
"special": true
|
||||||
|
},
|
||||||
|
"1": {
|
||||||
|
"content": "<pad>",
|
||||||
|
"lstrip": false,
|
||||||
|
"normalized": true,
|
||||||
|
"rstrip": false,
|
||||||
|
"single_word": false,
|
||||||
|
"special": true
|
||||||
|
},
|
||||||
|
"2": {
|
||||||
|
"content": "</s>",
|
||||||
|
"lstrip": false,
|
||||||
|
"normalized": true,
|
||||||
|
"rstrip": false,
|
||||||
|
"single_word": false,
|
||||||
|
"special": true
|
||||||
|
},
|
||||||
|
"3": {
|
||||||
|
"content": "<unk>",
|
||||||
|
"lstrip": false,
|
||||||
|
"normalized": true,
|
||||||
|
"rstrip": false,
|
||||||
|
"single_word": false,
|
||||||
|
"special": true
|
||||||
|
},
|
||||||
|
"50264": {
|
||||||
|
"content": "<mask>",
|
||||||
|
"lstrip": true,
|
||||||
|
"normalized": true,
|
||||||
|
"rstrip": false,
|
||||||
|
"single_word": false,
|
||||||
|
"special": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"bos_token": "<s>",
|
||||||
|
"clean_up_tokenization_spaces": false,
|
||||||
|
"cls_token": "<s>",
|
||||||
|
"eos_token": "</s>",
|
||||||
|
"errors": "replace",
|
||||||
|
"extra_special_tokens": {},
|
||||||
|
"mask_token": "<mask>",
|
||||||
|
"model_max_length": 512,
|
||||||
|
"pad_token": "<pad>",
|
||||||
|
"sep_token": "</s>",
|
||||||
|
"tokenizer_class": "RobertaTokenizer",
|
||||||
|
"trim_offsets": true,
|
||||||
|
"unk_token": "<unk>"
|
||||||
|
}
|
||||||
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