Text Classification
Transformers
PyTorch
Safetensors
English
roberta
boolean-qa
text-embeddings-inference
Instructions to use shahrukhx01/roberta-base-boolq with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use shahrukhx01/roberta-base-boolq with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="shahrukhx01/roberta-base-boolq")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("shahrukhx01/roberta-base-boolq") model = AutoModelForSequenceClassification.from_pretrained("shahrukhx01/roberta-base-boolq", device_map="auto") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from shahrukhx01/roberta-base-boolq: direct link, hf CLI and curl.
- Browser
- Download file 1.42 kB
-
https://huggingface.co/shahrukhx01/roberta-base-boolq/resolve/main/README.md
- Command line
-
hf download hf://shahrukhx01/roberta-base-boolq/README.md
-
curl -L -o README.md https://huggingface.co/shahrukhx01/roberta-base-boolq/resolve/main/README.md
1.42 kB
metadata
language: en
tags:
- boolean-qa
widget:
- text: >-
Is Berlin the smallest city of Germany? <s> Berlin is the capital and
largest city of Germany by both area and population. Its 3.8 million
inhabitants make it the European Union's most populous city, according to
the population within city limits
Labels Map
LABEL_0 => "NO"
LABEL_1 => "YES"
from transformers import (
AutoModelForSequenceClassification,
AutoTokenizer,
)
model = AutoModelForSequenceClassification.from_pretrained("shahrukhx01/roberta-base-boolq")
model.to(device)
#model.push_to_hub("roberta-base-boolq")
tokenizer = AutoTokenizer.from_pretrained("shahrukhx01/roberta-base-boolq")
def predict(question, passage):
sequence = tokenizer.encode_plus(question, passage, return_tensors="pt")['input_ids'].to(device)
logits = model(sequence)[0]
probabilities = torch.softmax(logits, dim=1).detach().cpu().tolist()[0]
proba_yes = round(probabilities[1], 2)
proba_no = round(probabilities[0], 2)
print(f"Question: {question}, Yes: {proba_yes}, No: {proba_no}")
passage = """Berlin is the capital and largest city of Germany by both area and population. Its 3.8 million inhabitants make it the European Union's most populous city,
according to the population within city limits."""
question = "Is Berlin the smallest city of Germany?"
predict(s_question, passage)