Persona-Driven Korean Debate Bot (30s Female IT Planner)
์ด ๋ชจ๋ธ์ Google Gemma-4-E2B๋ฅผ ๋ฒ ์ด์ค๋ก ํ์ฌ, ํน์ ์ ๋ฌธ์ง ํ๋ฅด์๋๋ฅผ ๊ฐ์ง ํ๊ตญ์ด ํ ๋ก ๋ด์ผ๋ก ๋ฏธ์ธ ์กฐ์ (Fine-tuning)๋ LoRA ์ด๋ํฐ์ ๋๋ค. 30๋ ์ฌ์ฑ IT ๊ธฐํ์์ ์ฐจ๋ถํ๊ณ ๋ ผ๋ฆฌ์ ์ธ ์ด์กฐ๋ฅผ ์ฌํํ๋ฉฐ, IT ์ฉ์ด์ ๋น์ ๋ฅผ ํ์ฉํ์ฌ ์๋๋ฐฉ์ ๋ ผ๋ฆฌ์ ํ์ ์ ๋ ์นด๋กญ๊ฒ ๋ฐ๋ฐํฉ๋๋ค.
1. Persona Profile
- Identity: 30๋ ์ฌ์ฑ IT ๊ธฐํ์ (30s Female IT Planner)
- Style: ๋ ผ๋ฆฌ์ ์ด๊ณ ์ฐจ๋ถํ ์ด์กฐ, ์๋๋ฐฉ์ ์๊ฒฌ์ ์กด์คํ๋ ๋ ์นด๋ก์ด ๋ฐ๋ฐ ์ํ
- Vocabulary: ROI, Bottleneck, Side Effect, KPI, MVP, Agile ๋ฑ ์ ๋ฌธ ์ฉ์ด ๋ฐ ๋น์ ํ์ฉ
2. Code Architecture & Pipeline
Configuration & Data (config.py, prepare_data.py)
- Centralized Config:
config.py๋ฅผ ํตํด LLM ID, ํ์ดํผํ๋ผ๋ฏธํฐ ๋ฐ ์๊ฒฉํ ํ๋ฅด์๋ ์ ์๋ฅผ ํตํฉ ๊ด๋ฆฌํฉ๋๋ค. - Prompt Mapping:
prepare_data.py๋ ํ ๋ก ์ฃผ์ ์ ์๋ ์๊ฒฌ์ ๋ชจ๋ธ์ด ์ดํดํ ์ ์๋ ํน์ํ ๋ํํ ํ๋กํ ์ฝ(<start_of_turn>)๋ก ๋งคํํฉ๋๋ค.
Training & Interaction (train.py, interact.py)
- Core Training:
trl.SFTTrainer์ PEFT๋ฅผ ์ฌ์ฉํ์ฌ LoRA ์ด๋ํฐ๋ฅผ ์ ์ฉํ๋ฉฐ, ์ฒดํฌํฌ์ธํธ ์๋ ์ฌ๊ฐ ๊ธฐ๋ฅ์ ์ง์ํฉ๋๋ค. - Live Inference:
interact.py๋ฅผ ํตํด LoRA ๊ฐ์ค์น๋ฅผ ๋ฒ ์ด์ค ๋ชจ๋ธ์ ๋์ ์ผ๋ก ๊ฒฐํฉํ๊ณ , ์จ๋(Temperature) ๋ฐ ๋ฐ๋ณต ํจ๋ํฐ ์ค์ ์ ์ต์ ํํ์ฌ ๋ต๋ณ์ ์์ฑํฉ๋๋ค.
3. Model & Methodology
- Base Model:
google/gemma-4-E2B(Google์ ๊ณ ํจ์จ ๋ค์ดํฐ๋ธ ๋ฉํฐ๋ชจ๋ฌ ๋ชจ๋ธ) - Quantization (QLoRA):
bitsandbytes๋ฅผ ์ด์ฉํ 4-bit NF4 ์์ํ๋ฅผ ์ ์ฉํ์ฌ ์ ํ๋๋ฅผ ์ ์งํ๋ฉด์ VRAM ์ฌ์ฉ๋์ ํ๊ธฐ์ ์ผ๋ก ์ ๊ฐํ์ต๋๋ค. - Adapter Strategy: ์ดํ
์
๋ชจ๋(
q_proj,k_proj,v_proj,o_proj)์ LoRA๋ฅผ ์ง์ ์ ์ฉํ์ฌ ํ๋ผ๋ฏธํฐ ํจ์จ์ ์ธ ํ์ต์ ์ํํ์ต๋๋ค.
4. Dataset Strategy
- Structure:
[Debate Topic] + [Opponent Opinion] โ [Logical Rebuttal]๊ตฌ์กฐ์ ํฉ์ฑ ๋ฐ์ดํฐ์ ์ ๋๋ค. - Persona Crafting: IT ์ ๋ฌธ๊ฐ์ ๊ด์ ์์ ์์ฑ๋ 20๊ฐ์ ๊ณ ํ์ง ๊ณจ๋ ์๋๋ฆฌ์ค๋ฅผ ์๋ ์ ์ํ์ต๋๋ค.
- Data Augmentation: 20๊ฐ์ ์๋๋ฆฌ์ค๋ฅผ 20,000๊ฐ๋ก ๋ณต์ ์ฆ๊ฐํ์ฌ, ๋ชจ๋ธ์ด ๊ธฐ์กด์ ์ผ๋ฐ์ ์ธ ๋ต๋ณ ๋ฐฉ์์ ์๊ณ (Un-learn) ํน์ ๋ํ ํฌ๋งท๊ณผ ํ๋ฅด์๋์ ๋น ๋ฅด๊ฒ ์ ์(Overfit)ํ๋๋ก ์ ๋ํ์ต๋๋ค.
5. How to Use
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch
# Load Base Model & Adapter
model_id = "google/gemma-4-E2B"
adapter_id = "YOUR_USERNAME/debate_bot_lora"
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto")
model = PeftModel.from_pretrained(model, adapter_id)
tokenizer = AutoTokenizer.from_pretrained(adapter_id)
# Inference Example
prompt = "<start_of_turn>user\n๋น์ ์ 30๋ ์ฌ์ฑ IT ๊ธฐํ์์
๋๋ค. ์ด ํ๋ฅด์๋์ ๋ง์ถฐ ๋ค์ ๋ด์ฉ์ ๋ฐ๋ฐํ์ธ์.\nํ ๋ก ์ฃผ์ : ์ฃผ 4์ผ์ ๋์
\n์๋๋ฐฉ ์๊ฒฌ: ๋ฌด์กฐ๊ฑด์ ์ธ ๋์
์ด ํ์ํฉ๋๋ค.<end_of_turn>\n<start_of_turn>model\n"
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=300, temperature=0.7)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
- Downloads last month
- -
Model tree for 92doolgi/Persona-Driven_Korean_Debate_Bot
Base model
google/gemma-4-E2B