Being new to the "Natural Language Processing" scene, I am experimentally learning and have implemented the following segment of code:
from transformers import RobertaTokenizer, RobertaForSequenceClassification
import torch
path = "D:/LM/rb/"
tokenizer = RobertaTokenizer.from_pretrained(path)
model = RobertaForSequenceClassification.from_pretrained(path)
inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
outputs = model(**inputs)
pred_logits = outputs.logits
print(pred_logits)
probs = pred_logits.softmax(dim=-1).detach().cpu().flatten().numpy().tolist()
print(probs)
I understand that applying the model returns a "torch.FloatTensor comprising various elements depending on the configuration (RobertaConfig) and inputs", and that the logits are accessible using .logits. As demonstrated I have applied the .softmax function to the tensor to return normalised probabilities and have converted the result into a list. I am outputted with the following:
[0.5022980570793152, 0.49770188331604004]
Do these probabilities represent some kind of overall "masked" probability?
What do the first and second index represent in context of the input?
EDIT:
model.num_labels
Output:
2
@cronoik explains that the model "tries to classify if a sequence belongs to one class or another"
Am I to assume that because there are no trained output layers these classes don't mean anything yet?
For example, I can assume that the probability that the sentence, post analysis, belongs to class 1 is 0.5. However, what is class 1?
Additionally, model cards with pre-trained output layers such as the open-ai detector help differentiate between what is "real" and "fake", and so I can assume the class that a sentence belongs to. However, how can I confirm these "labels" without some type of "mapping.txt" file?