File size: 2,920 Bytes
77c48bc | 1 2 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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | ---
language: ko
license: mit
tags:
- pytorch
- bert
- text-classification
- stance-detection
- korean
- news
datasets:
- custom
metrics:
- accuracy
model-index:
- name: political-news-stance-classifier
results:
- task:
type: text-classification
name: Stance Classification
metrics:
- type: accuracy
value: 91.6
name: Test Accuracy
---
# Korean News Stance Classifier (ํ๊ตญ์ด ๋ด์ค ์คํ ์ค ๋ถ๋ฅ๊ธฐ)
KoBERT ๊ธฐ๋ฐ ํ๊ตญ์ด ์ ์น ๋ด์ค ์คํ ์ค(์
์ฅ) ๋ถ๋ฅ ๋ชจ๋ธ์
๋๋ค.
## Model Description
- **Base Model**: skt/kobert-base-v1
- **Tokenizer**: monologg/kobert (์ค์!)
- **Task**: 3-class stance classification (์นํธ/์ค๋ฆฝ/๋นํ)
- **Language**: Korean
## Performance
- **Test Accuracy**: 91.6%
- **Validation Accuracy**: 93.9%
- **Training Samples**: 5253
## Labels
| Label | Korean | English | Description |
|-------|--------|---------|-------------|
| 0 | ์นํธ | support | ์ ๋ถ/์ฌ๋น ์ ์ฑ
์ ์ฐํธ์ |
| 1 | ์ค๋ฆฝ | neutral | ๊ฐ๊ด์ ์ฌ์ค ์ ๋ฌ |
| 2 | ๋นํ | oppose | ์ ๋ถ/์ฌ๋น ์ ์ฑ
์ ๋นํ์ |
## Usage
```python
import torch
from transformers import AutoTokenizer
# ํ ํฌ๋์ด์ ๋ก๋ (๋ฐ๋์ monologg/kobert ์ฌ์ฉ!)
tokenizer = AutoTokenizer.from_pretrained("monologg/kobert", trust_remote_code=True)
# ๋ชจ๋ธ ๋ก๋
model = torch.load("pytorch_model.bin")
# ๋๋ state_dict ๋ก๋
# model.load_state_dict(torch.load("model.pth"))
# ์์ธก
text = "์ ๋ถ์ ์ ์ ์ฑ
์ด ๊ฒฝ์ ์ฑ์ฅ์ ํฌ๊ฒ ๊ธฐ์ฌํ ๊ฒ์ผ๋ก ๊ธฐ๋๋๋ค"
inputs = tokenizer(text, return_tensors="pt", max_length=512, truncation=True, padding="max_length")
with torch.no_grad():
outputs = model(inputs["input_ids"], inputs["attention_mask"])
probs = torch.softmax(outputs, dim=1)
pred = torch.argmax(probs, dim=1).item()
labels = ["์นํธ", "์ค๋ฆฝ", "๋นํ"]
print(f"Predicted: {labels[pred]} ({probs[0][pred].item()*100:.1f}%)")
```
## Important Notes
**ํ ํฌ๋์ด์ ์ฃผ์์ฌํญ**: ์ด ๋ชจ๋ธ์ `monologg/kobert` ํ ํฌ๋์ด์ ๋ก ํ์ต๋์์ต๋๋ค.
๋ฐ๋์ ๋์ผํ ํ ํฌ๋์ด์ ๋ฅผ ์ฌ์ฉํด์ผ ์ ํํ ๊ฒฐ๊ณผ๋ฅผ ์ป์ ์ ์์ต๋๋ค.
```python
# ์ฌ๋ฐ๋ฅธ ์ฌ์ฉ๋ฒ
tokenizer = AutoTokenizer.from_pretrained("monologg/kobert", trust_remote_code=True)
# ์๋ชป๋ ์ฌ์ฉ๋ฒ (๊ฒฐ๊ณผ๊ฐ ๋ถ์ ํํจ)
# tokenizer = AutoTokenizer.from_pretrained("skt/kobert-base-v1")
```
## Training Details
- **Epochs**: 16
- **Batch Size**: 16
- **Learning Rate**: 2e-05
- **Max Length**: 512
- **Dropout**: 0.3
## Citation
If you use this model, please cite:
```bibtex
@misc{korean-news-stance-classifier,
title={Korean News Stance Classifier},
author={Politics News Analysis Team},
year={2024},
publisher={HuggingFace}
}
```
|