--- license: apache-2.0 --- # Qwen3-8B-Korean-Sentiment ## Overview This repository contains a fine-tuned model for **Korean Sentiment Analysis (한국어 감정 분석)** using a **Large Language Model (LLM)**, specifically designed for **YouTube comments** in **Korean**. The model classifies sentiments into **Positive(긍정)**, **Negative(부정)**, and **Neutral(중립)** categories, and is fine-tuned to detect not only direct emotions but also subtle features like **irony (반어법)** and **sarcasm (풍자)** common in Korean-language content. ### Sentiment Classification: - **Positive (긍정)** - **Negative (부정)** - **Neutral (중립)** ## Quickstart To quickly get started with the fine-tuned model, use the following Python code: ```python from peft import AutoPeftModelForCausalLM from transformers import AutoTokenizer import torch # Load the model and tokenizer model = AutoPeftModelForCausalLM.from_pretrained( "LLM-SocialMedia/Qwen3-8B-Korean-Sentiment", # if GPU memory is insufficient device_map="auto", offload_folder="/offload", offload_state_dict=True, torch_dtype=torch.bfloat16 ) tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-8B") model.eval() # Sample comment comment = "이거 너무 좋아요!" # Format the prompt messages = [ { "role": "user", "content": ( "아래는 한국어 유튜브 댓글의 감정 분류 작업입니다.\n\n" f"댓글: {comment}\n\n" "다음 단계별로 꼼꼼히 생각하고 분석해 주세요:\n" "step_0. 댓글에서 사용된 주요 단어와 표현의 감정적 의미 분석 (예: 긍정적, 부정적, 중립적, 혹은 애매하거나 은어/반어적)\n" "step_1. 이모티콘, 이모지, 밈, 인터넷 은어의 숨겨진 의미 분석\n" "step_2. 댓글의 맥락과 의도 분석 (예: 진심, 풍자, 농담, 비꼼)\n" "step_3. 댓글을 감정을 분류 하세요\n" "step_4. 최종 감정 분류: '긍정', '중립', '부정' 중 하나\n\n" "마지막으로 아래 두 가지를 명확히 작성하세요:\n" "1. 분류 근거: 각 단계 분석을 종합한 감정 분류 이유\n" "2. 감정 분류 결과: '긍정', '중립', '부정' 중 하나로 출력\n\n" "출력 예시:\n" "분류 근거: 이 댓글은 농담과 비꼼을 섞었지만 최종적으로 유튜버를 긍정적으로 평가하고 있습니다.\n" "감정 분류 결과: 긍정" ) } ] prompt = tokenizer.apply_chat_template( messages, tokenize=False, add_generation_prompt=True ) # Tokenize the input inputs = tokenizer(prompt, return_tensors="pt") # Generate prediction outputs = model.generate(input_ids=inputs["input_ids"].to("cuda"), max_new_tokens=512) # Decode and print the output print(tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]) ``` ## Train/Test Details - **Training Dataset**: Fine-tuned on **3,857** labeled YouTube comments for sentiment classification. - **Testing Dataset**: Evaluated on **1,130** labeled YouTube comments to assess the model's performance. ## Results The fine-tuned model's performance on the sentiment classification task is summarized below: | Metric | Positive (긍정) | Neutral (중립) | Negative (부정) | |--------------|-----------------|----------------|-----------------| | **Precision**| 0.8981 | 0.3787 | 0.4971 | | **Recall** | 0.7362 | 0.2880 | 0.7413 | | **F1-Score** | 0.8092 | 0.3272 | 0.5951 | | **Support** | 527 | 309 | 344 | **Accuracy**: 62.03% (Based on 1180 samples) You can find detailed results [here](https://github.com/suil0109/LLM-SocialMedia/tree/main/huggingface). ## Contact For any inquiries or feedback, feel free to contact the team: - **Email**: suil0109@gmail.com **Team**: - Hanjun Jung - Jinsoo Kim - Junhyeok Choi - Suil Lee - Seongjae Kang