Upload folder using huggingface_hub
Browse files- cross_encoder_model/README.md +147 -0
- cross_encoder_model/config.json +36 -0
- cross_encoder_model/config_sentence_transformers.json +11 -0
- cross_encoder_model/model.safetensors +3 -0
- cross_encoder_model/modules.json +8 -0
- cross_encoder_model/sentence_bert_config.json +10 -0
- cross_encoder_model/tokenizer.json +3 -0
- cross_encoder_model/tokenizer_config.json +18 -0
cross_encoder_model/README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
tags:
|
| 3 |
+
- sentence-transformers
|
| 4 |
+
- cross-encoder
|
| 5 |
+
- reranker
|
| 6 |
+
base_model: cross-encoder/ms-marco-MiniLM-L6-v2
|
| 7 |
+
pipeline_tag: text-ranking
|
| 8 |
+
library_name: sentence-transformers
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# CrossEncoder based on cross-encoder/ms-marco-MiniLM-L6-v2
|
| 12 |
+
|
| 13 |
+
This is a [Cross Encoder](https://www.sbert.net/docs/cross_encoder/usage/usage.html) model finetuned from [cross-encoder/ms-marco-MiniLM-L6-v2](https://huggingface.co/cross-encoder/ms-marco-MiniLM-L6-v2) using the [sentence-transformers](https://www.SBERT.net) library. It computes scores for pairs of texts, which can be used for text reranking and semantic search.
|
| 14 |
+
|
| 15 |
+
## Model Details
|
| 16 |
+
|
| 17 |
+
### Model Description
|
| 18 |
+
- **Model Type:** Cross Encoder
|
| 19 |
+
- **Base model:** [cross-encoder/ms-marco-MiniLM-L6-v2](https://huggingface.co/cross-encoder/ms-marco-MiniLM-L6-v2) <!-- at revision c5ee24cb16019beea0893ab7796b1df96625c6b8 -->
|
| 20 |
+
- **Maximum Sequence Length:** 512 tokens
|
| 21 |
+
- **Number of Output Labels:** 1 label
|
| 22 |
+
- **Supported Modality:** Text
|
| 23 |
+
<!-- - **Training Dataset:** Unknown -->
|
| 24 |
+
<!-- - **Language:** Unknown -->
|
| 25 |
+
<!-- - **License:** Unknown -->
|
| 26 |
+
|
| 27 |
+
### Model Sources
|
| 28 |
+
|
| 29 |
+
- **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
|
| 30 |
+
- **Documentation:** [Cross Encoder Documentation](https://www.sbert.net/docs/cross_encoder/usage/usage.html)
|
| 31 |
+
- **Repository:** [Sentence Transformers on GitHub](https://github.com/huggingface/sentence-transformers)
|
| 32 |
+
- **Hugging Face:** [Cross Encoders on Hugging Face](https://huggingface.co/models?library=sentence-transformers&other=cross-encoder)
|
| 33 |
+
|
| 34 |
+
### Full Model Architecture
|
| 35 |
+
|
| 36 |
+
```
|
| 37 |
+
CrossEncoder(
|
| 38 |
+
(0): Transformer({'transformer_task': 'sequence-classification', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'logits'}}, 'module_output_name': 'scores', 'architecture': 'BertForSequenceClassification'})
|
| 39 |
+
)
|
| 40 |
+
```
|
| 41 |
+
|
| 42 |
+
## Usage
|
| 43 |
+
|
| 44 |
+
### Direct Usage (Sentence Transformers)
|
| 45 |
+
|
| 46 |
+
First install the Sentence Transformers library:
|
| 47 |
+
|
| 48 |
+
```bash
|
| 49 |
+
pip install -U sentence-transformers
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
Then you can load this model and run inference.
|
| 53 |
+
```python
|
| 54 |
+
from sentence_transformers import CrossEncoder
|
| 55 |
+
|
| 56 |
+
# Download from the 🤗 Hub
|
| 57 |
+
model = CrossEncoder("cross_encoder_model_id")
|
| 58 |
+
# Get scores for pairs of inputs
|
| 59 |
+
pairs = [
|
| 60 |
+
['How many calories in an egg', 'There are on average between 55 and 80 calories in an egg depending on its size.'],
|
| 61 |
+
['How many calories in an egg', 'Egg whites are very low in calories, have no fat, no cholesterol, and are loaded with protein.'],
|
| 62 |
+
['How many calories in an egg', 'Most of the calories in an egg come from the yellow yolk in the center.'],
|
| 63 |
+
]
|
| 64 |
+
scores = model.predict(pairs)
|
| 65 |
+
print(scores)
|
| 66 |
+
# [ 9.9541 -2.0108 0.9186]
|
| 67 |
+
|
| 68 |
+
# Or rank different texts based on similarity to a single text
|
| 69 |
+
ranks = model.rank(
|
| 70 |
+
'How many calories in an egg',
|
| 71 |
+
[
|
| 72 |
+
'There are on average between 55 and 80 calories in an egg depending on its size.',
|
| 73 |
+
'Egg whites are very low in calories, have no fat, no cholesterol, and are loaded with protein.',
|
| 74 |
+
'Most of the calories in an egg come from the yellow yolk in the center.',
|
| 75 |
+
]
|
| 76 |
+
)
|
| 77 |
+
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
<!--
|
| 81 |
+
### Direct Usage (Transformers)
|
| 82 |
+
|
| 83 |
+
<details><summary>Click to see the direct usage in Transformers</summary>
|
| 84 |
+
|
| 85 |
+
</details>
|
| 86 |
+
-->
|
| 87 |
+
|
| 88 |
+
<!--
|
| 89 |
+
### Downstream Usage (Sentence Transformers)
|
| 90 |
+
|
| 91 |
+
You can finetune this model on your own dataset.
|
| 92 |
+
|
| 93 |
+
<details><summary>Click to expand</summary>
|
| 94 |
+
|
| 95 |
+
</details>
|
| 96 |
+
-->
|
| 97 |
+
|
| 98 |
+
<!--
|
| 99 |
+
### Out-of-Scope Use
|
| 100 |
+
|
| 101 |
+
*List how the model may foreseeably be misused and address what users ought not to do with the model.*
|
| 102 |
+
-->
|
| 103 |
+
|
| 104 |
+
<!--
|
| 105 |
+
## Bias, Risks and Limitations
|
| 106 |
+
|
| 107 |
+
*What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
|
| 108 |
+
-->
|
| 109 |
+
|
| 110 |
+
<!--
|
| 111 |
+
### Recommendations
|
| 112 |
+
|
| 113 |
+
*What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
|
| 114 |
+
-->
|
| 115 |
+
|
| 116 |
+
## Training Details
|
| 117 |
+
|
| 118 |
+
### Framework Versions
|
| 119 |
+
- Python: 3.12.13
|
| 120 |
+
- Sentence Transformers: 5.4.1
|
| 121 |
+
- Transformers: 5.0.0
|
| 122 |
+
- PyTorch: 2.10.0+cu128
|
| 123 |
+
- Accelerate: 1.13.0
|
| 124 |
+
- Datasets: 4.0.0
|
| 125 |
+
- Tokenizers: 0.22.2
|
| 126 |
+
|
| 127 |
+
## Citation
|
| 128 |
+
|
| 129 |
+
### BibTeX
|
| 130 |
+
|
| 131 |
+
<!--
|
| 132 |
+
## Glossary
|
| 133 |
+
|
| 134 |
+
*Clearly define terms in order to be accessible across audiences.*
|
| 135 |
+
-->
|
| 136 |
+
|
| 137 |
+
<!--
|
| 138 |
+
## Model Card Authors
|
| 139 |
+
|
| 140 |
+
*Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
|
| 141 |
+
-->
|
| 142 |
+
|
| 143 |
+
<!--
|
| 144 |
+
## Model Card Contact
|
| 145 |
+
|
| 146 |
+
*Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
|
| 147 |
+
-->
|
cross_encoder_model/config.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_cross_attention": false,
|
| 3 |
+
"architectures": [
|
| 4 |
+
"BertForSequenceClassification"
|
| 5 |
+
],
|
| 6 |
+
"attention_probs_dropout_prob": 0.1,
|
| 7 |
+
"bos_token_id": null,
|
| 8 |
+
"classifier_dropout": null,
|
| 9 |
+
"dtype": "float32",
|
| 10 |
+
"eos_token_id": null,
|
| 11 |
+
"gradient_checkpointing": false,
|
| 12 |
+
"hidden_act": "gelu",
|
| 13 |
+
"hidden_dropout_prob": 0.1,
|
| 14 |
+
"hidden_size": 384,
|
| 15 |
+
"id2label": {
|
| 16 |
+
"0": "LABEL_0"
|
| 17 |
+
},
|
| 18 |
+
"initializer_range": 0.02,
|
| 19 |
+
"intermediate_size": 1536,
|
| 20 |
+
"is_decoder": false,
|
| 21 |
+
"label2id": {
|
| 22 |
+
"LABEL_0": 0
|
| 23 |
+
},
|
| 24 |
+
"layer_norm_eps": 1e-12,
|
| 25 |
+
"max_position_embeddings": 512,
|
| 26 |
+
"model_type": "bert",
|
| 27 |
+
"num_attention_heads": 12,
|
| 28 |
+
"num_hidden_layers": 6,
|
| 29 |
+
"pad_token_id": 0,
|
| 30 |
+
"position_embedding_type": "absolute",
|
| 31 |
+
"tie_word_embeddings": true,
|
| 32 |
+
"transformers_version": "5.0.0",
|
| 33 |
+
"type_vocab_size": 2,
|
| 34 |
+
"use_cache": true,
|
| 35 |
+
"vocab_size": 30522
|
| 36 |
+
}
|
cross_encoder_model/config_sentence_transformers.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"__version__": {
|
| 3 |
+
"pytorch": "2.10.0+cu128",
|
| 4 |
+
"sentence_transformers": "5.4.1",
|
| 5 |
+
"transformers": "5.0.0"
|
| 6 |
+
},
|
| 7 |
+
"activation_fn": "torch.nn.modules.linear.Identity",
|
| 8 |
+
"default_prompt_name": null,
|
| 9 |
+
"model_type": "CrossEncoder",
|
| 10 |
+
"prompts": {}
|
| 11 |
+
}
|
cross_encoder_model/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5d5a1f2650eeb40eea5f06ddf0802b0ace0f102a28bddaa3a2cfbe65d54459ba
|
| 3 |
+
size 90866404
|
cross_encoder_model/modules.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"idx": 0,
|
| 4 |
+
"name": "0",
|
| 5 |
+
"path": "",
|
| 6 |
+
"type": "sentence_transformers.base.modules.transformer.Transformer"
|
| 7 |
+
}
|
| 8 |
+
]
|
cross_encoder_model/sentence_bert_config.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"transformer_task": "sequence-classification",
|
| 3 |
+
"modality_config": {
|
| 4 |
+
"text": {
|
| 5 |
+
"method": "forward",
|
| 6 |
+
"method_output_name": "logits"
|
| 7 |
+
}
|
| 8 |
+
},
|
| 9 |
+
"module_output_name": "scores"
|
| 10 |
+
}
|
cross_encoder_model/tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:91f1def9b9391fdabe028cd3f3fcc4efd34e5d1f08c3bf2de513ebb5911a1854
|
| 3 |
+
size 711649
|
cross_encoder_model/tokenizer_config.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"clean_up_tokenization_spaces": true,
|
| 4 |
+
"cls_token": "[CLS]",
|
| 5 |
+
"do_basic_tokenize": true,
|
| 6 |
+
"do_lower_case": true,
|
| 7 |
+
"is_local": false,
|
| 8 |
+
"mask_token": "[MASK]",
|
| 9 |
+
"model_max_length": 512,
|
| 10 |
+
"model_specific_special_tokens": {},
|
| 11 |
+
"never_split": null,
|
| 12 |
+
"pad_token": "[PAD]",
|
| 13 |
+
"sep_token": "[SEP]",
|
| 14 |
+
"strip_accents": null,
|
| 15 |
+
"tokenize_chinese_chars": true,
|
| 16 |
+
"tokenizer_class": "BertTokenizer",
|
| 17 |
+
"unk_token": "[UNK]"
|
| 18 |
+
}
|