Add new CrossEncoder model
Browse files- README.md +137 -0
- config.json +31 -0
- model.safetensors +3 -0
- special_tokens_map.json +37 -0
- tokenizer.json +0 -0
- tokenizer_config.json +65 -0
- vocab.txt +0 -0
README.md
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
tags:
|
3 |
+
- sentence-transformers
|
4 |
+
- cross-encoder
|
5 |
+
- text-classification
|
6 |
+
pipeline_tag: text-classification
|
7 |
+
library_name: sentence-transformers
|
8 |
+
---
|
9 |
+
|
10 |
+
# CrossEncoder
|
11 |
+
|
12 |
+
This is a [Cross Encoder](https://www.sbert.net/docs/cross_encoder/usage/usage.html) model trained using the [sentence-transformers](https://www.SBERT.net) library. It computes scores for pairs of texts, which can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
|
13 |
+
|
14 |
+
## Model Details
|
15 |
+
|
16 |
+
### Model Description
|
17 |
+
- **Model Type:** Cross Encoder
|
18 |
+
<!-- - **Base model:** [Unknown](https://huggingface.co/unknown) -->
|
19 |
+
- **Maximum Sequence Length:** 512 tokens
|
20 |
+
- **Number of Output Labels:** 1 label
|
21 |
+
<!-- - **Training Dataset:** Unknown -->
|
22 |
+
<!-- - **Language:** Unknown -->
|
23 |
+
<!-- - **License:** Unknown -->
|
24 |
+
|
25 |
+
### Model Sources
|
26 |
+
|
27 |
+
- **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
|
28 |
+
- **Documentation:** [Cross Encoder Documentation](https://www.sbert.net/docs/cross_encoder/usage/usage.html)
|
29 |
+
- **Repository:** [Sentence Transformers on GitHub](https://github.com/UKPLab/sentence-transformers)
|
30 |
+
- **Hugging Face:** [Cross Encoders on Hugging Face](https://huggingface.co/models?library=sentence-transformers&other=cross-encoder)
|
31 |
+
|
32 |
+
## Usage
|
33 |
+
|
34 |
+
### Direct Usage (Sentence Transformers)
|
35 |
+
|
36 |
+
First install the Sentence Transformers library:
|
37 |
+
|
38 |
+
```bash
|
39 |
+
pip install -U sentence-transformers
|
40 |
+
```
|
41 |
+
|
42 |
+
Then you can load this model and run inference.
|
43 |
+
```python
|
44 |
+
from sentence_transformers import CrossEncoder
|
45 |
+
|
46 |
+
# Download from the 🤗 Hub
|
47 |
+
model = CrossEncoder("tomaarsen/reranker-MiniLM-L12-msmarco-scratch")
|
48 |
+
# Get scores for pairs of texts
|
49 |
+
pairs = [
|
50 |
+
['How many calories in an egg', 'There are on average between 55 and 80 calories in an egg depending on its size.'],
|
51 |
+
['How many calories in an egg', 'Egg whites are very low in calories, have no fat, no cholesterol, and are loaded with protein.'],
|
52 |
+
['How many calories in an egg', 'Most of the calories in an egg come from the yellow yolk in the center.'],
|
53 |
+
]
|
54 |
+
scores = model.predict(pairs)
|
55 |
+
print(scores.shape)
|
56 |
+
# (3,)
|
57 |
+
|
58 |
+
# Or rank different texts based on similarity to a single text
|
59 |
+
ranks = model.rank(
|
60 |
+
'How many calories in an egg',
|
61 |
+
[
|
62 |
+
'There are on average between 55 and 80 calories in an egg depending on its size.',
|
63 |
+
'Egg whites are very low in calories, have no fat, no cholesterol, and are loaded with protein.',
|
64 |
+
'Most of the calories in an egg come from the yellow yolk in the center.',
|
65 |
+
]
|
66 |
+
)
|
67 |
+
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]
|
68 |
+
```
|
69 |
+
|
70 |
+
<!--
|
71 |
+
### Direct Usage (Transformers)
|
72 |
+
|
73 |
+
<details><summary>Click to see the direct usage in Transformers</summary>
|
74 |
+
|
75 |
+
</details>
|
76 |
+
-->
|
77 |
+
|
78 |
+
<!--
|
79 |
+
### Downstream Usage (Sentence Transformers)
|
80 |
+
|
81 |
+
You can finetune this model on your own dataset.
|
82 |
+
|
83 |
+
<details><summary>Click to expand</summary>
|
84 |
+
|
85 |
+
</details>
|
86 |
+
-->
|
87 |
+
|
88 |
+
<!--
|
89 |
+
### Out-of-Scope Use
|
90 |
+
|
91 |
+
*List how the model may foreseeably be misused and address what users ought not to do with the model.*
|
92 |
+
-->
|
93 |
+
|
94 |
+
<!--
|
95 |
+
## Bias, Risks and Limitations
|
96 |
+
|
97 |
+
*What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
|
98 |
+
-->
|
99 |
+
|
100 |
+
<!--
|
101 |
+
### Recommendations
|
102 |
+
|
103 |
+
*What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
|
104 |
+
-->
|
105 |
+
|
106 |
+
## Training Details
|
107 |
+
|
108 |
+
### Framework Versions
|
109 |
+
- Python: 3.11.6
|
110 |
+
- Sentence Transformers: 3.5.0.dev0
|
111 |
+
- Transformers: 4.48.3
|
112 |
+
- PyTorch: 2.5.0+cu121
|
113 |
+
- Accelerate: 1.3.0
|
114 |
+
- Datasets: 2.20.0
|
115 |
+
- Tokenizers: 0.21.0
|
116 |
+
|
117 |
+
## Citation
|
118 |
+
|
119 |
+
### BibTeX
|
120 |
+
|
121 |
+
<!--
|
122 |
+
## Glossary
|
123 |
+
|
124 |
+
*Clearly define terms in order to be accessible across audiences.*
|
125 |
+
-->
|
126 |
+
|
127 |
+
<!--
|
128 |
+
## Model Card Authors
|
129 |
+
|
130 |
+
*Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
|
131 |
+
-->
|
132 |
+
|
133 |
+
<!--
|
134 |
+
## Model Card Contact
|
135 |
+
|
136 |
+
*Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
|
137 |
+
-->
|
config.json
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "output/training_ms-marco_cross-encoder-microsoft-MiniLM-L12-H384-uncased-2025-02-13_12-04-44-latest",
|
3 |
+
"architectures": [
|
4 |
+
"BertForSequenceClassification"
|
5 |
+
],
|
6 |
+
"attention_probs_dropout_prob": 0.1,
|
7 |
+
"classifier_dropout": null,
|
8 |
+
"hidden_act": "gelu",
|
9 |
+
"hidden_dropout_prob": 0.1,
|
10 |
+
"hidden_size": 384,
|
11 |
+
"id2label": {
|
12 |
+
"0": "LABEL_0"
|
13 |
+
},
|
14 |
+
"initializer_range": 0.02,
|
15 |
+
"intermediate_size": 1536,
|
16 |
+
"label2id": {
|
17 |
+
"LABEL_0": 0
|
18 |
+
},
|
19 |
+
"layer_norm_eps": 1e-12,
|
20 |
+
"max_position_embeddings": 512,
|
21 |
+
"model_type": "bert",
|
22 |
+
"num_attention_heads": 12,
|
23 |
+
"num_hidden_layers": 12,
|
24 |
+
"pad_token_id": 0,
|
25 |
+
"position_embedding_type": "absolute",
|
26 |
+
"torch_dtype": "float32",
|
27 |
+
"transformers_version": "4.48.3",
|
28 |
+
"type_vocab_size": 2,
|
29 |
+
"use_cache": true,
|
30 |
+
"vocab_size": 30522
|
31 |
+
}
|
model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:82343d5ad9bccb84565dcdbfd3de9f41f3e5363d11e7312ea6a033130de0ea95
|
3 |
+
size 133464836
|
special_tokens_map.json
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cls_token": {
|
3 |
+
"content": "[CLS]",
|
4 |
+
"lstrip": false,
|
5 |
+
"normalized": false,
|
6 |
+
"rstrip": false,
|
7 |
+
"single_word": false
|
8 |
+
},
|
9 |
+
"mask_token": {
|
10 |
+
"content": "[MASK]",
|
11 |
+
"lstrip": false,
|
12 |
+
"normalized": false,
|
13 |
+
"rstrip": false,
|
14 |
+
"single_word": false
|
15 |
+
},
|
16 |
+
"pad_token": {
|
17 |
+
"content": "[PAD]",
|
18 |
+
"lstrip": false,
|
19 |
+
"normalized": false,
|
20 |
+
"rstrip": false,
|
21 |
+
"single_word": false
|
22 |
+
},
|
23 |
+
"sep_token": {
|
24 |
+
"content": "[SEP]",
|
25 |
+
"lstrip": false,
|
26 |
+
"normalized": false,
|
27 |
+
"rstrip": false,
|
28 |
+
"single_word": false
|
29 |
+
},
|
30 |
+
"unk_token": {
|
31 |
+
"content": "[UNK]",
|
32 |
+
"lstrip": false,
|
33 |
+
"normalized": false,
|
34 |
+
"rstrip": false,
|
35 |
+
"single_word": false
|
36 |
+
}
|
37 |
+
}
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer_config.json
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"added_tokens_decoder": {
|
3 |
+
"0": {
|
4 |
+
"content": "[PAD]",
|
5 |
+
"lstrip": false,
|
6 |
+
"normalized": false,
|
7 |
+
"rstrip": false,
|
8 |
+
"single_word": false,
|
9 |
+
"special": true
|
10 |
+
},
|
11 |
+
"100": {
|
12 |
+
"content": "[UNK]",
|
13 |
+
"lstrip": false,
|
14 |
+
"normalized": false,
|
15 |
+
"rstrip": false,
|
16 |
+
"single_word": false,
|
17 |
+
"special": true
|
18 |
+
},
|
19 |
+
"101": {
|
20 |
+
"content": "[CLS]",
|
21 |
+
"lstrip": false,
|
22 |
+
"normalized": false,
|
23 |
+
"rstrip": false,
|
24 |
+
"single_word": false,
|
25 |
+
"special": true
|
26 |
+
},
|
27 |
+
"102": {
|
28 |
+
"content": "[SEP]",
|
29 |
+
"lstrip": false,
|
30 |
+
"normalized": false,
|
31 |
+
"rstrip": false,
|
32 |
+
"single_word": false,
|
33 |
+
"special": true
|
34 |
+
},
|
35 |
+
"103": {
|
36 |
+
"content": "[MASK]",
|
37 |
+
"lstrip": false,
|
38 |
+
"normalized": false,
|
39 |
+
"rstrip": false,
|
40 |
+
"single_word": false,
|
41 |
+
"special": true
|
42 |
+
}
|
43 |
+
},
|
44 |
+
"clean_up_tokenization_spaces": true,
|
45 |
+
"cls_token": "[CLS]",
|
46 |
+
"do_basic_tokenize": true,
|
47 |
+
"do_lower_case": true,
|
48 |
+
"extra_special_tokens": {},
|
49 |
+
"mask_token": "[MASK]",
|
50 |
+
"max_length": 512,
|
51 |
+
"model_max_length": 512,
|
52 |
+
"never_split": null,
|
53 |
+
"pad_to_multiple_of": null,
|
54 |
+
"pad_token": "[PAD]",
|
55 |
+
"pad_token_type_id": 0,
|
56 |
+
"padding_side": "right",
|
57 |
+
"sep_token": "[SEP]",
|
58 |
+
"stride": 0,
|
59 |
+
"strip_accents": null,
|
60 |
+
"tokenize_chinese_chars": true,
|
61 |
+
"tokenizer_class": "BertTokenizer",
|
62 |
+
"truncation_side": "right",
|
63 |
+
"truncation_strategy": "longest_first",
|
64 |
+
"unk_token": "[UNK]"
|
65 |
+
}
|
vocab.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|