Downloads · 30 days
8
7% of all-time downloads
gaaahee/political-news-stance-classifier
political-news-stance-classifier is a text classification model from gaaahee. Use it when you need a label for a piece of text. The card lists the license as mit.
Downloads · 30 days
8
7% of all-time downloads
All-time downloads
112
Public
Repo size
738 MB
Likes
0
Public
Click a slice to open those files.
.bin369 MB · 50%
From the Hugging Face model README
KoBERT 기반 한국어 정치 뉴스 스탠스(입장) 분류 모델입니다.
| Label | Korean | English | Description |
|---|---|---|---|
| 0 | 옹호 | support | 정부/여당 정책에 우호적 |
| 1 | 중립 | neutral | 객관적 사실 전달 |
| 2 | 비판 | oppose | 정부/여당 정책에 비판적 |
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}%)")
토크나이저 주의사항: 이 모델은 monologg/kobert 토크나이저로 학습되었습니다.
반드시 동일한 토크나이저를 사용해야 정확한 결과를 얻을 수 있습니다.
# 올바른 사용법
tokenizer = AutoTokenizer.from_pretrained("monologg/kobert", trust_remote_code=True)
# 잘못된 사용법 (결과가 부정확함)
# tokenizer = AutoTokenizer.from_pretrained("skt/kobert-base-v1")
If you use this model, please cite:
@misc{korean-news-stance-classifier,
title={Korean News Stance Classifier},
author={Politics News Analysis Team},
year={2024},
publisher={HuggingFace}
}