Downloads · 30 days
4
2% of all-time downloads
EyalMaor/roberta-base-boolq-idk
roberta-base-boolq-idk is a machine learning model from EyalMaor. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
The labels which the model have are the following:
Downloads · 30 days
4
2% of all-time downloads
All-time downloads
171
Public
Repo size
499 MB
Likes
1
Public
Click a slice to open those files.
.bin499 MB · 99%
From the Hugging Face model README
The labels which the model have are the following:
LABEL_0 => "NO"
LABEL_1 => "YES"
LABEL_2 => "NO ANSWER"
code example:
python import torch from transformers import ( AutoModelForSequenceClassification, AutoTokenizer, )
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model_name = "EyalMaor/roberta-base-boolq-idk"
model = AutoModelForSequenceClassification.from_pretrained(model_name) model.to(device)
tokenizer = AutoTokenizer.from_pretrained(model_name)
def predict(question, passage): sequence = tokenizer.encode_plus(question, passage, return_tensors="pt")['input_ids'].to(device)
# Put model in evaluation mode for inference
model.eval()
with torch.no_grad():
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)
proba_no_answer = round(probabilities[2], 2)
print(f"Question: {question}\nYes: {proba_yes}, No: {proba_no}, NO_ANSWER: {proba_no_answer}")
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(question, passage)