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}

}

```