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
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
---
|
| 4 |
-
# Cross-Encoder for
|
| 5 |
This model was trained using [SentenceTransformers](https://sbert.net) [Cross-Encoder](https://www.sbert.net/examples/applications/cross-encoder/README.html) class.
|
| 6 |
|
| 7 |
## Training Data
|
|
@@ -15,7 +15,8 @@ For performance results of this model, see [SBERT.net Pre-trained Cross-Encoder]
|
|
| 15 |
Pre-trained models can be used like this:
|
| 16 |
```python
|
| 17 |
from sentence_transformers import CrossEncoder
|
| 18 |
-
|
|
|
|
| 19 |
scores = model.predict([('Query1', 'Paragraph1'), ('Query2', 'Paragraph2')])
|
| 20 |
|
| 21 |
#e.g.
|
|
@@ -28,8 +29,8 @@ You can use the model also directly with Transformers library (without SentenceT
|
|
| 28 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 29 |
import torch
|
| 30 |
|
| 31 |
-
model = AutoModelForSequenceClassification.from_pretrained('
|
| 32 |
-
tokenizer = AutoTokenizer.from_pretrained('
|
| 33 |
|
| 34 |
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")
|
| 35 |
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
---
|
| 4 |
+
# Cross-Encoder for SQuAD (QNLI)
|
| 5 |
This model was trained using [SentenceTransformers](https://sbert.net) [Cross-Encoder](https://www.sbert.net/examples/applications/cross-encoder/README.html) class.
|
| 6 |
|
| 7 |
## Training Data
|
|
|
|
| 15 |
Pre-trained models can be used like this:
|
| 16 |
```python
|
| 17 |
from sentence_transformers import CrossEncoder
|
| 18 |
+
|
| 19 |
+
model = CrossEncoder('cross-encoder/qnli-electra-base')
|
| 20 |
scores = model.predict([('Query1', 'Paragraph1'), ('Query2', 'Paragraph2')])
|
| 21 |
|
| 22 |
#e.g.
|
|
|
|
| 29 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 30 |
import torch
|
| 31 |
|
| 32 |
+
model = AutoModelForSequenceClassification.from_pretrained('cross-encoder/qnli-electra-base')
|
| 33 |
+
tokenizer = AutoTokenizer.from_pretrained('cross-encoder/qnli-electra-base')
|
| 34 |
|
| 35 |
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")
|
| 36 |
|