Downloads · 30 days
84
4% of all-time downloads
brivil1/lithuanian-sentiment-analysis-DistilBERT
lithuanian-sentiment-analysis-DistilBERT is a text classification model from brivil1. Use it when you need a label for a piece of text. It is set up for bertopic. The card lists the license as apache-2.0.
This repository contains a fine-tuned version of the distilbert/distilbert-base-multilingual-cased model for sentiment analysis classification. It was specifically trained using Lithuanian internet reviews from variou…
Downloads · 30 days
84
4% of all-time downloads
All-time downloads
2.2K
Public
Parameters
135M
541 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors541 MB · 99%
From the Hugging Face model README
This repository contains a fine-tuned version of the distilbert/distilbert-base-multilingual-cased model for sentiment analysis classification. It was specifically trained using Lithuanian internet reviews from various domains as part of a master's degree research project on the topic "Sentiment Analysis of Lithuanian Online Reviews Using Deep Language Models".<br><br> DistilBERT is a smaller, faster, and more efficient version of BERT, retaining 97% of BERT’s language understanding while being 60% faster and 40% smaller. The base DistilBERT model was pre-trained on the Wikipedia dataset across 104 languages, including Lithuanian. The case-sensitive model can differentiate between 'labai nepatiko' and 'LABAI nepatiko'. For more architectural details refer to distilbert/distilbert-base-multilingual-cased model description.
While the fine-tuned DistilBERT model shows promising results in classifying sentiments from Lithuanian reviews, it is important to be aware of potential biases and limitations:
The dataset for fine-tuning the model was collected from three sources:
The reviews were classified into five categories based on a 5-star rating system:
| Model | Accuracy | F1 Score Overall | F1 Scores by Category |
|---|---|---|---|
| DistilBERT | 0.6845 | 0.6751 | 0.7601, 0.3556, 0.4938, 0.4513, 0.8354 |
The model's performance was evaluated using a confusion matrix and various metrics. The table below presents the results for all five sentiment categories:
| True Category | Emotionally Negative | Rationally Negative | Neutral | Rationally Positive | Emotionally Positive |
|---|---|---|---|---|---|
| Emotionally Negative | 2135 (80.74%) | 248 (9.38%) | 197 (7.45%) | 82 (3.10%) | 83 (3.14%) |
| Rationally Negative | 362 (26.32%) | 402 (29.20%) | 232 (16.85%) | 71 (5.15%) | 40 (2.91%) |
| Neutral | 237 (12.76%) | 217 (11.69%) | 984 (53.00%) | 396 (21.31%) | 280 (15.08%) |
| Rationally Positive | 48 (2.63%) | 32 (1.75%) | 299 (16.41%) | 1030 (56.51%) | 978 (53.60%) |
| Emotionally Positive | 71 (1.14%) | 25 (0.40%) | 149 (2.37%) | 590 (9.39%) | 5645 (89.61%) |
The table below presents the results for three sentiment categories:
| True Category | Negative | Neutral | Positive |
|---|---|---|---|
| Negative | 3147 (75.79%) | 429 (10.34%) | 276 (6.65%) |
| Neutral | 454 (14.90%) | 984 (32.18%) | 676 (22.09%) |
| Positive | 217 (2.98%) | 445 (6.11%) | 8243 (91.01%) |
To use the fine-tuned model for sentiment analysis, you can follow the steps below:
from transformers import pipeline, AutoModelForSequenceClassification, AutoTokenizer
# Load the fine-tuned model and tokenizer
model_output_dir = "brivil1/lithuanian-sentiment-analysis-ByT5"
trained_model = AutoModelForSequenceClassification.from_pretrained(model_output_dir)
trained_tokenizer = AutoTokenizer.from_pretrained(model_output_dir)
# Create a sentiment analysis pipeline
sentiment_pipeline = pipeline("text-classification", model=trained_model, tokenizer=trained_tokenizer)
print(sentiment_pipeline("Blogai. ziauru ir nepatiko"))
print(sentiment_pipeline("Labai puiku"))
print(sentiment_pipeline("Nežinau, visai nepatinka"))
Results:
[{'label': 'negative', 'score': 0.9424479007720947}]
[{'label': 'positive', 'score': 0.8821539282798767}]
[{'label': 'neutral', 'score': 0.9761189222335815}]