Update README.md
Browse files
README.md
CHANGED
@@ -1,199 +1,165 @@
|
|
1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
library_name: transformers
|
3 |
-
tags: []
|
4 |
---
|
5 |
|
6 |
# Model Card for Model ID
|
7 |
|
8 |
-
|
9 |
-
|
10 |
|
|
|
11 |
|
12 |
## Model Details
|
13 |
|
14 |
### Model Description
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
- **Developed by:** [More Information Needed]
|
21 |
-
- **Funded by [optional]:** [More Information Needed]
|
22 |
-
- **Shared by [optional]:** [More Information Needed]
|
23 |
-
- **Model type:** [More Information Needed]
|
24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
25 |
-
- **License:** [More Information Needed]
|
26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
-
|
28 |
-
### Model Sources [optional]
|
29 |
-
|
30 |
-
<!-- Provide the basic links for the model. -->
|
31 |
-
|
32 |
-
- **Repository:** [More Information Needed]
|
33 |
-
- **Paper [optional]:** [More Information Needed]
|
34 |
-
- **Demo [optional]:** [More Information Needed]
|
35 |
|
36 |
## Uses
|
37 |
|
38 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
39 |
-
|
40 |
### Direct Use
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
[More Information Needed]
|
45 |
|
46 |
### Downstream Use [optional]
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
|
52 |
### Out-of-Scope Use
|
53 |
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
## Bias, Risks, and Limitations
|
59 |
-
|
60 |
-
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
61 |
|
62 |
-
|
63 |
-
|
64 |
-
### Recommendations
|
65 |
-
|
66 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
67 |
-
|
68 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
69 |
|
70 |
## How to Get Started with the Model
|
71 |
|
72 |
Use the code below to get started with the model.
|
73 |
|
74 |
-
[More Information Needed]
|
75 |
-
|
76 |
-
## Training Details
|
77 |
-
|
78 |
-
### Training Data
|
79 |
-
|
80 |
-
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
81 |
-
|
82 |
-
[More Information Needed]
|
83 |
-
|
84 |
-
### Training Procedure
|
85 |
-
|
86 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
87 |
-
|
88 |
-
#### Preprocessing [optional]
|
89 |
-
|
90 |
-
[More Information Needed]
|
91 |
-
|
92 |
-
|
93 |
-
#### Training Hyperparameters
|
94 |
-
|
95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
96 |
-
|
97 |
-
#### Speeds, Sizes, Times [optional]
|
98 |
|
99 |
-
|
|
|
100 |
|
101 |
-
|
102 |
-
|
103 |
-
## Evaluation
|
104 |
-
|
105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
106 |
-
|
107 |
-
### Testing Data, Factors & Metrics
|
108 |
-
|
109 |
-
#### Testing Data
|
110 |
-
|
111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
112 |
-
|
113 |
-
[More Information Needed]
|
114 |
-
|
115 |
-
#### Factors
|
116 |
-
|
117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
118 |
-
|
119 |
-
[More Information Needed]
|
120 |
-
|
121 |
-
#### Metrics
|
122 |
-
|
123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
124 |
-
|
125 |
-
[More Information Needed]
|
126 |
-
|
127 |
-
### Results
|
128 |
-
|
129 |
-
[More Information Needed]
|
130 |
-
|
131 |
-
#### Summary
|
132 |
|
|
|
133 |
|
|
|
134 |
|
135 |
-
|
136 |
|
137 |
-
|
138 |
|
139 |
-
|
140 |
|
141 |
-
|
|
|
|
|
142 |
|
143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
|
145 |
-
|
146 |
|
147 |
-
|
148 |
-
|
149 |
-
- **Cloud Provider:** [More Information Needed]
|
150 |
-
- **Compute Region:** [More Information Needed]
|
151 |
-
- **Carbon Emitted:** [More Information Needed]
|
152 |
|
153 |
-
|
|
|
|
|
154 |
|
155 |
-
|
|
|
156 |
|
157 |
-
|
|
|
158 |
|
159 |
-
|
|
|
|
|
160 |
|
161 |
-
|
|
|
|
|
162 |
|
163 |
-
|
|
|
|
|
164 |
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
[More Information Needed]
|
170 |
-
|
171 |
-
## Citation [optional]
|
172 |
-
|
173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
174 |
-
|
175 |
-
**BibTeX:**
|
176 |
-
|
177 |
-
[More Information Needed]
|
178 |
-
|
179 |
-
**APA:**
|
180 |
-
|
181 |
-
[More Information Needed]
|
182 |
-
|
183 |
-
## Glossary [optional]
|
184 |
-
|
185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
186 |
|
187 |
-
|
|
|
188 |
|
189 |
-
|
|
|
|
|
|
|
|
|
|
|
190 |
|
191 |
-
|
192 |
|
193 |
-
|
194 |
|
195 |
-
|
|
|
|
|
196 |
|
197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
|
199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
license: mit
|
3 |
+
language:
|
4 |
+
- tr
|
5 |
+
base_model:
|
6 |
+
- dbmdz/bert-base-turkish-cased
|
7 |
+
pipeline_tag: text-classification
|
8 |
library_name: transformers
|
|
|
9 |
---
|
10 |
|
11 |
# Model Card for Model ID
|
12 |
|
13 |
+
yeniguno/absa-turkish-bert-dbmdz
|
|
|
14 |
|
15 |
+
This model is fine-tuned to detect sentiment in Turkish text with respect to specific aspects. It has been designed for the ABSA task, where the model receives both an aspect (span) and a text and predicts the sentiment towards the aspect.
|
16 |
|
17 |
## Model Details
|
18 |
|
19 |
### Model Description
|
20 |
|
21 |
+
- **Base Model**: `dbmdz/bert-base-turkish-cased`
|
22 |
+
- **Fine-tuning Task**: Aspect-Based Sentiment Analysis (ABSA) for Turkish text.
|
23 |
+
- **Language**: Turkish
|
24 |
+
- **Labels**: Sentiment classification (`positive`, `neutral`, `negative`)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
## Uses
|
27 |
|
|
|
|
|
28 |
### Direct Use
|
29 |
|
30 |
+
- **ABSA**: This model is used for Aspect-Based Sentiment Analysis in Turkish, where users can provide a text along with a specific aspect, and the model will predict the sentiment (positive, neutral, or negative) towards that aspect.
|
|
|
|
|
31 |
|
32 |
### Downstream Use [optional]
|
33 |
|
34 |
+
- This model can be used in downstream applications such as:
|
35 |
+
- **Brand Monitoring**: Analyze customer feedback or social media mentions to determine sentiment towards specific brands.
|
36 |
+
- **Marketing Analysis**: Understand how consumers feel about specific brands in product reviews or survey responses.
|
37 |
|
38 |
### Out-of-Scope Use
|
39 |
|
40 |
+
- **General Sentiment Analysis**: The model is fine-tuned specifically for brand names as aspects and may not generalize well to other aspects or tasks.
|
41 |
+
- **Other Languages**: The model is trained only on Turkish data and will likely perform poorly on other languages without additional fine-tuning.
|
42 |
+
- **Non-brand related aspects**: The model is specialized for brand-related sentiments and may not perform well on aspects outside of brand names.
|
|
|
|
|
|
|
|
|
43 |
|
44 |
+
## Recommendations
|
45 |
+
Users should be aware of the model’s limitations and biases, especially in sensitive applications like brand reputation management. Additional validation may be necessary for specific use cases to ensure fairness and accuracy.
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
## How to Get Started with the Model
|
48 |
|
49 |
Use the code below to get started with the model.
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
+
```python
|
53 |
+
from transformers import pipeline
|
54 |
|
55 |
+
pipe = pipeline("text-classification", model="yeniguno/absa-turkish-bert-dbmdz")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
+
text = "Sony'nin ses sistemleri tam anlamıyla harika, her ayrıntıyı net bir şekilde duyabiliyorum ve tasarımı da oldukça şık."
|
58 |
|
59 |
+
response = pipe(text, text_pair="Sony")
|
60 |
|
61 |
+
print(response)
|
62 |
|
63 |
+
# [{'label': 'LABEL_2', 'score': 0.9998026490211487}]
|
64 |
|
65 |
+
text = "Apple'ın tabletleri çok kullanışlı ve uzun ömürlü, ancak kulaklıklarının dayanıklılığı hayal kırıklığı yaratıyor."
|
66 |
|
67 |
+
response = pipe(text, text_pair="tablet")
|
68 |
+
print(response)
|
69 |
+
# [{'label': 'LABEL_2', 'score': 0.9978420734405518}]
|
70 |
|
71 |
+
response = pipe(text, text_pair="kulaklık")
|
72 |
+
print(response)
|
73 |
+
# [{'label': 'LABEL_0', 'score': 0.9996157884597778}]
|
74 |
+
```
|
75 |
+
```python
|
76 |
+
import torch
|
77 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
78 |
|
79 |
+
model_name = "yeniguno/absa-turkish-bert-dbmdz"
|
80 |
|
81 |
+
text = "Samsung'un televizyonları mükemmel bir görüntü kalitesine sahip."
|
82 |
+
span = "televizyon"
|
|
|
|
|
|
|
83 |
|
84 |
+
# Load the tokenizer and model
|
85 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
86 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
87 |
|
88 |
+
# Tokenize the text and the aspect (span)
|
89 |
+
inputs = tokenizer(span, text, truncation=True, padding='max_length', max_length=128, return_tensors="pt")
|
90 |
|
91 |
+
# Put model in evaluation mode
|
92 |
+
model.eval()
|
93 |
|
94 |
+
# Get the model output (predictions)
|
95 |
+
with torch.no_grad():
|
96 |
+
outputs = model(**inputs)
|
97 |
|
98 |
+
# Get the predicted label
|
99 |
+
logits = outputs.logits
|
100 |
+
predicted_class_id = torch.argmax(logits, dim=-1).item()
|
101 |
|
102 |
+
# Map the prediction back to the label
|
103 |
+
id_to_label = {0: "negative", 1: "neutral", 2: "positive"}
|
104 |
+
predicted_label = id_to_label[predicted_class_id]
|
105 |
|
106 |
+
print(f"Predicted sentiment: {predicted_label}")
|
107 |
+
# Predicted sentiment: positive
|
108 |
+
```
|
109 |
+
## Training Details
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
|
111 |
+
### Training Data
|
112 |
+
The training data used for fine-tuning this model consists of a mix of several datasets that were adapted to the Turkish language for Aspect-Based Sentiment Analysis (ABSA). The datasets include:
|
113 |
|
114 |
+
- `alexcadillon/SemEval2014Task4`
|
115 |
+
- `PNLPhub/Pars-ABSA`
|
116 |
+
- `STNM-NLPhoenix/turkish-absa`
|
117 |
+
- `Alpaca69B reviews datasets`
|
118 |
+
- `pahri/setfit-absa-indo-restaurantmix`
|
119 |
+
- `ABSA-QUAD-master`
|
120 |
|
121 |
+
In total, the training data includes 231,753 instances, while the test data consists of 57,905 instances. Non-Turkish examples from the original datasets were translated and arranged to be compatible with Turkish language processing, ensuring consistency in the aspect-based sentiment analysis task.
|
122 |
|
123 |
+
### Training Procedure
|
124 |
|
125 |
+
#### Preprocessing
|
126 |
+
- **Text Tokenization**: The text data was tokenized using the BERT tokenizer (`dbmdz/bert-base-turkish-cased`), with padding and truncation applied to a maximum length of 128 tokens.
|
127 |
+
- **Label Mapping**: The sentiment labels were mapped to integers: `0` for negative, `1` for neutral, and `2` for positive.
|
128 |
|
129 |
+
#### Training Hyperparameters
|
130 |
+
- **Epochs**: 3-5
|
131 |
+
- **Batch Size**: 16
|
132 |
+
- **Learning Rate**: 2e-5
|
133 |
+
- **Optimizer**: AdamW
|
134 |
+
- **Warmup Steps**: 10% of training steps
|
135 |
+
- **Weight Decay**: 0.01
|
136 |
+
|
137 |
+
## Evaluation
|
138 |
|
139 |
+
### Testing Data
|
140 |
+
The model was evaluated on a subset of the Turkish ABSA dataset, which includes 57,905 instances, focusing on brand-related sentiment analysis. The evaluation was conducted over three epochs, with accuracy and F1-scores being tracked to assess performance improvements during training.
|
141 |
+
|
142 |
+
### Metrics
|
143 |
+
|
144 |
+
#### Epoch 1:
|
145 |
+
- **Average Training Loss**: 0.3848
|
146 |
+
- **Evaluation Accuracy**: 0.9013
|
147 |
+
- **Evaluation F1-score**: 0.9012
|
148 |
+
- **New Best Model Saved**
|
149 |
+
|
150 |
+
#### Epoch 2:
|
151 |
+
- **Average Training Loss**: 0.2030
|
152 |
+
- **Evaluation Accuracy**: 0.9264
|
153 |
+
- **Evaluation F1-score**: 0.9262
|
154 |
+
- **New Best Model Saved**
|
155 |
+
|
156 |
+
#### Epoch 3:
|
157 |
+
- **Average Training Loss**: 0.1183
|
158 |
+
- **Evaluation Accuracy**: 0.9376
|
159 |
+
- **Evaluation F1-score**: 0.9372
|
160 |
+
- **New Best Model Saved**
|
161 |
+
|
162 |
+
### Final Classification Report:
|
163 |
+
- **Accuracy**: 0.9376
|
164 |
+
- **Macro F1-score**: 0.9314
|
165 |
+
- **Weighted F1-score**: 0.9372
|