Downloads · 30 days
4
17% of all-time downloads
gamzadole/llama3_instruct_tuning_without_pretraing
llama3_instruct_tuning_without_pretraing 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.
Downloads · 30 days
4
17% of all-time downloads
All-time downloads
23
Public
Repo size
4.4 GB
Likes
0
Public
Click a slice to open those files.
.safetensors4.4 GB · 100%
From the Hugging Face model README
Base model : beomi/Llama-3-Open-Ko-8B
Using Dataset : Bingsu/ko_alpaca_data & 한국어 생성 기반 상식추론 데이터셋
inference code
from peft import PeftModel, PeftConfig
from transformers import AutoModelForCausalLM, AutoTokenizer
config = PeftConfig.from_pretrained("gamzadole/llama3_instruct_tuning_without_pretraing")
base_model = AutoModelForCausalLM.from_pretrained("beomi/Llama-3-Open-Ko-8B", device_map="auto", load_in_4bit=True)
model = PeftModel.from_pretrained(base_model, "gamzadole/llama3_instruct_tuning_without_pretraing")
tokenizer = AutoTokenizer.from_pretrained("gamzadole/llama3_instruct_tuning_without_pretraing")
alpaca_prompt = """아래는 질문 instruction 과 추가정보를 나타내는 input 입니다. 적절한 response를 생성해주세요.
### Instruction:
{instruction}
### Input:
{input}
### Response:
{response}"""
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 = "건강을 유지하는 3가지 팁 알려줘"
print(generate_response(instruction, model))
response
'건강을 유지하는 세 가지 팁은 다음과 같습니다.
1. 적절한 수면 시간을 유지하세요.
2. 적절한 식습관을 유지하세요.
3. 규칙적인 운동을 하세요.'