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:
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.
Contact
For any inquiries or feedback, feel free to contact the team:
- Email: [email protected]
Team:
- Hanjun Jung
- Jinsoo Kim
- Junhyeok Choi
- Suil Lee
- Seongjae Kang