Update README.md
Browse files
README.md
CHANGED
@@ -1,199 +1,84 @@
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
-
|
|
|
4 |
---
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
- **
|
21 |
-
-
|
22 |
-
-
|
23 |
-
-
|
24 |
-
|
25 |
-
|
26 |
-
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
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 |
-
<!-- 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 |
-
[More Information Needed]
|
188 |
-
|
189 |
-
## More Information [optional]
|
190 |
-
|
191 |
-
[More Information Needed]
|
192 |
-
|
193 |
-
## Model Card Authors [optional]
|
194 |
-
|
195 |
-
[More Information Needed]
|
196 |
-
|
197 |
-
## Model Card Contact
|
198 |
-
|
199 |
-
[More Information Needed]
|
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
+
base_model:
|
4 |
+
- monologg/kobert
|
5 |
---
|
6 |
+
# KoBERT κΈ°λ° νκ΅μ΄ κ°μ λΆλ₯ λͺ¨λΈ
|
7 |
+
|
8 |
+
μ΄ νλ‘μ νΈλ **νκ΅μ΄ ν
μ€νΈμ κ°μ μ λΆλ₯**νλ KoBERT κΈ°λ°μ κ°μ λΆλ₯ λͺ¨λΈμ νμ΅νκ³ νμ©νλ μ½λλ₯Ό ν¬ν¨ν©λλ€. μ΄ λͺ¨λΈμ μ
λ ₯λ ν
μ€νΈκ° **λΆλ
Έ(Anger), λλ €μ(Fear), κΈ°μ¨(Happy), νμ¨(Tender), μ¬ν(Sad)** μ€ μ΄λ€ κ°μ μ ν΄λΉνλμ§λ₯Ό μμΈ‘ν©λλ€.
|
9 |
+
|
10 |
+
## 1. λͺ¨λΈ νμ΅ κ³Όμ
|
11 |
+
|
12 |
+
### Colab νκ²½ μ€μ λ° λ°μ΄ν° μ€λΉ
|
13 |
+
1. **νμ λΌμ΄λΈλ¬λ¦¬ μ€μΉ**:
|
14 |
+
`transformers`, `datasets`, `torch`, `pandas`, `scikit-learn` λΌμ΄λΈλ¬λ¦¬λ₯Ό μ€μΉν©λλ€.
|
15 |
+
|
16 |
+
2. **λ°μ΄ν° λΆλ¬μ€κΈ°**:
|
17 |
+
ai hub μ λ±λ‘λ νκ΅μ΄ κ°μ± λν λ°μ΄ν°λ‘λΆν° κ°μ λΆλ₯μ© CSV νμΌμ λΆλ¬μ΅λλ€.
|
18 |
+
|
19 |
+
3. **λ°μ΄ν°μ
μ€λΉ**:
|
20 |
+
- **νμ΅/κ²μ¦ λ°μ΄ν° λΆν **: 80%λ νμ΅ λ°μ΄ν°λ‘, 20%λ κ²μ¦ λ°μ΄ν°λ‘ μ¬μ©.
|
21 |
+
- **HuggingFace Dataset νμ λ³ν**: Pandas DataFrameμ HuggingFace `Dataset`μΌλ‘ λ³ν.
|
22 |
+
- **λ μ΄λΈ 컬λΌλͺ
λ³κ²½**: κ°μ λ μ΄λΈμ λνλ΄λ `label_int` 컬λΌμ `labels`λ‘ λ³κ²½.
|
23 |
+
- **λ°μ΄ν° ν ν°ν**: `monologg/kobert` ν ν¬λμ΄μ λ₯Ό μ΄μ©ν΄ μ
λ ₯ ν
μ€νΈλ₯Ό ν ν°ν.
|
24 |
+
- **νμ λ³ν**: `input_ids`, `attention_mask`, `labels`λ§ λ¨κ²¨ νμ΅ μ€λΉ μλ£.
|
25 |
+
|
26 |
+
4. **λͺ¨λΈ λ° νμ΅ μ€μ **:
|
27 |
+
- **λͺ¨λΈ**: `monologg/kobert` λͺ¨λΈμ λΆλ¬μ 5κ°μ κ°μ λ μ΄λΈμ λΆλ₯νλλ‘ μ€μ .
|
28 |
+
- **νμ΅ νμ΄νΌνλΌλ―Έν°**:
|
29 |
+
- `learning_rate=2e-5`, `num_train_epochs=10`, `batch_size=16`.
|
30 |
+
- F1 μ€μ½μ΄λ₯Ό κΈ°λ°μΌλ‘ λ² μ€νΈ λͺ¨λΈ μ μ₯.
|
31 |
+
- Early stopping μ μ©.
|
32 |
+
|
33 |
+
5. **νμ΅ μ§ν λ° λͺ¨λΈ μ μ₯**:
|
34 |
+
- νμ΅ μλ£ ν λͺ¨λΈμ Google Driveμ μ μ₯.
|
35 |
+
|
36 |
+
### μ±λ₯ νκ° λ° ν
μ€νΈ
|
37 |
+
- **νκ° μ§ν**: Accuracy, F1 score (macro, weighted) κ³μ°.
|
38 |
+
- **ν
μ€νΈ λ°μ΄ν° νκ°**: νμ΅λ λͺ¨λΈμ μ΄μ©ν΄ ν
μ€νΈ λ°μ΄ν°μ
νκ°.
|
39 |
+
|
40 |
+
## 2. λͺ¨λΈ μ¬μ© λ°©λ²
|
41 |
+
|
42 |
+
### μ¬μ μ€λΉ
|
43 |
+
- HuggingFace Hubμμ νμ΅λ λͺ¨λΈμ λΆλ¬μ μ¬μ©ν μ μμ΅λλ€.
|
44 |
+
- λͺ¨λΈ λ° ν ν¬λμ΄μ λ `monologg/kobert` κΈ°λ°μ΄λ©°, λΆλ₯ λ μ΄λΈμ λ€μκ³Ό κ°μ΅λλ€:
|
45 |
+
- **Anger**: π‘
|
46 |
+
- **Fear**: π¨
|
47 |
+
- **Happy**: π
|
48 |
+
- **Tender**: π₯°
|
49 |
+
- **Sad**: π’
|
50 |
+
|
51 |
+
### μ¬μ© μμ
|
52 |
+
1. **λ¨μ λ¬Έμ₯ μ
λ ₯ κ°μ λΆμ**:
|
53 |
+
- μ¬μ©μκ° μ
λ ₯ν ν
μ€νΈμ λν΄ λͺ¨λΈμ΄ κ°μ μ μμΈ‘νκ³ , κ° κ°μ μ νλ₯ μ ν¨κ» μΆλ ₯ν©λλ€.
|
54 |
+
|
55 |
+
2. **μμ
νμΌμμ κ°μ λΆμ**:
|
56 |
+
- μμ
νμΌμμ μ§μ ν ν
μ€νΈ μ΄κ³Ό ν λ²μλ₯Ό μ½μ΄μ, ν΄λΉ ν
μ€νΈλ€μ λν΄ κ°μ μ λΆλ₯νκ³ κ²°κ³Όλ₯Ό μΆλ ₯ν©λλ€.
|
57 |
+
|
58 |
+
### μ½λ μ¬μ© μμ
|
59 |
+
```python
|
60 |
+
# ν ν¬λμ΄μ λ° λͺ¨λΈ λ‘λ
|
61 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
62 |
+
|
63 |
+
# KoBERT ν ν¬λμ΄μ μ λͺ¨λΈ λ‘λ
|
64 |
+
tokenizer = AutoTokenizer.from_pretrained("monologg/kobert", trust_remote_code=True)
|
65 |
+
model = AutoModelForSequenceClassification.from_pretrained("rkdaldus/ko-sent5-classification")
|
66 |
+
|
67 |
+
# μ¬μ©μ μ
λ ₯ ν
μ€νΈ κ°μ λΆμ
|
68 |
+
text = "μ€λ μ λ§ ν볡ν΄!"
|
69 |
+
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
|
70 |
+
with torch.no_grad():
|
71 |
+
outputs = model(**inputs)
|
72 |
+
predicted_label = torch.argmax(outputs.logits, dim=1).item()
|
73 |
+
|
74 |
+
# κ°μ λ μ΄λΈ μ μ
|
75 |
+
emotion_labels = {
|
76 |
+
0: ("Angry", "π‘"),
|
77 |
+
1: ("Fear", "π¨"),
|
78 |
+
2: ("Happy", "π"),
|
79 |
+
3: ("Tender", "π₯°"),
|
80 |
+
4: ("Sad", "π’")
|
81 |
+
}
|
82 |
+
|
83 |
+
# μμΈ‘λ κ°μ μΆλ ₯
|
84 |
+
print(f"μμΈ‘λ κ°μ : {emotion_labels[predicted_label][0]} {emotion_labels[predicted_label][1]}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|