Views
No views yet
felipesfpaula/bertimbau-large-InferBr-NLIneuralmind/bert-large-portuguese-casedneuralmind/bert-large-portuguese-cased tokenizer{0,1,2}neuralmind/bert-large-portuguese-casedaccuracy = (number of correctly predicted labels) / (total number of examples)f1_macro = unweighted average F₁ across labels {0,1,2}1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4# 1. Load tokenizer and model from HuggingFace
5tokenizer = AutoTokenizer.from_pretrained("felipesfpaula/bertimbau-large-InferBr-NLI")
6model = AutoModelForSequenceClassification.from_pretrained("felipesfpaula/bertimbau-large-InferBr-NLI")
7
8# 2. Encode a premise–hypothesis pair
9premise = "O gato está sentado no sofá."
10hypothesis = "O gato está deitado no sofá."
11encoded = tokenizer(premise, hypothesis, return_tensors="pt", max_length=128, truncation=True, padding="max_length")
12
13# 3. Run inference
14with torch.no_grad():
15 outputs = model(**encoded)
16 logits = outputs.logits
17 pred_id = torch.argmax(logits, dim=-1).item()
18
19# 4. Map prediction to label
20label_map = {0: "Contradiction", 1: "Entailment", 2: "Neutral"}
21print(f"Predicted label: {label_map[pred_id]}")