๐ฐ๐ท Korean Stock News Analysis Model
GPT-4o์ ๋๋ฑํ 80% ์ ์ค๋ฅ ์ ๋ฌ์ฑํ ํ๊ตญ ์ฃผ์ ๋ด์ค ๋ถ์ ๋ชจ๋ธ
Qwen2.5-7B-Instruct๋ฅผ Knowledge Distillation์ผ๋ก ํ์ธํ๋ํ์ฌ ํ๊ตญ ์ฃผ์์์ฅ ๋ด์ค ๋ถ์ ๋ฐ ํฌ์ ์ถ์ฒ์ ์ํํ๋ ๋ชจ๋ธ์ ๋๋ค.
๐ Performance Highlights
| Metric | Score | ๋น๊ต |
|---|---|---|
| ์ ์ฒด ์ ์ค๋ฅ | 80.0% | GPT-4o์ ๋๋ฑ |
| BUY ์ ํธ ์ ์ค๋ฅ | 85.7% | 7๊ฑด ์ค 6๊ฑด ์ ์ค |
| ๊ฐ์ ๋ถ์ ์ ํ๋ | 95.0% | 20๊ฑด ์ค 19๊ฑด ์ ํ |
| ๊ธฐ์ ๋ช ์ถ์ถ F1 | 79.69 | Precision 72.2, Recall 88.8 |
| ๋น์ฉ ์ ๊ฐ | 95%+ | vs GPT-4o API |
๐ฏ ์ฃผ์ ๊ธฐ๋ฅ
1. ๋ด์ค ๊ฐ์ ๋ถ์
์
๋ ฅ: "์ผ์ฑ์ ์ 3๋ถ๊ธฐ ์์
์ด์ต 10์กฐ์ ๋ํ, ์์ฅ ์์ ํฌ๊ฒ ์ํ"
์ถ๋ ฅ: "๊ธ์ "
2. ํ๊ตญ ๊ธฐ์ ๋ช ์ถ์ถ
์
๋ ฅ: "์ผ์ฑ์ ์์ SKํ์ด๋์ค๊ฐ ๋ฐ๋์ฒด ํ๋ ฅ MOU ์ฒด๊ฒฐ"
์ถ๋ ฅ: "์ผ์ฑ์ ์, SKํ์ด๋์ค"
3. ํฌ์ ์ฐ๊ด๋ ๋ถ์
์
๋ ฅ: ์ฃผ์ ๊ด๋ จ ๋ด์ค
์ถ๋ ฅ: "๋์" / "๋ณดํต" / "๋ฎ์"
4. ํฌ์ ์ถ์ฒ ์์ฑ
์ถ๋ ฅ:
1. ์ผ์ฑ์ ์ - ๋งค์ - AI ๋ฐ๋์ฒด ์์ ์ฆ๊ฐ๋ก ์ค์ ๊ฐ์ ์ ๋ง
2. ํ๋์ฐจ - ๋งค์ - ์ ๊ธฐ์ฐจ ํ๋งค๋ ๊ธ์ฆ์ผ๋ก ์ฑ์ฅ ๊ฐ์ํ
3. ํฌ์ค์ฝ - ๋ณด์ - ์ฒ ๊ฐ ๊ฐ๊ฒฉ ์์น์ธ์ด๋ ์์์ฌ ๋น์ฉ ๋ถ๋ด
๐ Usage
LoRA ์ด๋ํฐ ์ฌ์ฉ๋ฒ (Oracle/์๋ฒ ํ๊ฒฝ ์ต์ ํ)
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import PeftModel
# 1. 4bit ์์ํ ์ค์ (๋ฉ๋ชจ๋ฆฌ ์ ์ฝ)
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=True,
bnb_4bit_compute_dtype=torch.float16
)
# 2. ๋ฒ ์ด์ค ๋ชจ๋ธ ๋ก๋ (4bit ์์ํ)
base_model = AutoModelForCausalLM.from_pretrained(
"Qwen/Qwen2.5-7B-Instruct",
quantization_config=bnb_config,
device_map="auto",
torch_dtype=torch.float16
)
# 3. LoRA ์ด๋ํฐ ์ ์ฉ
model = PeftModel.from_pretrained(
base_model,
"jsjung00/korean-stock-news-qwen-lora"
)
# 4. ํ ํฌ๋์ด์ ๋ก๋
tokenizer = AutoTokenizer.from_pretrained("jsjung00/korean-stock-news-qwen-lora")
# ๊ฐ์ ๋ถ์ ์์
def analyze_sentiment(news_title, news_content):
system_prompt = "๋น์ ์ ํ๊ตญ ์ฃผ์์์ฅ ์ ๋ฌธ ์ ๋๋ฆฌ์คํธ์
๋๋ค."
user_prompt = f'''๋ค์ ๋ด์ค์ ํฌ์ ๊ฐ์ ์ ๋ถ์ํด์ฃผ์ธ์. [๊ธ์ /์ค๋ฆฝ/๋ถ์ ] ์ค ํ๋๋ก๋ง ๋ต๋ณํ์ธ์.
์ ๋ชฉ: {news_title}
๋ด์ฉ: {news_content}'''
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_prompt}
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer([text], return_tensors="pt")
with torch.no_grad():
outputs = model.generate(
inputs.input_ids,
max_new_tokens=10,
do_sample=False,
temperature=0.1
)
response = tokenizer.decode(outputs[0][len(inputs.input_ids[0]):], skip_special_tokens=True)
return response.strip()
๐ฌ Training Details
Model Architecture
- Base Model: Qwen/Qwen2.5-7B-Instruct
- Fine-tuning: LoRA + 4bit Quantization
- Method: Supervised Fine-Tuning (SFT)
- Knowledge Source: GPT-4o responses
Hyperparameters
- Learning Rate: 2e-4
- Batch Size: 1 (gradient_accumulation_steps=4)
- Epochs: 5
- LoRA Rank: 64
- Chat Template: chat_template.jinja
- Assistant Only Loss: False
Training Data
- Source: ํ๊ตญ ์ฃผ์ ๊ด๋ จ ๋ด์ค (๋ค์ด๋ฒ, RSS ๋ฑ)
- Size: ์ฝ 1000+ ๋ด์ค ๊ธฐ์ฌ
- Tasks: ๊ฐ์ ๋ถ์, ๊ธฐ์ ์ถ์ถ, ์ฐ๊ด๋๋ถ์, ํฌ์์ถ์ฒ
- Annotation: GPT-4o Knowledge Distillation
๐ Evaluation Results
ํฌ์ ์ ํธ ์ฑ๊ณผ (2024.09.17-09.24)
- ๋งค์ ์ ํธ: 7๊ฑด ์ค 6๊ฑด ์ ์ค (85.7%)
- ๋ณด์ ์ ํธ: 3๊ฑด ์ค 2๊ฑด ์ ์ค (66.7%)
- ์ ์ฒด ์ ํธ: 10๊ฑด ์ค 8๊ฑด ์ ์ค (80.0%)
Task๋ณ ์ฑ๋ฅ
| Task | Metric | Score |
|---|---|---|
| ๊ฐ์ ๋ถ์ | Accuracy | 95.0% |
| ๊ธฐ์ ๋ช ์ถ์ถ | F1 Score | 79.69 |
| ์ฐ๊ด๋ ๋ถ์ | Accuracy | 35.0%* |
*์ฐ๊ด๋ ๋ถ์์ "๋ณดํต" ์์ค ๋ด์ค๋ ํฌํจํ๋๋ก ๊ธฐ์ค ์ํํ์ฌ ์ค์ฉ์ฑ ๊ฐ์
๐ System Architecture
์ด ๋ชจ๋ธ์ ๋ค์๊ณผ ๊ฐ์ ํ๋ก๋์ ์์คํ ์์ ํ์ฉ๋ฉ๋๋ค:
- n8n: ๋ด์ค ์์ง ๋ฐ ์ํฌํ๋ก์ฐ ์ค์ผ์คํธ๋ ์ด์
- LangGraph: ๋ค๋จ๊ณ ๋ด์ค ๋ถ์ ํ์ดํ๋ผ์ธ
- vLLM: ๊ณ ์ฑ๋ฅ ๋ชจ๋ธ ์๋น
- ์ค์๊ฐ ๋ฐฐํฌ: ๋งค์ผ ์๋์ผ๋ก ํฌ์ ๋ฆฌํฌํธ ์์ฑ
๐ Lessons Learned
- Chat Template ์ค์์ฑ: qwen.jinja vs chat_template.jinja ์ ํ์ด ์ฑ๋ฅ์ ๊ฒฐ์ ์ ์ํฅ
- ๊ณผ์ ํฉ ์ฃผ์: Epoch 5โ8๋ก ์ฆ๊ฐ์ ์ฑ๋ฅ์ด 80%โ60%๋ก ํ๋ฝ
- ๋ฐฐ์น ์ฒ๋ฆฌ: 4096 ํ ํฐ ์ ํ์ผ๋ก ๊ณ์ธต์ ์์ฝ ์ ๋ต ํ์
- Task๋ณ ํ๊ฐ: ์ ์ฒด ์ ํ๋๋ง์ผ๋ก ๋ณ๋ชฉ ์ง์ ํ์ ์ด๋ ค์
๐ License
Apache 2.0
๐ Acknowledgments
- Base Model: Qwen Team
- Knowledge Distillation: OpenAI GPT-4o
- Training Infrastructure: Colab Pro+
- Stock Data: pykrx library
Contact: ํฌ์๋ ๋ณธ์ธ ์ฑ ์ํ์ ์งํํ์๊ธฐ ๋ฐ๋๋๋ค. ์ด ๋ชจ๋ธ์ ์ฐธ๊ณ ์ฉ์ผ๋ก๋ง ์ฌ์ฉํด์ฃผ์ธ์.
- Downloads last month
- 1
Inference Providers
NEW
This model isn't deployed by any Inference Provider.
๐
Ask for provider support