Model Description
This model performs sentiment analysis on YouTube comments, classifying each comment into one of the following categories:
-Negative → 0
-Neutral → 1
-Positive → 2
It is built on RoBERTa-base, a transformer model pretrained on large-scale web text,
and fine-tuned on labeled YouTube comments to better capture social-media-style language,
including informal expressions and emojis.
- Developed by: Imane Azzamok
- Model type: Text Classification (Sentiment Analysis)
- Language(s) (NLP): English
- License: Apache 2.0
- Finetuned from model : cardiffnlp/twitter-roberta-base-sentiment
Uses
Direct Use
The model can be used directly to analyze sentiment in YouTube comments or similar short social media texts.
Example usage:
[from transformers import pipeline
classifier = pipeline(
"sentiment-analysis",
model="ImaneAz/youtube-roberta-sentiment"
)
classifier("This video was amazing, I learned a lot!")
]
Downstream Use [optional]
- YouTube analytics dashboards
- Social media monitoring tools
- Opinion mining pipelines
- Topic-based sentiment aggregation (used alongside topic modeling)
Out-of-Scope Use
- Not intended for non-English text
- Not suitable for clinical, legal, or high-stakes decision-making
- Sarcasm and emojis are partially handled due to RoBERTa pretraining, but complex sarcasm or cultural context may still be misinterpreted
Bias, Risks, and Limitations
- The model may reflect biases present in online YouTube comments
- Performance can vary across topics, slang, and emerging expressions
- Predictions are probabilistic and should not be interpreted as absolute truth
Recommendations
- Prefer aggregated sentiment analysis over individual predictions
- Combine sentiment outputs with topic modeling or metadata for deeper insights
- Periodically re-evaluate the model on newly collected data
Training Details
Training Data
- Primary dataset:
Kaggle – YouTube Comments Sentiment Dataset (English, labeled)
- Deployment alignment:
Designed to be applied to YouTube comments collected via the YouTube API and stored in MongoDB
Training Procedure
- Tokenization using the RoBERTa tokenizer
- Fine-tuning with the Hugging Face Trainer API
- Optimization using cross-entropy loss for multi-class classification
Training Hyperparameters
| Parameter | Value |
|---|
| Base model | RoBERTa-base |
| Epochs | 2 |
| Learning rate | 2e-5 |
| Batch size | 32 |
| Optimizer | AdamW |
| Precision | fp32 |
Evaluation
Metrics
The model was evaluated on a held-out test set of 10,000 YouTube comments using standard classification metrics.
| Metric / Class | Precision | Recall | F1-score | Support |
|---|
| Negative | 0.75 | 0.80 | 0.77 | 3,332 |
| Neutral | 0.72 | 0.69 | 0.70 | 3,318 |
| Positive | 0.81 | 0.79 | 0.80 | 3,350 |
| Accuracy | — | — | 0.76 | 10,000 |
| Macro Avg | 0.76 | 0.76 | 0.76 | 10,000 |
| Weighted Avg | 0.76 | 0.76 | 0.76 | 10,000 |
Confusion Matrix Summary
- Strong separation between Positive and Negative classes
- Most confusion occurs between Neutral and sentiment-bearing classes, which is expected in real-world comments
🔎 Example Predictions
Below are example predictions generated by the model during inference:
Input:
"I really liked this video, it was very informative and entertaining!"
Output:
- Label: Positive
- Confidence score: 0.998
Input:
"This is a terrible product, I regret buying it."
Output:
- Label: Negative
- Confidence score: 0.995
Summary
This model is a RoBERTa-based sentiment analysis system fine-tuned on labeled YouTube comments.
It classifies comments into Negative, Neutral, or Positive sentiment and is designed to handle informal social media language, including emojis and short expressions.
The model is suitable for YouTube analytics, opinion mining, and dashboard-based sentiment monitoring, and can be easily deployed using the Hugging Face pipeline API.