初始化项目,由ModelHub XC社区提供模型

Model: cross-encoder/nli-distilroberta-base
Source: Original Platform
This commit is contained in:
ModelHub XC
2026-05-13 16:42:57 +08:00
commit d85acb8f2d
25 changed files with 318896 additions and 0 deletions

10
.gitattributes vendored Normal file
View 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

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

69
README.md Normal file
View 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:
- distilbert/distilroberta-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-distilroberta-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-distilroberta-base')
tokenizer = AutoTokenizer.from_pretrained('cross-encoder/nli-distilroberta-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-distilroberta-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
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
}

3
flax_model.msgpack Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f1d007c150a23b7099e74fbfe564ca1c55146d2f4d9e87651716ef6176dd2570
size 328486639

50001
merges.txt Normal file

File diff suppressed because it is too large Load Diff

3
model.safetensors Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9df3eb5d37118f952f4ba4fb46fde6889e3a9ccedeee0bad09b0110fc64c5c29
size 328499560

3
onnx/model.onnx Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3ace438d5b0ad73d1dd68d4e031e2438659993cc2b6b9cdb145cb209ab6fce8f
size 328649957

3
onnx/model_O1.onnx Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a62134fe4bba8f2d037ca5a79f2e9254ca779880b7b704f01f1c82bd591ba866
size 328598421

3
onnx/model_O2.onnx Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4a35e10df48657c58c7c1f45071562528c95992efba1f2421ee289a9ba3af338
size 328507853

3
onnx/model_O3.onnx Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:adf3cf5cbdd716c6cb4df4cf9c2badfc2050d802862aa0ab7518ac0e76a6de11
size 328507784

3
onnx/model_O4.onnx Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:64e07a6eeeb5b7b821c632dfb97a3cf8b187523b5230500f01544296d45fb4c2
size 164336758

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a3aec44a4d2a49b6c9ab821ab2f985abcc2a0af79e8215c7091a0b5e1bc84576
size 82823065

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a3aec44a4d2a49b6c9ab821ab2f985abcc2a0af79e8215c7091a0b5e1bc84576
size 82823065

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a3aec44a4d2a49b6c9ab821ab2f985abcc2a0af79e8215c7091a0b5e1bc84576
size 82823065

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:cd21e27865fdf2dcc63407e32bdb334a83e6713f160e64d09de720670c0281cb
size 82823063

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f65f6143f284ce6a33c3d6fa3194d665c3a975078fb2ffaf652dee82586f2bf7
size 328487100

6795
openvino/openvino_model.xml Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:709915885467b15b9f6c91a2356434d56f2477a9b7bfc04c4dcacc585702ce44
size 82819176

File diff suppressed because it is too large Load Diff

3
pytorch_model.bin Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d272bba7769a509cd328dbda062279926d00550a635f4428998c1869a25f83b2
size 328532073

51
special_tokens_map.json Normal file
View 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

File diff suppressed because it is too large Load Diff

58
tokenizer_config.json Normal file
View 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

File diff suppressed because one or more lines are too long