adding rreadme
Browse files
README.md
CHANGED
@@ -1,199 +1,167 @@
|
|
1 |
-
|
2 |
-
library_name: transformers
|
3 |
-
tags: []
|
4 |
-
---
|
5 |
-
|
6 |
-
# Model Card for Model ID
|
7 |
-
|
8 |
-
<!-- Provide a quick summary of what the model is/does. -->
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
## Model Details
|
13 |
-
|
14 |
-
### Model Description
|
15 |
-
|
16 |
-
<!-- Provide a longer summary of what this model is. -->
|
17 |
-
|
18 |
-
This is the model card of a ๐ค transformers model that has been pushed on the Hub. This model card has been automatically generated.
|
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 |
-
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
43 |
-
|
44 |
-
[More Information Needed]
|
45 |
-
|
46 |
-
### Downstream Use [optional]
|
47 |
-
|
48 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
49 |
-
|
50 |
-
[More Information Needed]
|
51 |
-
|
52 |
-
### Out-of-Scope Use
|
53 |
-
|
54 |
-
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
55 |
-
|
56 |
-
[More Information Needed]
|
57 |
-
|
58 |
-
## Bias, Risks, and Limitations
|
59 |
-
|
60 |
-
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
61 |
-
|
62 |
-
[More Information Needed]
|
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 |
-
|
|
|
|
|
71 |
|
72 |
-
|
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 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
100 |
-
|
101 |
-
[More Information Needed]
|
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 |
-
|
118 |
|
119 |
-
[
|
120 |
|
121 |
-
|
122 |
|
123 |
-
|
124 |
|
125 |
-
|
126 |
|
127 |
-
|
|
|
|
|
128 |
|
129 |
-
|
|
|
130 |
|
131 |
-
|
|
|
|
|
|
|
|
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
|
171 |
-
|
172 |
|
173 |
-
|
174 |
|
175 |
-
|
|
|
|
|
176 |
|
177 |
-
|
|
|
|
|
178 |
|
179 |
-
|
|
|
|
|
|
|
180 |
|
181 |
-
|
|
|
182 |
|
183 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
|
185 |
-
|
186 |
|
187 |
-
|
188 |
|
189 |
-
|
190 |
|
191 |
-
|
192 |
|
193 |
-
##
|
194 |
|
195 |
-
|
|
|
|
|
|
|
196 |
|
197 |
-
|
198 |
|
199 |
-
|
|
|
1 |
+
You're absolutely right โ label flipping is **critical** here since the base model you fine-tuned uses a **non-standard label mapping** (`0 = Positive`, `2 = Negative`). Here's the **updated and corrected** model card with:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
+
* ๐ Clear warning about label flipping
|
4 |
+
* ๐งช Updated usage code with correct interpretation
|
5 |
+
* โ
Rewritten explanation for clarity
|
6 |
|
7 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
+
# ๐ฎ๐ฉ Fine-Tuned IndoRoBERTa for Indonesian Financial Sentiment Classification
|
10 |
|
11 |
+
This is a fine-tuned version of [`w11wo/indonesian-roberta-base-sentiment-classifier`](https://huggingface.co/w11wo/indonesian-roberta-base-sentiment-classifier), specialized for **Indonesian financial news sentiment classification**.
|
12 |
|
13 |
+
---
|
14 |
|
15 |
+
## ๐ง Model Objective
|
16 |
|
17 |
+
This model classifies Indonesian financial news articles into:
|
18 |
|
19 |
+
* `0` โ **Positive**
|
20 |
+
* `1` โ **Neutral**
|
21 |
+
* `2` โ **Negative**
|
22 |
|
23 |
+
โ ๏ธ **Important: Label Mapping is Flipped**
|
24 |
+
This label order follows the base model's unexpected configuration. During training and evaluation, the dataset was relabeled accordingly.
|
25 |
|
26 |
+
> โ ๏ธ Always interpret model output using this mapping:
|
27 |
+
>
|
28 |
+
> * `0`: Positive
|
29 |
+
> * `1`: Neutral
|
30 |
+
> * `2`: Negative
|
31 |
|
32 |
+
---
|
33 |
|
34 |
+
## ๐ Dataset & Preprocessing Pipeline
|
35 |
|
36 |
+
### ๐น Source Dataset
|
37 |
|
38 |
+
* [`intanm/indonesian-financial-sentiment-analysis`](https://huggingface.co/datasets/intanm/indonesian-financial-sentiment-analysis)
|
39 |
+
* Labeled financial news (imbalanced and limited)
|
40 |
|
41 |
+
### ๐ Data Augmentation & Balancing
|
42 |
|
43 |
+
#### 1. ๐งช Gemini Synthetic Generation
|
44 |
|
45 |
+
* Generated structured financial news samples using `gemini-2.0-flash-lite`
|
46 |
+
* Targeted generation for underrepresented classes
|
47 |
|
48 |
+
#### 2. โ๏ธ GPT-2 Prompt Completion
|
49 |
|
50 |
+
* Used [`indonesian-nlp/gpt2-medium-indonesian`](https://huggingface.co/indonesian-nlp/gpt2-medium-indonesian)
|
51 |
+
* Prompt templates varied and strictly separated between train/test sets
|
|
|
|
|
|
|
52 |
|
53 |
+
#### 3. ๐งฉ Roberta-Based Masked Augmentation
|
54 |
|
55 |
+
* Strategic masking/filling while protecting key financial terms
|
56 |
+
* Iterative masking to increase diversity and context coverage
|
57 |
|
58 |
+
#### ๐ Final Label Distribution
|
59 |
|
60 |
+
**Train Set**:
|
61 |
|
62 |
+
```
|
63 |
+
2 (Negative): 22906
|
64 |
+
1 (Neutral): 23374
|
65 |
+
0 (Positive): 23423
|
66 |
+
```
|
67 |
|
68 |
+
**Test Set**:
|
69 |
|
70 |
+
```
|
71 |
+
2 (Negative): 9817
|
72 |
+
1 (Neutral): 10018
|
73 |
+
0 (Positive): 10039
|
74 |
+
```
|
75 |
|
76 |
+
---
|
77 |
|
78 |
+
## ๐๏ธ Training Details
|
79 |
+
|
80 |
+
### ๐ Label Flipping
|
81 |
+
|
82 |
+
> The base model uses **non-standard labels**:
|
83 |
+
>
|
84 |
+
> * `0`: Positive
|
85 |
+
> * `1`: Neutral
|
86 |
+
> * `2`: Negative
|
87 |
+
>
|
88 |
+
> Training data was relabeled accordingly.
|
89 |
+
|
90 |
+
### ๐ง TrainingArguments
|
91 |
+
|
92 |
+
```python
|
93 |
+
TrainingArguments(
|
94 |
+
output_dir="./results-roberta",
|
95 |
+
eval_strategy="epoch",
|
96 |
+
save_strategy="epoch",
|
97 |
+
logging_strategy="epoch",
|
98 |
+
per_device_train_batch_size=256,
|
99 |
+
per_device_eval_batch_size=256,
|
100 |
+
num_train_epochs=15,
|
101 |
+
learning_rate=2e-5,
|
102 |
+
weight_decay=0.01,
|
103 |
+
load_best_model_at_end=True,
|
104 |
+
metric_for_best_model="accuracy",
|
105 |
+
save_total_limit=4,
|
106 |
+
)
|
107 |
+
```
|
108 |
+
|
109 |
+
* Early stopping (`patience=2`)
|
110 |
+
* Training completed at **epoch 5**, best model from **epoch 3**
|
111 |
+
|
112 |
+
### โ
Evaluation Results
|
113 |
+
|
114 |
+
```
|
115 |
+
eval_accuracy = 0.9749
|
116 |
+
eval_precision = 0.9749
|
117 |
+
eval_recall = 0.9749
|
118 |
+
eval_f1 = 0.9749
|
119 |
+
```
|
120 |
|
121 |
+
---
|
122 |
|
123 |
+
## ๐ Usage
|
124 |
|
125 |
+
```python
|
126 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
127 |
+
import torch
|
128 |
|
129 |
+
# Load model and tokenizer
|
130 |
+
model = AutoModelForSequenceClassification.from_pretrained("ihsan31415/finetuned-indo-roBERTa-financial-sentiment")
|
131 |
+
tokenizer = AutoTokenizer.from_pretrained("ihsan31415/finetuned-indo-roBERTa-financial-sentiment")
|
132 |
|
133 |
+
# Example input
|
134 |
+
text = "IHSG diprediksi melemah karena sentimen global negatif"
|
135 |
+
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
|
136 |
+
outputs = model(**inputs)
|
137 |
|
138 |
+
# Get predicted class
|
139 |
+
predicted_label = torch.argmax(outputs.logits, dim=1).item()
|
140 |
|
141 |
+
# Interpret using flipped label mapping
|
142 |
+
label_map = {
|
143 |
+
0: "Positive",
|
144 |
+
1: "Neutral",
|
145 |
+
2: "Negative"
|
146 |
+
}
|
147 |
+
print(f"Predicted sentiment: {label_map[predicted_label]}")
|
148 |
+
```
|
149 |
|
150 |
+
---
|
151 |
|
152 |
+
## ๐ Citation
|
153 |
|
154 |
+
If you use this model in your research or application, please cite or link to this model card.
|
155 |
|
156 |
+
---
|
157 |
|
158 |
+
## ๐ฌ Contact
|
159 |
|
160 |
+
Created by
|
161 |
+
[`ihsan31415`](https://huggingface.co/ihsan31415)
|
162 |
+
[`ihsan31415`](https://github.com/ihsan31415)
|
163 |
+
[`Khoirul Ihsan`](https://www.linkedin.com/in/khoirul-ihsan-387115288/)
|
164 |
|
165 |
+
For collaborations or questions, feel free to reach out via Hugging Face or GitHub.
|
166 |
|
167 |
+
---
|