LimYeri's picture
Update README.md
ca54b7c verified
---
library_name: transformers
tags:
- text-regression
- emotion-regression
- sentiment-regression
- ko
- korean
- koelectra
- emotion-analysis
- nlp
license: mit
language:
- ko
base_model:
- monologg/koelectra-base-v3-discriminator
---
# HowRU-KoELECTRA-Emotion-Regression
## Model Description
KoELECTRA ๊ธฐ๋ฐ˜์˜ ํ•œ๊ตญ์–ด(ํŠนํžˆ ์ผ๊ธฐ/์‹ฌ๋ฆฌ ๊ธฐ๋ก) ๊ฐ์ • ์Šค์ฝ”์–ด๋ง(Regression) ๋ชจ๋ธ์ž…๋‹ˆ๋‹ค.<br>
ํ…์ŠคํŠธ ์† ๊ฐ์ •์˜ *๊ฐ•๋„์™€ ๋ฐฉํ–ฅ์„ฑ(๊ธ์ • โ†” ๋ถ€์ •)* ์„ **โ€“1.0 ~ 1.0 ์‹ค์ˆ˜๊ฐ’**์œผ๋กœ ์˜ˆ์ธกํ•ฉ๋‹ˆ๋‹ค.
- **Model type:** Regression (Emotion Intensity / Sentiment Strength)
- **Output Range:** -1.0 ~ 1.0
- **Language:** Korean (ํ•œ๊ตญ์–ด, ko)
- **License:** MIT
- **Finetuned from model:** [monologg/koelectra-base-v3-discriminator](https://huggingface.co/monologg/koelectra-base-v3-discriminator)
---
## Emotion Score Interpretation
๋ชจ๋ธ์€ ์ž…๋ ฅ๋œ ํ•œ๊ตญ์–ด ๋ฌธ์žฅ์˜ ๊ฐ์ • ๊ฐ•๋„๋ฅผ ์•„๋ž˜ ๋ฒ”์œ„ ์ค‘ ํ•˜๋‚˜๋กœ ์‚ฐ์ถœํ•ฉ๋‹ˆ๋‹ค.
| Score Range | Meaning |
|------------------|---------------------------------|
| **+0.6 ~ +1.0** | ๊ฐ•ํ•œ ๊ธ์ • ๊ฐ์ • |
| **+0.2 ~ +0.6** | ์•ฝํ•œ ๊ธ์ • ๊ฐ์ • |
| **-0.2 ~ +0.2** | ์ค‘๋ฆฝ ๋˜๋Š” ๊ฐ์ • ํ‘œํ˜„์ด ๋ฏธ์•ฝ |
| **-0.6 ~ -0.2** | ์•ฝํ•œ ๋ถ€์ • ๊ฐ์ • |
| **-1.0 ~ -0.6** | ๊ฐ•ํ•œ ๋ถ€์ • ๊ฐ์ • |
---
## How to Get Started with the Model
```python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
MODEL_NAME = "LimYeri/HowRU-KoELECTRA-Emotion-Regression"
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
model = AutoModelForSequenceClassification.from_pretrained(MODEL_NAME)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model.to(device)
model.eval()
def predict_score(text: str):
"""
Returns:
- emotion_score: ๊ฐ์ • ๊ฐ•๋„ (-1.0 ~ 1.0)
"""
inputs = tokenizer(
text,
return_tensors="pt",
truncation=True,
padding=True,
max_length=512
).to(device)
with torch.no_grad():
outputs = model(**inputs).logits
score = outputs.item()
return {"text": text, "emotion_score": score}
# Example
result = predict_score("์˜ค๋Š˜์€ ์ •๋ง ์ฆ๊ฒ๊ณ  ํ–‰๋ณตํ•œ ์ตœ๊ณ ์˜ ํ•˜๋ฃจ์˜€์–ด!")
print(result)
```
### pipeline
```python
from transformers import pipeline
MODEL_NAME = "LimYeri/HowRU-KoELECTRA-Emotion-Regression"
regressor = pipeline(
"text-classification", # Regression๋„ ๋™์ผ Task๋กœ ๋™์ž‘
model=MODEL_NAME,
tokenizer=MODEL_NAME,
function_to_apply="none" # Softmax ์ œ๊ฑฐ โ†’ raw value ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉ
)
text = "์˜ค๋Š˜์€ ์ •๋ง ์ฆ๊ฒ๊ณ  ํ–‰๋ณตํ•œ ์ตœ๊ณ ์˜ ํ•˜๋ฃจ์˜€์–ด!"
result = regressor(text)[0]
print("์ž…๋ ฅ ๋ฌธ์žฅ:", text)
print("๊ฐ์ • ์Šค์ฝ”์–ด:", result["score"])
```
---
## Training Details
### Training Data
- **Total(9:1๋กœ ๋ถ„ํ• ):** 42,000ํ–‰
- **Train:** 37,800ํ–‰
- **Validation:** 4,200ํ–‰
### Training Procedure
- **Base Model**: [monologg/koelectra-base-v3-discriminator](https://huggingface.co/monologg/koelectra-base-v3-discriminator)
- **Max Length**: 512
### Training Hyperparameters
- **num_train_epochs**: 4
- **learning_rate**: 1.8e-5
- **weight_decay**: 0.01
- **warmup_ratio**: 0.12
- **per_device_train_batch_size**: 32
- **per_device_eval_batch_size**: 32
- **loss_function**: Huber Loss (ฮด = 1.0)
---
## Performance
| Metric | Score |
|---------------------------|------------|
| **Eval MAE** | **0.0461** |
| **Eval Pearson Correlation** | **0.9951** |
| **Eval Loss** | **0.00199** |
---
## Model Architecture
### 1) ELECTRA Encoder (Base-size)
- **Hidden size:** 768
- **Layers:** 12 Transformer blocks
- **Attention heads:** 12
- **MLP intermediate size:** 3072
- **Activation:** GELU
- **Dropout:** 0.1
### 2) Classification Head
๊ฐ์ • ๊ฐ•๋„(โ€“1.0 ~ 1.0)๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ๋‹จ์ผ ํšŒ๊ท€ ํ—ค๋“œ:
- **Dense Layer**: 768 โ†’ 768
- **Activation**: GELU
- **Dropout**: 0.1
- **Output Projection**: 768 โ†’ 1
์ตœ์ข… ์ถœ๋ ฅ ๊ฐ’์€ Softmax ์—†์ด **logits ๊ทธ๋Œ€๋กœ** ์‚ฌ์šฉํ•˜๋ฉฐ,
โ€“1.0 ~ 1.0 ๋ฒ”์œ„ ๊ฐ์ • ๊ฐ•๋„๋กœ ํ•ด์„๋ฉ๋‹ˆ๋‹ค.
---
## Citation
```bibtex
@misc{HowRUEmotionRegression2025,
title={HowRU KoELECTRA Emotion Regression},
author={Lim, Yeri},
year={2025},
publisher={Hugging Face},
howpublished={\url{https://huggingface.co/LimYeri/HowRU-KoELECTRA-Emotion-Regression}}
}
```