Text Ranking
sentence-transformers
Safetensors
English
bert
cross-encoder
text-classification
Generated from Trainer
dataset_size:578402
loss:BinaryCrossEntropyLoss
text-embeddings-inference
Instructions to use cross-encoder-testing/reranker-bert-tiny-gooaq-bce-v6 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use cross-encoder-testing/reranker-bert-tiny-gooaq-bce-v6 with sentence-transformers:
from sentence_transformers import CrossEncoder model = CrossEncoder("cross-encoder-testing/reranker-bert-tiny-gooaq-bce-v6") query = "Which planet is known as the Red Planet?" passages = [ "Venus is often called Earth's twin because of its similar size and proximity.", "Mars, known for its reddish appearance, is often referred to as the Red Planet.", "Jupiter, the largest planet in our solar system, has a prominent red spot.", "Saturn, famous for its rings, is sometimes mistaken for the Red Planet." ] scores = model.predict([(query, passage) for passage in passages]) print(scores) - Notebooks
- Google Colab
- Kaggle
Uploading CrossEncoder model.
Browse files- README.md +138 -0
- config.json +30 -0
- config_sentence_transformers.json +9 -0
- model.safetensors +3 -0
- modules.json +8 -0
- sentence_bert_config.json +10 -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,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
tags:
|
| 3 |
+
- sentence-transformers
|
| 4 |
+
- cross-encoder
|
| 5 |
+
- reranker
|
| 6 |
+
base_model: cross-encoder-testing/reranker-bert-tiny-gooaq-bce
|
| 7 |
+
pipeline_tag: text-ranking
|
| 8 |
+
library_name: sentence-transformers
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# CrossEncoder based on cross-encoder-testing/reranker-bert-tiny-gooaq-bce
|
| 12 |
+
|
| 13 |
+
This is a [Cross Encoder](https://www.sbert.net/docs/cross_encoder/usage/usage.html) model finetuned from [cross-encoder-testing/reranker-bert-tiny-gooaq-bce](https://huggingface.co/cross-encoder-testing/reranker-bert-tiny-gooaq-bce) 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-testing/reranker-bert-tiny-gooaq-bce](https://huggingface.co/cross-encoder-testing/reranker-bert-tiny-gooaq-bce) <!-- at revision 0d75677beaddce2ff048cbd96079c3e2ce0e984f -->
|
| 20 |
+
- **Maximum Sequence Length:** 512 tokens
|
| 21 |
+
- **Number of Output Labels:** 1 label
|
| 22 |
+
<!-- - **Training Dataset:** Unknown -->
|
| 23 |
+
<!-- - **Language:** Unknown -->
|
| 24 |
+
<!-- - **License:** Unknown -->
|
| 25 |
+
|
| 26 |
+
### Model Sources
|
| 27 |
+
|
| 28 |
+
- **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
|
| 29 |
+
- **Documentation:** [Cross Encoder Documentation](https://www.sbert.net/docs/cross_encoder/usage/usage.html)
|
| 30 |
+
- **Repository:** [Sentence Transformers on GitHub](https://github.com/huggingface/sentence-transformers)
|
| 31 |
+
- **Hugging Face:** [Cross Encoders on Hugging Face](https://huggingface.co/models?library=sentence-transformers&other=cross-encoder)
|
| 32 |
+
|
| 33 |
+
## Usage
|
| 34 |
+
|
| 35 |
+
### Direct Usage (Sentence Transformers)
|
| 36 |
+
|
| 37 |
+
First install the Sentence Transformers library:
|
| 38 |
+
|
| 39 |
+
```bash
|
| 40 |
+
pip install -U sentence-transformers
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
Then you can load this model and run inference.
|
| 44 |
+
```python
|
| 45 |
+
from sentence_transformers import CrossEncoder
|
| 46 |
+
|
| 47 |
+
# Download from the 🤗 Hub
|
| 48 |
+
model = CrossEncoder("cross-encoder-testing/reranker-bert-tiny-gooaq-bce-v6")
|
| 49 |
+
# Get scores for pairs of texts
|
| 50 |
+
pairs = [
|
| 51 |
+
['How many calories in an egg', 'There are on average between 55 and 80 calories in an egg depending on its size.'],
|
| 52 |
+
['How many calories in an egg', 'Egg whites are very low in calories, have no fat, no cholesterol, and are loaded with protein.'],
|
| 53 |
+
['How many calories in an egg', 'Most of the calories in an egg come from the yellow yolk in the center.'],
|
| 54 |
+
]
|
| 55 |
+
scores = model.predict(pairs)
|
| 56 |
+
print(scores.shape)
|
| 57 |
+
# (3,)
|
| 58 |
+
|
| 59 |
+
# Or rank different texts based on similarity to a single text
|
| 60 |
+
ranks = model.rank(
|
| 61 |
+
'How many calories in an egg',
|
| 62 |
+
[
|
| 63 |
+
'There are on average between 55 and 80 calories in an egg depending on its size.',
|
| 64 |
+
'Egg whites are very low in calories, have no fat, no cholesterol, and are loaded with protein.',
|
| 65 |
+
'Most of the calories in an egg come from the yellow yolk in the center.',
|
| 66 |
+
]
|
| 67 |
+
)
|
| 68 |
+
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
<!--
|
| 72 |
+
### Direct Usage (Transformers)
|
| 73 |
+
|
| 74 |
+
<details><summary>Click to see the direct usage in Transformers</summary>
|
| 75 |
+
|
| 76 |
+
</details>
|
| 77 |
+
-->
|
| 78 |
+
|
| 79 |
+
<!--
|
| 80 |
+
### Downstream Usage (Sentence Transformers)
|
| 81 |
+
|
| 82 |
+
You can finetune this model on your own dataset.
|
| 83 |
+
|
| 84 |
+
<details><summary>Click to expand</summary>
|
| 85 |
+
|
| 86 |
+
</details>
|
| 87 |
+
-->
|
| 88 |
+
|
| 89 |
+
<!--
|
| 90 |
+
### Out-of-Scope Use
|
| 91 |
+
|
| 92 |
+
*List how the model may foreseeably be misused and address what users ought not to do with the model.*
|
| 93 |
+
-->
|
| 94 |
+
|
| 95 |
+
<!--
|
| 96 |
+
## Bias, Risks and Limitations
|
| 97 |
+
|
| 98 |
+
*What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
|
| 99 |
+
-->
|
| 100 |
+
|
| 101 |
+
<!--
|
| 102 |
+
### Recommendations
|
| 103 |
+
|
| 104 |
+
*What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
|
| 105 |
+
-->
|
| 106 |
+
|
| 107 |
+
## Training Details
|
| 108 |
+
|
| 109 |
+
### Framework Versions
|
| 110 |
+
- Python: 3.11.6
|
| 111 |
+
- Sentence Transformers: 5.2.0.dev0
|
| 112 |
+
- Transformers: 5.0.0.dev0
|
| 113 |
+
- PyTorch: 2.8.0+cu128
|
| 114 |
+
- Accelerate: 1.6.0
|
| 115 |
+
- Datasets: 4.2.0
|
| 116 |
+
- Tokenizers: 0.22.1
|
| 117 |
+
|
| 118 |
+
## Citation
|
| 119 |
+
|
| 120 |
+
### BibTeX
|
| 121 |
+
|
| 122 |
+
<!--
|
| 123 |
+
## Glossary
|
| 124 |
+
|
| 125 |
+
*Clearly define terms in order to be accessible across audiences.*
|
| 126 |
+
-->
|
| 127 |
+
|
| 128 |
+
<!--
|
| 129 |
+
## Model Card Authors
|
| 130 |
+
|
| 131 |
+
*Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
|
| 132 |
+
-->
|
| 133 |
+
|
| 134 |
+
<!--
|
| 135 |
+
## Model Card Contact
|
| 136 |
+
|
| 137 |
+
*Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
|
| 138 |
+
-->
|
config.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"BertForSequenceClassification"
|
| 4 |
+
],
|
| 5 |
+
"attention_probs_dropout_prob": 0.1,
|
| 6 |
+
"classifier_dropout": null,
|
| 7 |
+
"dtype": "float32",
|
| 8 |
+
"hidden_act": "gelu",
|
| 9 |
+
"hidden_dropout_prob": 0.1,
|
| 10 |
+
"hidden_size": 128,
|
| 11 |
+
"id2label": {
|
| 12 |
+
"0": "LABEL_0"
|
| 13 |
+
},
|
| 14 |
+
"initializer_range": 0.02,
|
| 15 |
+
"intermediate_size": 512,
|
| 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": 2,
|
| 23 |
+
"num_hidden_layers": 2,
|
| 24 |
+
"pad_token_id": 0,
|
| 25 |
+
"position_embedding_type": "absolute",
|
| 26 |
+
"transformers_version": "5.0.0.dev0",
|
| 27 |
+
"type_vocab_size": 2,
|
| 28 |
+
"use_cache": true,
|
| 29 |
+
"vocab_size": 30522
|
| 30 |
+
}
|
config_sentence_transformers.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model_type": "CrossEncoder",
|
| 3 |
+
"__version__": {
|
| 4 |
+
"sentence_transformers": "5.2.0.dev0",
|
| 5 |
+
"transformers": "5.0.0.dev0",
|
| 6 |
+
"pytorch": "2.8.0+cu128"
|
| 7 |
+
},
|
| 8 |
+
"activation_fn": "torch.nn.modules.activation.Sigmoid"
|
| 9 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1e29bb7709134dfc7b374375802767c4cbed41dfff30eee538b951bfcf472cc1
|
| 3 |
+
size 17548796
|
modules.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"idx": 0,
|
| 4 |
+
"name": "0",
|
| 5 |
+
"path": "",
|
| 6 |
+
"type": "sentence_transformers.base.models.Transformer"
|
| 7 |
+
}
|
| 8 |
+
]
|
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 |
+
}
|
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
|
|
|