RoBERTa-mini: Sentiment Classifier

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.

Example Usage

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)

Model Card

  • Architecture: RoBERTa (custom small version)
  • Training Dataset: Amazon Reviews Dataset
  • Use Case: Sentiment classification for customer feedback, reviews, etc.
  • Input Format: Plain text (string)
  • Output: Dictionary with class ID, label, and class probabilities

License

This model is licensed under the MIT License. You are free to use, modify, and distribute it with attribution.

Author

Developed and Trained by Dilip Pokhrel

Downloads last month
5
Safetensors
Model size
34.6M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Dataset used to train dilip025/RoBERTa-mini