MarkrAI/KOpen-HQ-Hermes-2.5-60K
Viewer โข Updated โข 60.1k โข 40 โข 62
์ด ๋ชจ๋ธ์ meta-llama/Meta-Llama-3.1-8B-Instruct๋ฅผ QLoRA ๊ธฐ๋ฒ์ ์ฌ์ฉํ์ฌ ํ๊ตญ์ด instruction ๋ฐ์ดํฐ๋ก ํ์ธํ๋ํ LoRA ์ด๋ํฐ์ ๋๋ค.
์ด ๋ชจ๋ธ์ ์๋ ํ๊ตญ์ด instruction ๋ฐ์ดํฐ์ ์ ๊ฒฐํฉํ์ฌ ํ์ต๋์์ต๋๋ค:
๊ณ ํ์ง ํ๊ตญ์ด ๋ฐ์ดํฐ์ ์ ๊ณต๊ฐํด์ฃผ์ Markr AI ํ(Seungyoo Lee, Kyujin Han)๊ป ์ง์ฌ์ผ๋ก ๊ฐ์ฌ๋๋ฆฝ๋๋ค. ์ด๋ฌํ ์คํ ๋ฐ์ดํฐ์ ๋๋ถ์ ํ๊ตญ์ด ์ธ์ด๋ชจ๋ธ ์ฐ๊ตฌ์ ๊ฐ๋ฐ์ด ํ์ฑํ๋๊ณ ์์ต๋๋ค.
์๋๋ ๋ฌธ์ ๋ฅผ ์ค๋ช
ํ๋ ์ง์์ฌํญ์
๋๋ค. ์ด ์์ฒญ์ ๋ํด ์ ์ ํ๊ฒ ๋ต๋ณํด์ฃผ์ธ์.
###์ง์์ฌํญ: {instruction}
###๋ต๋ณ:
์ ๋ ฅ์ด ์๋ ๊ฒฝ์ฐ:
์๋๋ ๋ฌธ์ ๋ฅผ ์ค๋ช
ํ๋ ์ง์์ฌํญ๊ณผ, ๊ตฌ์ฒด์ ์ธ ๋ต๋ณ์ ๋ฐฉ์์ ์๊ตฌํ๋ ์
๋ ฅ์ด ํจ๊ป ์๋ ๋ฌธ์ฅ์
๋๋ค. ์ด ์์ฒญ์ ๋ํด ์ ์ ํ๊ฒ ๋ต๋ณํด์ฃผ์ธ์.
###์
๋ ฅ:{input}
###์ง์์ฌํญ:{instruction}
###๋ต๋ณ:
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch
# ๋ฒ ์ด์ค ๋ชจ๋ธ ๋ก๋
base_model_name = "meta-llama/Meta-Llama-3.1-8B-Instruct"
model = AutoModelForCausalLM.from_pretrained(
base_model_name,
torch_dtype=torch.bfloat16,
device_map="auto",
)
# LoRA ์ด๋ํฐ ๋ก๋
model = PeftModel.from_pretrained(
model,
"jiwon9703/KoLlama-3.1-8B-Instruct-qlora-sft-v0",
)
# Tokenizer ๋ก๋
tokenizer = AutoTokenizer.from_pretrained(base_model_name)
# ์ถ๋ก
prompt = "์๋๋ ๋ฌธ์ ๋ฅผ ์ค๋ช
ํ๋ ์ง์์ฌํญ์
๋๋ค. ์ด ์์ฒญ์ ๋ํด ์ ์ ํ๊ฒ ๋ต๋ณํด์ฃผ์ธ์.\n###์ง์์ฌํญ: ์ธ๊ณต์ง๋ฅ์ ์ฅ์ ๊ณผ ๋จ์ ์ ์ค๋ช
ํด์ฃผ์ธ์.\n###๋ต๋ณ:"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=512,
temperature=0.7,
top_p=0.9,
do_sample=True,
)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import PeftModel
import torch
# 4-bit ์์ํ ์ค์
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_use_double_quant=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16,
)
# ๋ฒ ์ด์ค ๋ชจ๋ธ ๋ก๋ (4-bit)
base_model_name = "meta-llama/Meta-Llama-3.1-8B-Instruct"
model = AutoModelForCausalLM.from_pretrained(
base_model_name,
quantization_config=bnb_config,
device_map="auto",
)
# LoRA ์ด๋ํฐ ๋ก๋
model = PeftModel.from_pretrained(
model,
"jiwon9703/KoLlama-3.1-8B-Instruct-qlora-sft-v0",
)
tokenizer = AutoTokenizer.from_pretrained(base_model_name)
์ด ๋ชจ๋ธ์ ์ฌ์ฉํ์ค ๊ฒฝ์ฐ ์๋์ ๊ฐ์ด ์ธ์ฉํด์ฃผ์ธ์:
@misc{kollama31-8b-qlora-sft-v0,
title={KoLlama-3.1-8B-Instruct QLoRA Adapter (SFT v0)},
author={jiwon9703},
year={2024},
publisher={Hugging Face},
howpublished={\url{https://huggingface.co/jiwon9703/jiwon9703/KoLlama-3.1-8B-Instruct-qlora-sft-v0}}
}
@dataset{kopen_hq_hermes_2.5_60k,
title={KOpen-HQ-Hermes-2.5-60K},
author={Lee, Seungyoo and Han, Kyujin},
organization={Markr AI},
year={2024},
url={https://huggingface.co/datasets/MarkrAI/KOpen-HQ-Hermes-2.5-60K},
license={MIT}
}
์ด ๋ชจ๋ธ์ Meta์ Llama 3.1 Community License Agreement๋ฅผ ๋ฐ๋ฆ ๋๋ค. ์์ธํ ๋ด์ฉ์ Llama 3.1 License๋ฅผ ์ฐธ์กฐํ์ธ์.
Base model
meta-llama/Llama-3.1-8B