Text Ranking
sentence-transformers
PyTorch
ONNX
Safetensors
OpenVINO
Transformers
English
electra
text-classification
Instructions to use cross-encoder/qnli-electra-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use cross-encoder/qnli-electra-base with sentence-transformers:
from sentence_transformers import CrossEncoder model = CrossEncoder("cross-encoder/qnli-electra-base") 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/qnli-electra-base with Transformers:
# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("cross-encoder/qnli-electra-base") model = AutoModelForSequenceClassification.from_pretrained("cross-encoder/qnli-electra-base") - Notebooks
- Google Colab
- Kaggle
nreimers commited on
Commit ·
e46c24c
1
Parent(s): b382f61
up
Browse files- CEBinaryAccuracyEvaluator_qnli-dev_results.csv +6 -0
- README.md +37 -0
- config.json +32 -0
- pytorch_model.bin +3 -0
- special_tokens_map.json +1 -0
- tokenizer_config.json +1 -0
- vocab.txt +0 -0
CEBinaryAccuracyEvaluator_qnli-dev_results.csv
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
epoch,steps,Accuracy
|
| 2 |
+
0,-1,0.9082921471718836
|
| 3 |
+
1,-1,0.9284276038806517
|
| 4 |
+
2,-1,0.9271462566355483
|
| 5 |
+
3,-1,0.9289767526999817
|
| 6 |
+
4,-1,0.9320885960095185
|
README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
Given a question and paragraph, can the question be answered by the paragraph? The models have been trained on the [GLUE QNLI](https://arxiv.org/abs/1804.07461) dataset, which transformed the [SQuAD dataset](https://rajpurkar.github.io/SQuAD-explorer/) into an NLI task.
|
| 6 |
+
|
| 7 |
+
## Performance
|
| 8 |
+
For performance results of this model, see [SBERT.net Pre-trained Cross-Encoder][https://www.sbert.net/docs/pretrained_cross-encoders.html].
|
| 9 |
+
|
| 10 |
+
## Usage
|
| 11 |
+
|
| 12 |
+
Pre-trained models can be used like this:
|
| 13 |
+
```python
|
| 14 |
+
from sentence_transformers import CrossEncoder
|
| 15 |
+
model = CrossEncoder('model_name')
|
| 16 |
+
scores = model.predict([('Query1', 'Paragraph1'), ('Query2', 'Paragraph2')])
|
| 17 |
+
|
| 18 |
+
#e.g.
|
| 19 |
+
scores = model.predict([('How many people live in Berlin?', 'Berlin had a population of 3,520,031 registered inhabitants in an area of 891.82 square kilometers.'), ('What is the size of New York?', 'New York City is famous for the Metropolitan Museum of Art.')])
|
| 20 |
+
```
|
| 21 |
+
|
| 22 |
+
## Usage with Transformers AutoModel
|
| 23 |
+
You can use the model also directly with Transformers library (without SentenceTransformers library):
|
| 24 |
+
```python
|
| 25 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 26 |
+
import torch
|
| 27 |
+
|
| 28 |
+
model = AutoModelForSequenceClassification.from_pretrained('model_name')
|
| 29 |
+
tokenizer = AutoTokenizer.from_pretrained('model_name')
|
| 30 |
+
|
| 31 |
+
features = tokenizer(['How many people live in Berlin?', 'What is the size of New York?'], ['Berlin had a population of 3,520,031 registered inhabitants in an area of 891.82 square kilometers.', 'New York City is famous for the Metropolitan Museum of Art.'], padding=True, truncation=True, return_tensors="pt")
|
| 32 |
+
|
| 33 |
+
model.eval()
|
| 34 |
+
with torch.no_grad():
|
| 35 |
+
scores = torch.nn.functional.sigmoid(model(**features).logits)
|
| 36 |
+
print(scores)
|
| 37 |
+
```
|
config.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_name_or_path": "google/electra-base-discriminator",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"ElectraForSequenceClassification"
|
| 5 |
+
],
|
| 6 |
+
"attention_probs_dropout_prob": 0.1,
|
| 7 |
+
"embedding_size": 768,
|
| 8 |
+
"hidden_act": "gelu",
|
| 9 |
+
"hidden_dropout_prob": 0.1,
|
| 10 |
+
"hidden_size": 768,
|
| 11 |
+
"id2label": {
|
| 12 |
+
"0": "LABEL_0"
|
| 13 |
+
},
|
| 14 |
+
"initializer_range": 0.02,
|
| 15 |
+
"intermediate_size": 3072,
|
| 16 |
+
"label2id": {
|
| 17 |
+
"LABEL_0": 0
|
| 18 |
+
},
|
| 19 |
+
"layer_norm_eps": 1e-12,
|
| 20 |
+
"max_position_embeddings": 512,
|
| 21 |
+
"model_type": "electra",
|
| 22 |
+
"num_attention_heads": 12,
|
| 23 |
+
"num_hidden_layers": 12,
|
| 24 |
+
"pad_token_id": 0,
|
| 25 |
+
"position_embedding_type": "absolute",
|
| 26 |
+
"summary_activation": "gelu",
|
| 27 |
+
"summary_last_dropout": 0.1,
|
| 28 |
+
"summary_type": "first",
|
| 29 |
+
"summary_use_proj": true,
|
| 30 |
+
"type_vocab_size": 2,
|
| 31 |
+
"vocab_size": 30522
|
| 32 |
+
}
|
pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f8af0b8d3dd81812e835e9ba39593a3a2fb88314dd0945c3da64800930f6012c
|
| 3 |
+
size 438022601
|
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, "name_or_path": "google/electra-base-discriminator"}
|
vocab.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|