Downloads · 30 days
59
8% of all-time downloads
dilip025/RoBERTa-mini
RoBERTa-mini is a text classification model from dilip025. Use it when you need a label for a piece of text. The card lists the license as mit.
Model Name: dilip025/RoBERTa-mini Task: Sentiment Classification Labels: Very Negative, Negative, Neutral, Positive, Very Positive
Downloads · 30 days
59
8% of all-time downloads
All-time downloads
711
Public
Parameters
34.6M
93.7 GB on disk
Likes
0
Public
Click a slice to open those files.
.pt60.4 GB · 99%
From the Hugging Face model README
Model Name: dilip025/RoBERTa-mini
Task: Sentiment Classification
Labels: Very Negative, Negative, Neutral, Positive, Very Positive
A compact RoBERTa like model trained from scratch for sentiment classification.
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
tokenizer = AutoTokenizer.from_pretrained("dilip025/RoBERTa-mini")
model = AutoModelForSequenceClassification.from_pretrained("dilip025/RoBERTa-mini", trust_remote_code=True)
id2label = {
0: "Very Negative",
1: "Negative",
2: "Neutral",
3: "Positive",
4: "Very Positive"
}
def predict_sentiment(text):
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=128)
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs["logits"], dim=1)
pred_class = torch.argmax(probs, dim=1).item()
return {
"text": text,
"class_id": pred_class,
"label": id2label[pred_class],
"probabilities": probs.tolist()[0]
}
# Example
result = predict_sentiment("I absolutely hate this product.")
print(result)
This model is licensed under the MIT License. You are free to use, modify, and distribute it with attribution.
Developed and Trained by Dilip Pokhrel