Downloads · 30 days
160
0% of all-time downloads
shahrukhx01/roberta-base-boolq
roberta-base-boolq is a text classification model from shahrukhx01. Use it when you need a label for a piece of text. It is set up for transformers.
Downloads · 30 days
160
0% of all-time downloads
All-time downloads
87.9K
Public
Parameters
125M
2.5 GB on disk
Likes
2
Public
Click a slice to open those files.
.bin499 MB · 50%
How the weights are stored.
F32125M · 100%
From the Hugging Face model README
LABEL_0 => "NO" <br/> 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)