codealchemist01 commited on
Commit
dda1843
·
verified ·
1 Parent(s): 6b19f26

Upload folder using huggingface_hub

Browse files
__init__.py ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ # Model module
2
+
config.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "BertForSequenceClassification"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "classifier_dropout": null,
7
+ "dtype": "float32",
8
+ "hidden_act": "gelu",
9
+ "hidden_dropout_prob": 0.1,
10
+ "hidden_size": 768,
11
+ "id2label": {
12
+ "0": "negative",
13
+ "1": "neutral",
14
+ "2": "positive"
15
+ },
16
+ "initializer_range": 0.02,
17
+ "intermediate_size": 3072,
18
+ "label2id": {
19
+ "negative": 0,
20
+ "neutral": 1,
21
+ "positive": 2
22
+ },
23
+ "layer_norm_eps": 1e-12,
24
+ "max_position_embeddings": 512,
25
+ "model_type": "bert",
26
+ "num_attention_heads": 12,
27
+ "num_hidden_layers": 12,
28
+ "pad_token_id": 0,
29
+ "position_embedding_type": "absolute",
30
+ "problem_type": "single_label_classification",
31
+ "transformers_version": "4.57.0",
32
+ "type_vocab_size": 2,
33
+ "use_cache": true,
34
+ "vocab_size": 32000
35
+ }
confusion_matrix.png ADDED
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:905110c097ddeeda0a8b5136f91e5f8e2a2278cd9765e9eaa38feda658649203
3
+ size 442502140
model_card.md ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: tr
3
+ tags:
4
+ - sentiment-analysis
5
+ - turkish
6
+ - bert
7
+ - text-classification
8
+ license: apache-2.0
9
+ datasets:
10
+ - winvoker/turkish-sentiment-analysis-dataset
11
+ - WhiteAngelss/Turkce-Duygu-Analizi-Dataset
12
+ metrics:
13
+ - accuracy
14
+ - f1
15
+ - precision
16
+ - recall
17
+ ---
18
+
19
+ # Turkish Sentiment Analysis Model
20
+
21
+ A fine-tuned BERT model for Turkish sentiment analysis, trained on a combined dataset of 439,384 labeled Turkish sentences.
22
+
23
+ ## Model Details
24
+
25
+ - **Base Model:** `dbmdz/bert-base-turkish-cased`
26
+ - **Task:** Text Classification (Sentiment Analysis)
27
+ - **Language:** Turkish
28
+ - **Labels:** positive, negative, neutral
29
+
30
+ ## Training Data
31
+
32
+ The model was trained on a combination of two high-quality Turkish sentiment datasets:
33
+ - `winvoker/turkish-sentiment-analysis-dataset` (440,641 samples)
34
+ - `WhiteAngelss/Turkce-Duygu-Analizi-Dataset` (440,641 samples)
35
+
36
+ After deduplication and preprocessing, the final training set consisted of:
37
+ - **Training:** 351,507 samples
38
+ - **Validation:** 43,938 samples
39
+ - **Test:** 43,939 samples
40
+
41
+ ### Label Distribution
42
+
43
+ - **Positive:** 234,957 (53.5%)
44
+ - **Neutral:** 153,809 (35.0%)
45
+ - **Negative:** 50,618 (11.5%)
46
+
47
+ ## Training
48
+
49
+ - **Epochs:** 3
50
+ - **Learning Rate:** 2e-5
51
+ - **Batch Size:** 16
52
+ - **Max Length:** 128
53
+ - **Optimizer:** AdamW
54
+
55
+ ## Usage
56
+
57
+ ```python
58
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
59
+ import torch
60
+
61
+ # Load model and tokenizer
62
+ model_name = "codealchemist01/turkish-sentiment-analysis"
63
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
64
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
65
+
66
+ # Example text
67
+ text = "Bu ürün gerçekten harika!"
68
+
69
+ # Tokenize
70
+ inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)
71
+
72
+ # Predict
73
+ with torch.no_grad():
74
+ outputs = model(**inputs)
75
+ predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
76
+ predicted_label_id = predictions.argmax().item()
77
+
78
+ # Map to label
79
+ id2label = {0: "negative", 1: "neutral", 2: "positive"}
80
+ predicted_label = id2label[predicted_label_id]
81
+ confidence = predictions[0][predicted_label_id].item()
82
+
83
+ print(f"Label: {predicted_label}")
84
+ print(f"Confidence: {confidence:.4f}")
85
+ ```
86
+
87
+ ## Performance
88
+
89
+ Evaluation metrics on the test set (43,939 samples):
90
+
91
+ - **Accuracy:** 97.45%
92
+ - **Weighted F1:** 97.42%
93
+ - **Weighted Precision:** 97.41%
94
+ - **Weighted Recall:** 97.45%
95
+
96
+ ### Per-Class Performance
97
+
98
+ | Class | Precision | Recall | F1-Score | Support |
99
+ |----------|-----------|--------|----------|---------|
100
+ | Negative | 91.42% | 86.69% | 88.99% | 5,062 |
101
+ | Neutral | 99.79% | 99.96% | 99.87% | 15,381 |
102
+ | Positive | 97.15% | 98.12% | 97.63% | 23,496 |
103
+
104
+ **Note:** Negative class has lower performance due to class imbalance (only 11.5% of the dataset). The model performs excellently on neutral and positive classes.
105
+
106
+ ## Limitations
107
+
108
+ - The model may not perform well on very short texts (< 3 words)
109
+ - Performance may vary across different domains (social media, news, reviews)
110
+ - Class imbalance may affect performance on minority classes (negative)
111
+
112
+ ## Citation
113
+
114
+ If you use this model, please cite:
115
+
116
+ ```bibtex
117
+ @misc{turkish-sentiment-analysis,
118
+ title={Turkish Sentiment Analysis Model},
119
+ author={codealchemist01},
120
+ year={2024},
121
+ howpublished={\url{https://huggingface.co/codealchemist01/turkish-sentiment-analysis}}
122
+ }
123
+ ```
124
+
125
+ ## License
126
+
127
+ Apache 2.0
128
+
special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "3": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "4": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "clean_up_tokenization_spaces": true,
45
+ "cls_token": "[CLS]",
46
+ "do_basic_tokenize": true,
47
+ "do_lower_case": false,
48
+ "extra_special_tokens": {},
49
+ "mask_token": "[MASK]",
50
+ "max_len": 512,
51
+ "model_max_length": 512,
52
+ "never_split": null,
53
+ "pad_token": "[PAD]",
54
+ "sep_token": "[SEP]",
55
+ "strip_accents": null,
56
+ "tokenize_chinese_chars": true,
57
+ "tokenizer_class": "BertTokenizer",
58
+ "unk_token": "[UNK]"
59
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0bd94595c3e7c9cafde146967d7aed03066abdb040f116da8a9c805f0161d4e7
3
+ size 5777
vocab.txt ADDED
The diff for this file is too large to render. See raw diff