Housing-Subscription-QA-Phi-3.5
Model Details
Model Description
- Model type: Question Answering
- Language(s) (NLP): Korean
- Finetuned from model: microsoft/Phi-3.5-mini-instruct
Model Sources
from peft import PeftModel, PeftConfig
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
config = PeftConfig.from_pretrained("hecatonai/Housing-Subscription-QA-Phi-3.5")
base_model = AutoModelForCausalLM.from_pretrained("microsoft/Phi-3.5-mini-instruct", device_map='auto')
model = PeftModel.from_pretrained(base_model, "hecatonai/Housing-Subscription-QA-Phi-3.5", device_map='auto')
# ํ ํฌ๋์ด์ ๋ก๋
tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3.5-mini-instruct", device_map='auto')
# ์
๋ ฅ ํ
์คํธ ํฌ๋งทํ
def apply_chat_template(question):
template = "<|system|>\nYou are a helpful AI assistant. The default is 2024.<|end|>\n<|user|>\n{question}<|end|>\n<|assistant|>\n"
return template.format(question=question)
# ์
๋ ฅ ํ
์คํธ ํ ํฌ๋์ด์ง
question = "ํฌ๊ธฐ๊ณผ์ด์ง๊ตฌ ๋๋ ์ฒญ์ฝ๊ณผ์ด์ง์ญ์์ ์ธ๊ตญ์ธ 1์์ ์ฒญ์ฝ ๊ฐ๋ฅ?"
input_text = apply_chat_template(question)
inputs = tokenizer(input_text, return_tensors="pt")
# ์์ธก ์ํ
outputs = model.generate(**inputs, max_length=1000)
# ์ถ๋ ฅ ๋์ฝ๋ฉ
decoded_output = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(decoded_output)
Bias, Risks, and Limitations
ํด๋น ๋ชจ๋ธ์ ๋ํ๋ฏผ๊ตญ ๊ตญํ ๊ตํต๋ถ์์ ๋ฐํํ 2022๋
๋ ๋ฐ 2024๋
๋ ์ฃผํ์ฒญ์ฝ FAQ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก
Fine-Tune ํ LLM์
๋๋ค. ๋ฐ๋ผ์ ํด๋น FAQ์ ํฌํจ๋์ง ์์ ์ง๋ฌธ์ ๋ํด์๋ ๋ถ์ ํํ ๋ต๋ณ์ ํ ์ ์์ผ๋ ์ฌ์ฉ์ ์ ์๋ฐ๋๋๋ค.
How to Get Started with the Model
Use the code below to get started with the model.
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
config = PeftConfig.from_pretrained("hecatonai/Housing-Subscription-QA-Phi-3.5")
base_model = AutoModelForCausalLM.from_pretrained("microsoft/Phi-3.5-mini-instruct", device_map='auto')
model = PeftModel.from_pretrained(base_model, "hecatonai/Housing-Subscription-QA-Phi-3.5", device_map='auto')
Using with Pipeline
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
model = AutoModelForCausalLM.from_pretrained("hecatonai/Housing-Subscription-QA-Phi-3.5", device_map='auto')
pipe = pipeline("text-generation", model=model, tokenizer="microsoft/Phi-3.5-mini-instruct", torch_dtype=torch.bfloat16, device_map="auto")
messages = [
{"role": "system", "content": "You are a helpful AI assistant. The default is 2024."},
{"role": "user", "content": "ํฌ๊ธฐ๊ณผ์ด์ง๊ตฌ ๋ฐ ์ฒญ์ฝ๊ณผ์ด์ง์ญ 1์์ ์ ํ๋์ ๋๊ตฌ?"}
]
prompt = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
outputs = pipe(prompt, renormalize_logits=True, max_new_tokens=512, do_sample=False)
print(outputs[0]["generated_text"])
Result
<|system|>
You are a helpful AI assistant. The default is 2024.<|end|>
<|user|>
ํฌ๊ธฐ๊ณผ์ด์ง๊ตฌ ๋ฐ ์ฒญ์ฝ๊ณผ์ด์ง์ญ 1์์ ์ ํ๋์ ๋๊ตฌ?<|end|>
<|assistant|>
2024๋
๋ต๋ณ: ํฌ๊ธฐ๊ณผ์ด์ง๊ตฌ ๋ฐ ์ฒญ์ฝ๊ณผ์ด์ง์ญ์์ ๊ตญ๋ฏผ์ฃผํ๊ณผ ๋ฏผ์์ฃผํ 1์์ ์ ํ ๋์์, ๊ณผ๊ฑฐ 5๋
์ด๋ด์ ๋ณธ์ธ ๋๋ ์ธ๋์์ด ๋ค๋ฅธ ์ฃผํ์ ๋น์ฒจ์๊ฐ ๋ ๊ฒฝ์ฐ์
๋๋ค.
Training Details
Training Data
dataset: Housing_Subscription_QA_Dataset
Training Hyperparameters
This model following Hyperparameters were used during training:
- bf16 = True
- learning_rate = 5.0e-5
- num_train_epochs = 15
- per_device_batch_size = 4
- warmup_ratio = 0.2
Traning Prompt
messages = [{"role": "system", "content": "You are a helpful AI assistant."},
{"role": "user", "content": f"{example['question']}"},
{"role": "assistant", "content": f"{example['answer']}"}]
Framework versions
- PEFT 0.12.0
- Transformers 4.44.2
- Downloads last month
- 2
Model tree for hecatonai/Housing-Subscription-QA-Phi-3.5
Base model
microsoft/Phi-3.5-mini-instruct