đ Cross-Encoder for SQuAD (QNLI)
This model is designed for text ranking, trained using the Cross-Encoder class to determine if a question can be answered by a given paragraph.
đ Quick Start
This model was trained using SentenceTransformers Cross-Encoder class.
⨠Features
- Task: Given a question and paragraph, it can determine whether the question can be answered by the paragraph.
- Training Data: Trained on the GLUE QNLI dataset, which transformed the SQuAD dataset into an NLI task.
đĻ Installation
No specific installation steps are provided in the original document, so this section is skipped.
đģ Usage Examples
Basic Usage
Pre-trained models can be used like this:
from sentence_transformers import CrossEncoder
model = CrossEncoder('cross-encoder/qnli-distilroberta-base')
scores = model.predict([('Query1', 'Paragraph1'), ('Query2', 'Paragraph2')])
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.')])
Advanced Usage
You can use the model also directly with Transformers library (without SentenceTransformers library):
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model = AutoModelForSequenceClassification.from_pretrained('cross-encoder/qnli-distilroberta-base')
tokenizer = AutoTokenizer.from_pretrained('cross-encoder/qnli-distilroberta-base')
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")
model.eval()
with torch.no_grad():
scores = torch.nn.functional.sigmoid(model(**features).logits)
print(scores)
đ Documentation
Training Data
Given a question and paragraph, can the question be answered by the paragraph? The models have been trained on the GLUE QNLI dataset, which transformed the SQuAD dataset into an NLI task.
Performance
For performance results of this model, see SBERT.net Pre-trained Cross-Encoder.
đ§ Technical Details
No detailed technical implementation details are provided in the original document, so this section is skipped.
đ License
The model is released under the Apache-2.0 license.
Property |
Details |
Model Type |
Cross-Encoder for SQuAD (QNLI) |
Training Data |
GLUE QNLI dataset, which transformed the SQuAD dataset into an NLI task |
Library Name |
sentence-transformers |
Tags |
transformers |
Base Model |
distilbert/distilroberta-base |
Pipeline Tag |
text-ranking |