Update README.md
Browse files
README.md
CHANGED
@@ -1,202 +1,133 @@
|
|
1 |
---
|
2 |
base_model: google/gemma-2-2b-it
|
3 |
library_name: peft
|
|
|
|
|
|
|
|
|
|
|
4 |
---
|
5 |
|
6 |
-
# Model Card for
|
7 |
|
8 |
-
|
9 |
|
|
|
10 |
|
|
|
11 |
|
12 |
## Model Details
|
13 |
|
14 |
-
###
|
|
|
15 |
|
16 |
-
|
|
|
17 |
|
|
|
|
|
18 |
|
|
|
|
|
19 |
|
20 |
-
|
21 |
-
- **
|
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 |
-
###
|
|
|
|
|
|
|
|
|
29 |
|
30 |
-
|
31 |
|
32 |
-
|
33 |
-
-
|
34 |
-
- **Demo [optional]:** [More Information Needed]
|
35 |
|
36 |
-
|
|
|
37 |
|
38 |
-
|
|
|
|
|
39 |
|
40 |
-
|
41 |
|
42 |
-
|
|
|
43 |
|
44 |
-
|
|
|
|
|
45 |
|
46 |
-
|
|
|
47 |
|
48 |
-
|
|
|
49 |
|
50 |
-
[
|
|
|
|
|
51 |
|
52 |
-
|
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 |
-
## 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 |
-
###
|
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 |
-
|
|
|
|
|
89 |
|
90 |
-
|
|
|
91 |
|
|
|
92 |
|
93 |
-
|
94 |
-
|
95 |
-
- **
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
|
|
102 |
|
103 |
## Evaluation
|
104 |
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
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 |
-
## Model Examination [optional]
|
136 |
-
|
137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
138 |
-
|
139 |
-
[More Information Needed]
|
140 |
-
|
141 |
-
## Environmental Impact
|
142 |
-
|
143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
144 |
-
|
145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
146 |
-
|
147 |
-
- **Hardware Type:** [More Information Needed]
|
148 |
-
- **Hours used:** [More Information Needed]
|
149 |
-
- **Cloud Provider:** [More Information Needed]
|
150 |
-
- **Compute Region:** [More Information Needed]
|
151 |
-
- **Carbon Emitted:** [More Information Needed]
|
152 |
-
|
153 |
-
## Technical Specifications [optional]
|
154 |
-
|
155 |
-
### Model Architecture and Objective
|
156 |
-
|
157 |
-
[More Information Needed]
|
158 |
-
|
159 |
-
### Compute Infrastructure
|
160 |
-
|
161 |
-
[More Information Needed]
|
162 |
-
|
163 |
-
#### Hardware
|
164 |
-
|
165 |
-
[More Information Needed]
|
166 |
-
|
167 |
-
#### Software
|
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 |
-
|
200 |
-
|
|
|
|
|
201 |
|
202 |
-
|
|
|
|
|
|
1 |
---
|
2 |
base_model: google/gemma-2-2b-it
|
3 |
library_name: peft
|
4 |
+
tags:
|
5 |
+
- sentiment-analysis
|
6 |
+
- weighted-loss
|
7 |
+
- LoRA
|
8 |
+
- Korean
|
9 |
---
|
10 |
|
11 |
+
# Model Card for Fine-Tuned `gemma-2-2b-it` on Custom Korean Sentiment Dataset
|
12 |
|
13 |
+
## Model Summary
|
14 |
|
15 |
+
This model is a fine-tuned version of `google/gemma-2-2b-it`, trained to classify sentiment in Korean text into four categories: **무감정** (neutral), **슬픔** (sadness), **기쁨** (joy), and **분노** (anger). The model utilizes **LoRA (Low-Rank Adaptation)** for efficient fine-tuning and **4-bit quantization (NF4)** for memory efficiency using **BitsAndBytes**. A custom weighted loss function was applied to handle class imbalance within the dataset.
|
16 |
|
17 |
+
The model is suitable for multi-class sentiment classification in Korean and is optimized for environments with limited computational resources due to the quantization.
|
18 |
|
19 |
## Model Details
|
20 |
|
21 |
+
### Developed By:
|
22 |
+
This model was fine-tuned by [Your Name or Organization] using Hugging Face's `peft` and `transformers` libraries with a custom Korean sentiment dataset.
|
23 |
|
24 |
+
### Model Type:
|
25 |
+
This is a transformer-based model for **multi-class sentiment classification** in the Korean language.
|
26 |
|
27 |
+
### Language:
|
28 |
+
- **Language(s)**: Korean
|
29 |
|
30 |
+
### License:
|
31 |
+
[Add relevant license here]
|
32 |
|
33 |
+
### Finetuned From:
|
34 |
+
- **Base Model**: `google/gemma-2-2b-it`
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
+
### Framework Versions:
|
37 |
+
- **Transformers**: 4.44.2
|
38 |
+
- **PEFT**: 0.12.0
|
39 |
+
- **Datasets**: 3.0.1
|
40 |
+
- **PyTorch**: 2.4.1+cu121
|
41 |
|
42 |
+
## Intended Uses & Limitations
|
43 |
|
44 |
+
### Intended Use:
|
45 |
+
This model is suitable for applications requiring multi-class sentiment classification in Korean, such as chatbots, social media monitoring, or customer feedback analysis.
|
|
|
46 |
|
47 |
+
### Out-of-Scope Use:
|
48 |
+
The model may not perform optimally for tasks requiring multi-language support, sentiment classification with additional classes, or outside the specific context of Korean language data.
|
49 |
|
50 |
+
### Limitations:
|
51 |
+
- **Bias**: As the model is trained on a custom dataset, it may reflect specific biases inherent in that data.
|
52 |
+
- **Generalization**: Performance may vary when applied to datasets outside the scope of the initial training data, such as other forms of sentiment classification.
|
53 |
|
54 |
+
## Model Architecture
|
55 |
|
56 |
+
### Quantization:
|
57 |
+
The model uses **4-bit quantization** via **BitsAndBytes** for efficient memory usage, which enables it to run on lower-resource hardware.
|
58 |
|
59 |
+
### LoRA Configuration:
|
60 |
+
LoRA (Low-Rank Adaptation) was applied to specific transformer layers, allowing for parameter-efficient fine-tuning. The target modules include:
|
61 |
+
- `down_proj`, `gate_proj`, `q_proj`, `o_proj`, `up_proj`, `v_proj`, `k_proj`
|
62 |
|
63 |
+
LoRA parameters are:
|
64 |
+
- `r = 16`, `lora_alpha = 32`, `lora_dropout = 0.05`
|
65 |
|
66 |
+
### Custom Weighted Loss:
|
67 |
+
A custom weighted loss function was implemented to handle class imbalance, using the following weights:
|
68 |
|
69 |
+
\[
|
70 |
+
\text{weights} = [0.2032, 0.2704, 0.2529, 0.2735]
|
71 |
+
\]
|
72 |
|
73 |
+
These weights correspond to the classes: **무감정**, **슬픔**, **기쁨**, **분노**, respectively.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
## Training Details
|
76 |
|
77 |
+
### Dataset:
|
78 |
+
The model was trained on a custom Korean sentiment analysis dataset. This dataset consists of text samples labeled with one of four sentiment classes: **무감정**, **슬픔**, **기쁨**, and **분노**.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
+
- **Train Set Size**: Custom dataset
|
81 |
+
- **Test Set Size**: Custom dataset
|
82 |
+
- **Classes**: 4 (무감정, 슬픔, 기쁨, 분노)
|
83 |
|
84 |
+
### Preprocessing:
|
85 |
+
Data was tokenized using the `google/gemma-2-2b-it` tokenizer with a maximum sequence length of 128. The preprocessing steps included padding and truncation to ensure consistent input lengths.
|
86 |
|
87 |
+
### Hyperparameters:
|
88 |
|
89 |
+
- **Learning Rate**: 2e-4
|
90 |
+
- **Batch Size (train)**: 8
|
91 |
+
- **Batch Size (eval)**: 8
|
92 |
+
- **Epochs**: 4
|
93 |
+
- **Optimizer**: AdamW (with 8-bit optimization)
|
94 |
+
- **Weight Decay**: 0.01
|
95 |
+
- **Gradient Accumulation Steps**: 2
|
96 |
+
- **Evaluation Steps**: 500
|
97 |
+
- **Logging Steps**: 500
|
98 |
+
- **Metric for Best Model**: F1 (weighted)
|
99 |
|
100 |
## Evaluation
|
101 |
|
102 |
+
### Metrics:
|
103 |
+
The model was evaluated using the following metrics:
|
104 |
+
- **Accuracy**
|
105 |
+
- **F1 Score** (weighted)
|
106 |
+
- **Precision** (weighted)
|
107 |
+
- **Recall** (weighted)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
|
109 |
+
The evaluation provides a detailed view of the model's performance across multiple metrics, which helps in understanding its strengths and areas for improvement.
|
110 |
|
111 |
+
### Code Example:
|
112 |
|
113 |
+
You can load the fine-tuned model and use it for inference on your own data as follows:
|
114 |
|
115 |
+
```python
|
116 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
117 |
|
118 |
+
# Load model and tokenizer
|
119 |
+
model = AutoModelForSequenceClassification.from_pretrained("your-model-directory")
|
120 |
+
tokenizer = AutoTokenizer.from_pretrained("your-model-directory")
|
121 |
|
122 |
+
# Tokenize input text
|
123 |
+
text = "이 영화는 정말 슬퍼요."
|
124 |
+
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
|
125 |
|
126 |
+
# Get predictions
|
127 |
+
outputs = model(**inputs)
|
128 |
+
logits = outputs.logits
|
129 |
+
predicted_class = logits.argmax(-1).item()
|
130 |
|
131 |
+
# Map prediction to label
|
132 |
+
id2label = {0: "무감정", 1: "슬픔", 2: "기쁨", 3: "분노"}
|
133 |
+
print(f"Predicted sentiment: {id2label[predicted_class]}")
|