Update README.md
Browse files
README.md
CHANGED
|
@@ -1,111 +1,116 @@
|
|
| 1 |
-
---
|
| 2 |
-
language: en
|
| 3 |
-
tags:
|
| 4 |
-
- text-classification
|
| 5 |
-
- sentiment-analysis
|
| 6 |
-
- transformers
|
| 7 |
-
- pytorch
|
| 8 |
-
- multilingual
|
| 9 |
-
- xlm-roberta
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
- **
|
| 27 |
-
- **
|
| 28 |
-
- **
|
| 29 |
-
- **
|
| 30 |
-
- **
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
- **
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
- "
|
| 71 |
-
- "
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
- **
|
| 80 |
-
- **
|
| 81 |
-
- **
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
-
|
| 89 |
-
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
}
|
| 111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
tags:
|
| 4 |
+
- text-classification
|
| 5 |
+
- sentiment-analysis
|
| 6 |
+
- transformers
|
| 7 |
+
- pytorch
|
| 8 |
+
- multilingual
|
| 9 |
+
- xlm-roberta
|
| 10 |
+
- Siyovush Mirzoev
|
| 11 |
+
- Tajik
|
| 12 |
+
- Tajikistan
|
| 13 |
+
license: mit
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# advexon/multilingual-sentiment-classifier
|
| 17 |
+
|
| 18 |
+
Multilingual text classification model trained on XLM-RoBERTa base for sentiment analysis across English, Russian, Tajik and other languages
|
| 19 |
+
|
| 20 |
+
## Model Description
|
| 21 |
+
|
| 22 |
+
This is a multilingual text classification model based on XLM-RoBERTa. It has been fine-tuned for sentiment analysis across multiple languages and can classify text into positive, negative, and neutral categories.
|
| 23 |
+
|
| 24 |
+
## Model Details
|
| 25 |
+
|
| 26 |
+
- **Base Model**: XLM-RoBERTa Base
|
| 27 |
+
- **Model Type**: XLMRobertaForSequenceClassification
|
| 28 |
+
- **Number of Labels**: 3 (Negative, Neutral, Positive)
|
| 29 |
+
- **Languages**: Multilingual (English, Russian, Tajik, and others)
|
| 30 |
+
- **Max Sequence Length**: 512 tokens
|
| 31 |
+
- **Hidden Size**: 768
|
| 32 |
+
- **Attention Heads**: 12
|
| 33 |
+
- **Layers**: 12
|
| 34 |
+
|
| 35 |
+
## Performance
|
| 36 |
+
|
| 37 |
+
Based on training metrics:
|
| 38 |
+
- **Training Accuracy**: 58.33%
|
| 39 |
+
- **Validation Accuracy**: 100%
|
| 40 |
+
- **Training Loss**: 0.94
|
| 41 |
+
- **Validation Loss**: 0.79
|
| 42 |
+
|
| 43 |
+
## Usage
|
| 44 |
+
|
| 45 |
+
### Using the Model
|
| 46 |
+
|
| 47 |
+
```python
|
| 48 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 49 |
+
import torch
|
| 50 |
+
|
| 51 |
+
# Load the model and tokenizer
|
| 52 |
+
tokenizer = AutoTokenizer.from_pretrained("advexon/multilingual-sentiment-classifier")
|
| 53 |
+
model = AutoModelForSequenceClassification.from_pretrained("advexon/multilingual-sentiment-classifier")
|
| 54 |
+
|
| 55 |
+
# Example usage
|
| 56 |
+
text = "This product is amazing!"
|
| 57 |
+
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
|
| 58 |
+
outputs = model(**inputs)
|
| 59 |
+
predictions = torch.softmax(outputs.logits, dim=-1)
|
| 60 |
+
predicted_class = torch.argmax(predictions, dim=1).item()
|
| 61 |
+
|
| 62 |
+
# Class mapping: 0=Negative, 1=Neutral, 2=Positive
|
| 63 |
+
sentiment_labels = ["Negative", "Neutral", "Positive"]
|
| 64 |
+
predicted_sentiment = sentiment_labels[predicted_class]
|
| 65 |
+
print(f"Predicted sentiment: {predicted_sentiment}")
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
### Example Predictions
|
| 69 |
+
|
| 70 |
+
- "I absolutely love this product!" → Positive
|
| 71 |
+
- "This is terrible quality." → Negative
|
| 72 |
+
- "It's okay, nothing special." → Neutral
|
| 73 |
+
- "Отличный сервис!" → Positive (Russian)
|
| 74 |
+
- "Хунуки хуб нест" → Negative (Tajik)
|
| 75 |
+
|
| 76 |
+
## Training
|
| 77 |
+
|
| 78 |
+
This model was trained using:
|
| 79 |
+
- **Base Model**: XLM-RoBERTa Base
|
| 80 |
+
- **Optimizer**: AdamW
|
| 81 |
+
- **Learning Rate**: 2e-5
|
| 82 |
+
- **Batch Size**: 16
|
| 83 |
+
- **Training Epochs**: 2
|
| 84 |
+
- **Languages**: English, Russian, Tajik
|
| 85 |
+
|
| 86 |
+
## Model Architecture
|
| 87 |
+
|
| 88 |
+
The model uses the XLM-RoBERTa architecture with:
|
| 89 |
+
- 12 transformer layers
|
| 90 |
+
- 768 hidden dimensions
|
| 91 |
+
- 12 attention heads
|
| 92 |
+
- 3 classification heads for sentiment analysis
|
| 93 |
+
|
| 94 |
+
## Limitations
|
| 95 |
+
|
| 96 |
+
- The model's performance may vary across different languages
|
| 97 |
+
- It is recommended to fine-tune on domain-specific data for optimal performance
|
| 98 |
+
- Maximum input length is 512 tokens
|
| 99 |
+
- Performance may be lower on languages not well-represented in the training data
|
| 100 |
+
|
| 101 |
+
## Citation
|
| 102 |
+
|
| 103 |
+
If you use this model in your research, please cite:
|
| 104 |
+
|
| 105 |
+
```bibtex
|
| 106 |
+
@misc{multilingual-text-classifier,
|
| 107 |
+
title={Multilingual Text Classification Model},
|
| 108 |
+
author={Advexon},
|
| 109 |
+
year={2024},
|
| 110 |
+
publisher={Siyovush Mirzoev},
|
| 111 |
+
journal={Hugging Face Hub},
|
| 112 |
+
howpublished={\url{https://huggingface.co/advexon/multilingual-sentiment-classifier}},
|
| 113 |
+
}
|
| 114 |
+
```
|
| 115 |
+
## Contact me
|
| 116 |
+
mirzoevsish@gmail.com / +992 710707777 WhatsApp
|