Model Card for Model ID
Base model : beomi/Llama-3-Open-Ko-8B
Using Dataset : Bingsu/ko_alpaca_data & νκ΅μ΄ μμ± κΈ°λ° μμμΆλ‘ λ°μ΄ν°μ
Model Details
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. κ·μΉμ μΈ μ΄λμ νμΈμ.'
- Downloads last month
- 2
Model tree for gamzadole/llama3_instruct_tuning_without_pretraing
Base model
beomi/Llama-3-Open-Ko-8B
Adapter
this model