Text Ranking
sentence-transformers
PyTorch
JAX
ONNX
Safetensors
OpenVINO
Transformers
English
bert
text-classification
text-embeddings-inference
Instructions to use cross-encoder/stsb-TinyBERT-L4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use cross-encoder/stsb-TinyBERT-L4 with sentence-transformers:
from sentence_transformers import CrossEncoder model = CrossEncoder("cross-encoder/stsb-TinyBERT-L4") 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) - Transformers
How to use cross-encoder/stsb-TinyBERT-L4 with Transformers:
# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("cross-encoder/stsb-TinyBERT-L4") model = AutoModelForSequenceClassification.from_pretrained("cross-encoder/stsb-TinyBERT-L4") - Notebooks
- Google Colab
- Kaggle
nreimers commited on
Commit ·
db6ce33
1
Parent(s): c1a44ab
upload
Browse files- CECorrelationEvaluator_sts-dev_results.csv +7 -0
- README.md +19 -0
- config.json +28 -0
- pytorch_model.bin +3 -0
- special_tokens_map.json +1 -0
- tokenizer_config.json +1 -0
- vocab.txt +0 -0
CECorrelationEvaluator_sts-dev_results.csv
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
epoch,steps,Pearson_Correlation,Spearman_Correlation
|
| 2 |
+
0,-1,0.8545983323224908,0.8468392535285587
|
| 3 |
+
1,-1,0.8571942532186558,0.8520208839729133
|
| 4 |
+
2,-1,0.8613338704883177,0.8538568557640089
|
| 5 |
+
3,-1,0.8616480884450483,0.8550005160746958
|
| 6 |
+
4,-1,0.8605050883898332,0.8543731967733662
|
| 7 |
+
5,-1,0.8612005934368199,0.8541962412946662
|
README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Cross-Encoder for Quora Duplicate Questions Detection
|
| 2 |
+
This model was trained using [SentenceTransformers](https://sbert.net) [Cross-Encoder](https://www.sbert.net/examples/applications/cross-encoder/README.html) class.
|
| 3 |
+
|
| 4 |
+
## Training Data
|
| 5 |
+
This model was trained on the [STS benchmark dataset](http://ixa2.si.ehu.eus/stswiki/index.php/STSbenchmark). The model will predict a score between 0 and 1 how for the semantic similarity of two sentences.
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
## Usage and Performance
|
| 9 |
+
|
| 10 |
+
Pre-trained models can be used like this:
|
| 11 |
+
```
|
| 12 |
+
from sentence_transformers import CrossEncoder
|
| 13 |
+
model = CrossEncoder('model_name')
|
| 14 |
+
scores = model.predict([('Sentence 1', 'Sentence 2'), ('Sentence 3', 'Sentence 4')])
|
| 15 |
+
```
|
| 16 |
+
|
| 17 |
+
The model will predict scores for the pairs `('Sentence 1', 'Sentence 2')` and `('Sentence 3', 'Sentence 4')`.
|
| 18 |
+
|
| 19 |
+
You can use this model also without sentence_transformers and by just using Transformers ``AutoModel`` class
|
config.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_name_or_path": "output/TinyBERT_L-4-nli/",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"BertForSequenceClassification"
|
| 5 |
+
],
|
| 6 |
+
"attention_probs_dropout_prob": 0.1,
|
| 7 |
+
"gradient_checkpointing": false,
|
| 8 |
+
"hidden_act": "gelu",
|
| 9 |
+
"hidden_dropout_prob": 0.1,
|
| 10 |
+
"hidden_size": 312,
|
| 11 |
+
"id2label": {
|
| 12 |
+
"0": "LABEL_0"
|
| 13 |
+
},
|
| 14 |
+
"initializer_range": 0.02,
|
| 15 |
+
"intermediate_size": 1200,
|
| 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": 4,
|
| 24 |
+
"pad_token_id": 0,
|
| 25 |
+
"position_embedding_type": "absolute",
|
| 26 |
+
"type_vocab_size": 2,
|
| 27 |
+
"vocab_size": 30522
|
| 28 |
+
}
|
pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c81276416deab713ab841b7d4afa2484270d5d23d735d1baa27a7bc1501080e2
|
| 3 |
+
size 57436041
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"do_lower_case": true, "unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]", "tokenize_chinese_chars": true, "strip_accents": null, "model_max_length": 512, "special_tokens_map_file": "/home/ukp-reimers/.cache/huggingface/transformers/f96b11e14fec8f4be06121e7f6bbe07f82216bf7d75ad76fe3a81251e8895d69.dd8bd9bfd3664b530ea4e645105f557769387b3da9f79bdb55ed556bdd80611d", "name_or_path": "output/TinyBERT_L-4-nli/", "do_basic_tokenize": true, "never_split": null}
|
vocab.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|