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, )

1. Set the device (uses GPU if available, otherwise CPU)

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

2. Point to your local checkpoint directory

model_name = "EyalMaor/roberta-base-boolq-idk"

3. Load the model and tokenizer from the local path

model = AutoModelForSequenceClassification.from_pretrained(model_name) model.to(device)

tokenizer = AutoTokenizer.from_pretrained(model_name)

4. Define the inference function

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}")

5. Test Sample

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?"

Fixed the variable name typo from s_question to question

predict(question, passage)

Downloads last month
158
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support