Downloads · 30 days
8
23% of all-time downloads
RappyProgramming/IPW-RoBERTa-cased
IPW-RoBERTa-cased is a text classification model from RappyProgramming. Use it when you need a label for a piece of text. It is set up for transformers.
This model was created for a thesis. This model was created with a dataset obtained from social media X, with hashtag IsraelPalestineWar, collected from October - November 2023. This model is meant to classify sentime…
Downloads · 30 days
8
23% of all-time downloads
All-time downloads
35
Public
Parameters
125M
499 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors499 MB · 100%
From the Hugging Face model README
This model was created for a thesis. This model was created with a dataset obtained from social media X, with hashtag #IsraelPalestineWar, collected from October - November 2023. This model is meant to classify sentiment of tweets and suitable for english language.
from transformers import RobertaForSequenceClassification, RobertaTokenizer
import torch
output_model_dir = 'RappyProgramming/IPW-RoBERTa-cased'
model = RobertaForSequenceClassification.from_pretrained(output_model_dir)
tokenizer = RobertaTokenizer.from_pretrained(output_model_dir)
input_texts = [
"this meeting is scheduled for next week",
"drop dead",
"you're the best friend i could ever have in this whole wide world!!"
]
inputs = tokenizer(input_texts, return_tensors="pt", padding=True, truncation=True)
with torch.no_grad():
outputs = model(**inputs)
predicted_class_indices = torch.argmax(outputs.logits, dim=1).tolist()
probs = torch.softmax(outputs.logits, dim=1).tolist()
labels = ["Negative", "Neutral", "Positive"]
for i, input_text in enumerate(input_texts):
predicted_label = labels[predicted_class_indices[i]]
predicted_probabilities = {label: prob for label, prob in zip(labels, probs[i])}
print(f"Input text {i+1}: {input_text}")
print(f"Predicted label: {predicted_label}")
print("Predicted probabilities:")
for label, prob in predicted_probabilities.items():
print(f"{label}: {prob:.4f}")
print()
Output:
Input text 1: this meeting is scheduled for next week
Predicted label: Neutral
Predicted probabilities:
Negative: 0.0003
Neutral: 0.9994
Positive: 0.0004
Input text 2: drop dead
Predicted label: Negative
Predicted probabilities:
Negative: 0.8705
Neutral: 0.1290
Positive: 0.0005
Input text 3: you're the best friend i could ever have in this whole wide world!!
Predicted label: Positive
Predicted probabilities:
Negative: 0.0003
Neutral: 0.0001
Positive: 0.9995