Downloads · 30 days
62
0% of all-time downloads
jeonghyeon97/koBERT-Senti5
koBERT-Senti5 is a text classification model from jeonghyeon97. Use it when you need a label for a piece of text. It is set up for transformers.
이 모델은 AIHub의 감성대화 말뭉치 데이터셋을 기반으로 한국어 대화의 감정을 분류하는 KoBERT 모델입니다. 원본 데이터셋을 다시 5개의 감정 범주로 레이블링하였으며, Hugging Face의 Trainer 클래스를 사용하여 훈련되었습니다.
Downloads · 30 days
62
0% of all-time downloads
All-time downloads
21.2K
Public
Parameters
92.2M
369 MB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors369 MB · 100%
From the Hugging Face model README
이 모델은 AIHub의 감성대화 말뭉치 데이터셋을 기반으로 한국어 대화의 감정을 분류하는 KoBERT 모델입니다.
원본 데이터셋을 다시 5개의 감정 범주로 레이블링하였으며, Hugging Face의 Trainer 클래스를 사용하여 훈련되었습니다.
사용된 데이터셋은 AIHub의 감성대화 말뭉치에서 가져온 데이터로, 대화 텍스트를 5개의 범주로 레이블링하여 전처리하였습니다. 이 데이터는 80%는 학습 데이터로, 나머지 20%는 검증 데이터로 나누어 사용되었습니다.
이 모델은 monologg/kobert 사전 학습된 KoBERT 모델을 기반으로 합니다. KoBERT는 한국어 BERT 모델로서, 이 프로젝트에서 5개의 감정 범주를 분류하는 목적을 위해 미세 조정(fine-tuning)되었습니다.
모델은 AutoTokenizer를 사용하여 문장을 토큰화하였으며, padding='max_length'와 truncation=True 옵션을 사용하여 최대 길이 128의 입력으로 변환되었습니다.
tokenizer = AutoTokenizer.from_pretrained("monologg/kobert", trust_remote_code=True)
def tokenize_function(examples):
return tokenizer(examples['input_text'], padding='max_length', truncation=True, max_length=128)
train_dataset = train_dataset.map(tokenize_function, batched=True)
val_dataset = val_dataset.map(tokenize_function, batched=True)
모델은 BertForSequenceClassification 클래스를 사용하여 5개의 감정 레이블을 분류합니다.
model = BertForSequenceClassification.from_pretrained('monologg/kobert', num_labels=5)
모델 학습을 위해 Hugging Face의 Trainer 클래스를 사용하였으며, 다음과 같은 학습 설정을 적용하였습니다:
training_args = TrainingArguments(
output_dir='./results',
learning_rate=2e-5,
per_device_train_batch_size=16,
per_device_eval_batch_size=16,
num_train_epochs=10,
eval_strategy="epoch",
save_strategy="epoch",
metric_for_best_model="f1_macro",
load_best_model_at_end=True
)
모델을 사용하려면 다음과 같이 Hugging Face transformers 라이브러리에서 KoBERT 토크나이저를 사용하여 로드할 수 있습니다:
from transformers import AutoTokenizer, BertForSequenceClassification
# KoBERT의 원래 토크나이저 사용
tokenizer = AutoTokenizer.from_pretrained('monologg/kobert')
model = BertForSequenceClassification.from_pretrained('jeonghyeon97/koBERT-Senti5')
# 예시 입력 (여러 문장 리스트)
texts = [
"오늘은 정말 행복한 하루야!",
"이거 정말 짜증나고 화난다.",
"그냥 그렇네.",
"왜 이렇게 슬프지?",
"기분이 좀 불안해."
]
# 입력 텍스트 토큰화
inputs = tokenizer(texts, return_tensors='pt', padding=True, truncation=True)
# 예측
outputs = model(**inputs)
predictions = outputs.logits.argmax(dim=-1)
# 결과 출력
for text, prediction in zip(texts, predictions):
print(f"입력: {text} -> 예측된 감정 레이블: {prediction.item()}")