difficulty_klue / README.md
combe4259's picture
Update README.md
2951393 verified
---
language: ko
license: apache-2.0
base_model: klue/bert-base
tags:
- klue-bert
- text-classification
- pytorch
- ko
- financial-domain
- text-difficulty
datasets:
- custom
metrics:
- f1
- accuracy
- mae
---
## Colab Notebook
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/112GWo0LrRls5B_uF6ghjZXzY6PxXzrnV?usp=sharing)
## ν•™μŠ΅ 데이터셋
https://huggingface.co/combe4259/difficulty_klue/blob/main/training_data_difficulty_klue.json
# 금육 λ¬Έμ„œ λ‚œμ΄λ„ λΆ„λ₯˜ λͺ¨λΈ (Text Difficulty Classification)
이 λͺ¨λΈμ€ `klue/bert-base`λ₯Ό νŒŒμΈνŠœλ‹ν•˜μ—¬, ν•œκ΅­μ–΄ 금육 λ¬Έμž₯의 λ‚œμ΄λ„λ₯Ό 10단계(1~10)둜 λΆ„λ₯˜ν•˜λŠ” Text Classification λͺ¨λΈμž…λ‹ˆλ‹€.
'μ–΄λ €μš΄ λ¬Έμž₯'이 λ“±μž₯ν–ˆλŠ”μ§€ μ‹€μ‹œκ°„μœΌλ‘œ κ°μ§€ν•˜μ—¬ 'μ‰¬μš΄ λ¬Έμž₯ λ³€ν™˜ AI'의 트리거 역할을 ν•˜λ„λ‘ μ„€κ³„λ˜μ—ˆμŠ΅λ‹ˆλ‹€.
---
## μ‚¬μš© 방법 (How to Use)
```python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
# Hugging Face Hub λ˜λŠ” μ €μž₯된 둜컬 κ²½λ‘œμ—μ„œ λͺ¨λΈ λ‘œλ“œ
MODEL_PATH = "combe4259/difficulty_klue"
tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
model = AutoModelForSequenceClassification.from_pretrained(MODEL_PATH)
model.eval()
# μΆ”λ‘ ν•  ν…μŠ€νŠΈ
text = "μ‹ μš©νŒŒμƒκ²°ν•©μ¦κΆŒμ˜ CDS μŠ€ν”„λ ˆλ“œ 변동에 λ”°λ₯Έ 수읡ꡬ쑰"
inputs = tokenizer(
text,
return_tensors="pt",
truncation=True,
max_length=512,
padding=True
)
# 예츑
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
# λͺ¨λΈμ€ 0-9둜 μ˜ˆμΈ‘ν•˜λ―€λ‘œ, +1 ν•˜μ—¬ 1-10 μŠ€μΌ€μΌλ‘œ λ³€ν™˜
prediction = torch.argmax(logits, dim=-1).item()
difficulty = prediction + 1
print(f"ν…μŠ€νŠΈ: {text}")
print(f"예츑 λ‚œμ΄λ„: {difficulty}")
# 좜λ ₯: 예츑 λ‚œμ΄λ„: 7
```
## ν•™μŠ΅ 데이터 (Training Data)
- 자체 κ΅¬μΆ•ν•œ 2,880개의 금육 λ¬Έμž₯/λ‹¨λ½μœΌλ‘œ κ΅¬μ„±λœ JSON 데이터 μ‚¬μš©
- 데이터 λΆ„ν• : Train (2,016) / Validation (432) / Test (432)
- 데이터 λΆˆκ· ν˜•: λ‚œμ΄λ„ 7(28.2%)κ³Ό 8(18.6%) 집쀑, λ‚œμ΄λ„ 10(0.0%)은 1개 쑴재
- μ „μ²˜λ¦¬: klue/bert-base ν† ν¬λ‚˜μ΄μ € μ‚¬μš©, `max_length=512`둜 νŒ¨λ”© 및 μ ˆλ‹¨
---
## ν•™μŠ΅ 절차 (Training Procedure)
- Base Model: `klue/bert-base` (`num_labels=10`)
- Optimizer: AdamW
- Loss Function: Weighted CrossEntropyLoss (클래슀 κ°€μ€‘μΉ˜ 적용)
- 예: μƒ˜ν”Œ 1개인 λ‚œμ΄λ„ 10 β†’ 10.0
- μƒ˜ν”Œ 568개인 λ‚œμ΄λ„ 7 β†’ 0.35
- Epochs: 10
- Batch Size: 16
- Learning Rate: 2e-5 (with 500 warmup steps)
- Best Model: `metric_for_best_model='f1'` (F1 μ μˆ˜κ°€ κ°€μž₯ 높은 체크포인트 μ €μž₯)
- Early Stopping: patience=3 (F1 μ μˆ˜κ°€ 3회 연속 κ°œμ„ λ˜μ§€ μ•ŠμœΌλ©΄ ν•™μŠ΅ μ‘°κΈ° μ’…λ£Œ)
---
## 평가 κ²°κ³Ό (Evaluation Results)
Test Set (432개) κΈ°μ€€ μ΅œμ’… μ„±λŠ₯μž…λ‹ˆλ‹€.
'F1 Score'와 'MAE, Within 1 Acc' λͺ¨λ‘μ—μ„œ μ•ˆμ •μ μΈ μ„±λŠ₯을 λ³΄μ˜€μŠ΅λ‹ˆλ‹€.
| Metric | Score | μ„€λͺ… |
|-----------------------|-------|------|
| F1 Score (Weighted) | 0.607 | (핡심 μ§€ν‘œ) λͺ¨λΈμ˜ μ „λ°˜μ μΈ 정밀도/μž¬ν˜„μœ¨ |
| Accuracy (정확도) | 0.604 | 10개 쀑 μ •ν™•νžˆ 맞힐 ν™•λ₯  |
| MAE (평균 μ ˆλŒ€ 였차) | 0.560 | (μ€‘μš”) 예츑이 μ •λ‹΅μ—μ„œ 평균 0.56μΉΈ 벗어남 |
| Within 1 Acc | 0.926 | (μ€‘μš”) Β±1 였차 λ²”μœ„ λ‚΄ 정확도 (92.6%) |
---
## μƒ˜ν”Œ 예츑
| μž…λ ₯ ν…μŠ€νŠΈ | 예츑 λ‚œμ΄λ„ (1-10) |
|-------------|-------------------|
| "은행에 λˆμ„ λ§‘κ²¨μš”" | 1 |
| "μ˜ˆκΈˆμžλ³΄ν˜Έλ²•μ— 따라 5μ²œλ§Œμ›κΉŒμ§€ λ³΄ν˜Έλ©λ‹ˆλ‹€" | 2 |
| "μ‹ μš©νŒŒμƒκ²°ν•©μ¦κΆŒμ˜ CDS μŠ€ν”„λ ˆλ“œ 변동에 λ”°λ₯Έ 수읡ꡬ쑰" | 7 |