How to generate predictions from this model?

#3
by vivasvan100 - opened

sentence = tokenizer("god bless you",return_tensors="pt")
outputs = model(**inputs)
print(outputs.logits)

tensor([[ 1.9721, -1.8041]], grad_fn=<AddmmBackward0>)

is this how to generate the outputs?

AutopilotAI org
    inputs = tokenizer.encode("god bless you", return_tensors="pt")
    outputs = model(inputs)[0]
    probabilities = torch.softmax(outputs, dim=1)
    predicted_class = torch.argmax(probabilities).item()
    toxic_probability = round(probabilities[0][1].item() * 100, 2)
    pc = ""
    if predicted_class == 1:
        pc = "Toxic"
    else:
        pc = "Not toxic"
Your need to confirm your account before you can post a new comment.

Sign up or log in to comment