ko-gemma2-9B-sentiment

한국어 유튜브 댓글 감정 분류를 위한 LLM (Gemma2 기반 LoRA Fine-tuned)

Overview

ko-gemma2-9B-sentiment는 Google의 Gemma2 9B 모델을 기반으로, 한국어 유튜브 댓글의 감정을 분류하기 위해 LoRA 기반의 PEFT 기법으로 파인튜닝된 모델입니다.
Chain of Thought (CoT) 방식의 프롬프트 설계와 유튜브 영상 요약 정보를 활용하여 '긍정', '중립', '부정' 중 하나의 감정 클래스를 예측합니다.

본 모델은 다음과 같은 특성을 가집니다:

  • Gemma2 대화 포맷 (<start_of_turn>user, <end_of_turn>, <start_of_turn>model)
  • 4비트 양자화 + LoRA로 경량화된 학습
  • CoT + Multimodal Prompt (영상 요약 정보 포함 가능)

Quickstart

Install

$ pip install transformers peft accelerate

Inference

from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
import torch

base_model = "rtzr/ko-gemma-2-9b-it"
adapter_path = "./ko-gemma2-9B-sentiment"

prompt = """<start_of_turn>user
댓글: 이 영상 정말 감동이었습니다. 눈물이 났어요.
<end_of_turn>
<start_of_turn>model
"""

tokenizer = AutoTokenizer.from_pretrained(base_model, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(base_model, torch_dtype=torch.float16, device_map="auto", trust_remote_code=True)
model = PeftModel.from_pretrained(model, adapter_path)
model.eval()

inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=1024, do_sample=False)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))

예시 출력

다음 유튜브 댓글의 감정을 분석하고, '긍정', '중립', '부정' 중 어디에 해당하는지 분류하고, 또한 왜 그렇게 분류했는지 감정 분류의 이유 및 근거도 서술해주세요.

댓글: 정말 감동이었습니다. 눈물이 났어요. 잘 보고 갑니다~


댓글을 분석한 결과, 이 댓글의 감정은 '긍정'입니다. 

Training Details

모델 및 환경 구성

  • Base Model: rtzr/ko-gemma-2-9b-it
  • Trainer: Hugging Face Trainer + LoRA
  • Quantization: 4bit (nf4, float16 compute)

LoRA 구성

  • target_modules: q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
  • r = 8, alpha = 16, dropout = 0.05
  • gradient_checkpointing = True

데이터셋 정보

  • Train 데이터 수 : 3,658개
  • Validation 데이터 수 : 921개

감정 레이블 분포

Train
  • 긍정: 1,012개 (27.67%)
  • 중립: 909개 (24.85%)
  • 부정: 1,737개 (47.48%)
Validation
  • 긍정: 268개 (29.10%)
  • 중립: 233개 (25.30%)
  • 부정: 420개 (45.60%)

Results


Fine-tuned Performance

Confusion Matrix

Confusion Matrix

Classification Report

              precision    recall  f1-score   support

          긍정       0.89      0.85      0.87       574
          중립       0.46      0.52      0.49       169
          부정       0.70      0.70      0.70       246
    accuracy                           0.76       989
   macro avg       0.68      0.69      0.69       989
weighted avg       0.77      0.76      0.76       989

Contact

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support