Downloads · 30 days
7
2% of all-time downloads
gamzadole/llama3_instruct_preview_alpaca_finetuning
llama3_instruct_preview_alpaca_finetuning is a machine learning model from gamzadole. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as llama3.
Base Model : beomi/Llama-3-Open-Ko-8B-Instruct-preview
Downloads · 30 days
7
2% of all-time downloads
All-time downloads
343
Public
Repo size
168 MB
Likes
0
Public
Click a slice to open those files.
.safetensors168 MB · 95%
From the Hugging Face model README
Base Model : beomi/Llama-3-Open-Ko-8B-Instruct-preview
Dataset = Bingsu/ko_alpaca_data
prompt template
alpaca_prompt = """아래는 질문 instruction 과 추가정보를 나타내는 input 입니다. 적절한 response를 생성해주세요.
### Instruction:
{instruction}
### Input:
{input}
### Response:
{response}"""
inference code
def generate_response(prompt, model):
prompt = alpaca_prompt.format(instruction=prompt, input="", response="")
messages = [
{"role": "system", "content": "친절한 챗봇으로서 상대방의 요청에 최대한 자세하고 친절하게 답하자. 모든 대답은 한국어(Korean)으로 대답해줘."},
{"role": "user", "content": f"{prompt}"},
]
input_ids = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
return_tensors="pt"
).to(model.device)
terminators = [
tokenizer.eos_token_id,
tokenizer.convert_tokens_to_ids("<|eot_id|>")
]
outputs = model.generate(
input_ids,
max_new_tokens=512,
eos_token_id=terminators,
do_sample=True,
temperature=0.1,
top_p=0.9,
)
response = outputs[0][input_ids.shape[-1]:]
return tokenizer.decode(response, skip_special_tokens=True)
instruction = "금리가 오르면 물가가 어떻게 돼?"
generate_response(instruction, model)