Add model card with metadata for inference widget
Browse files
README.md
CHANGED
|
@@ -1,12 +1,93 @@
|
|
| 1 |
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
datasets:
|
| 4 |
-
- R3iwan/entertainment-reviews-kazakh
|
| 5 |
language:
|
| 6 |
- kk
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
-
|
|
|
|
|
|
|
|
|
|
| 11 |
pipeline_tag: text-classification
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
| 2 |
language:
|
| 3 |
- kk
|
| 4 |
+
license: apache-2.0
|
| 5 |
+
tags:
|
| 6 |
+
- text-classification
|
| 7 |
+
- sentiment-analysis
|
| 8 |
+
- kazakh
|
| 9 |
+
- bert
|
| 10 |
+
- multilingual
|
| 11 |
pipeline_tag: text-classification
|
| 12 |
+
datasets:
|
| 13 |
+
- R3iwan/entertainment-reviews-kazakh
|
| 14 |
+
base_model: google-bert/bert-base-multilingual-cased
|
| 15 |
+
model-index:
|
| 16 |
+
- name: kazakh-sentiment-bert
|
| 17 |
+
results: []
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
# Kazakh Sentiment Analysis Model
|
| 21 |
+
|
| 22 |
+
A sentiment analysis model for Kazakh text, fine-tuned on a dataset of entertainment reviews.
|
| 23 |
+
|
| 24 |
+
## Model Description
|
| 25 |
+
|
| 26 |
+
This model is based on `bert-base-multilingual-cased` and fine-tuned for sentiment classification of Kazakh text into three classes:
|
| 27 |
+
- **positive** (positive sentiment)
|
| 28 |
+
- **neutral** (neutral sentiment)
|
| 29 |
+
- **negative** (negative sentiment)
|
| 30 |
+
|
| 31 |
+
## Usage
|
| 32 |
+
|
| 33 |
+
### Using transformers pipeline
|
| 34 |
+
|
| 35 |
+
```python
|
| 36 |
+
from transformers import pipeline
|
| 37 |
+
|
| 38 |
+
classifier = pipeline("text-classification", model="R3iwan/kazakh-sentiment-bert")
|
| 39 |
+
|
| 40 |
+
text = "Бұл фильм маған ұнамады"
|
| 41 |
+
result = classifier(text)
|
| 42 |
+
print(result)
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
### Direct model usage
|
| 46 |
+
|
| 47 |
+
```python
|
| 48 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 49 |
+
import torch
|
| 50 |
+
|
| 51 |
+
model_name = "R3iwan/kazakh-sentiment-bert"
|
| 52 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 53 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
| 54 |
+
|
| 55 |
+
text = "Бұл фильм маған ұнамады"
|
| 56 |
+
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
|
| 57 |
+
|
| 58 |
+
with torch.no_grad():
|
| 59 |
+
outputs = model(**inputs)
|
| 60 |
+
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
|
| 61 |
+
|
| 62 |
+
predicted_class = torch.argmax(predictions, dim=-1).item()
|
| 63 |
+
labels = ["negative", "neutral", "positive"]
|
| 64 |
+
print(f"Predicted: {labels[predicted_class]}")
|
| 65 |
+
print(f"Confidence: {predictions[0][predicted_class].item():.2%}")
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
## Training
|
| 69 |
+
|
| 70 |
+
The model was trained on the [R3iwan/entertainment-reviews-kazakh](https://huggingface.co/datasets/R3iwan/entertainment-reviews-kazakh) dataset with the following parameters:
|
| 71 |
+
|
| 72 |
+
- **Base Model**: `bert-base-multilingual-cased`
|
| 73 |
+
- **Epochs**: 2
|
| 74 |
+
- **Batch Size**: 8
|
| 75 |
+
- **Learning Rate**: 2.5e-5 (with linear decay)
|
| 76 |
+
- **Train/Validation/Test Split**: ~80/10/10
|
| 77 |
+
|
| 78 |
+
## Metrics
|
| 79 |
+
|
| 80 |
+
- **Accuracy**: 100% on test set
|
| 81 |
+
- **Task**: Text Classification (Sentiment Analysis)
|
| 82 |
+
|
| 83 |
+
## Limitations
|
| 84 |
+
|
| 85 |
+
The model is trained on a limited dataset of entertainment reviews and may perform better on similar texts. For other domains, additional fine-tuning may be required.
|
| 86 |
+
|
| 87 |
+
## Author
|
| 88 |
+
|
| 89 |
+
R3iwan
|
| 90 |
+
|
| 91 |
+
## License
|
| 92 |
+
|
| 93 |
+
Apache 2.0
|