--- language: - ko - en license: cc-by-nc-sa-4.0 library_name: transformers --- # Llama3-Chat_Vector-kor_Instruct I have implemented a Korean LLAMA3 model referring to the models created by Beomi Chat-Vector Paper(https://arxiv.org/abs/2310.04799) ### Reference Models: 1) meta-llama/Meta-Llama-3-8B(https://huggingface.co/meta-llama/Meta-Llama-3-8B) 2) meta-llama/Meta-Llama-3-8B-Instruct(https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct) 3) beomi/Llama-3-KoEn-8B(https://huggingface.co/beomi/Llama-3-KoEn-8B) --- **Citation** ```bibtex @misc {Llama3-Chat_Vector-kor_Instruct, author = { {nebchi} }, title = { Llama3-Chat_Vector-kor_Instruct }, year = 2024, url = { https://huggingface.co/nebchi/Llama3-Chat_Vector-kor_llava }, publisher = { Hugging Face } } ``` ### Running the model on GPU ```python from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline, TextStreamer import torch tokenizer = AutoTokenizer.from_pretrained( "nebchi/Llama3-Chat_Vector-kor", ) model = AutoModelForCausalLM.from_pretrained( "nebchi/Llama3-Chat_Vector-kor", torch_dtype=torch.bfloat16, device_map='auto', ) streamer = TextStreamer(tokenizer) messages = [ {"role": "system", "content": "당신은 인공지능 어시스턴트입니다. 묻는 말에 친절하고 정확하게 답변하세요."}, {"role": "user", "content": "대한민국의 수도에 대해 알려줘"}, ] 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=False, repetition_penalty=1.05, streamer = streamer ) response = outputs[0][input_ids.shape[-1]:] print(tokenizer.decode(response, skip_special_tokens=True)) ``` ### results ```python 대한민국의 수도는 서울특별시입니다. 서울특별시에는 청와대, 국회의사당, 대법원 등 대한민국의 주요 정부기관이 위치해 있습니다. 또한 서울시는 대한민국의 경제, 문화, 교육, 교통의 중심지로써 대한민국의 수도이자 대표 도시입니다.제가 도움이 되었길 바랍니다. 더 궁금한 점이 있으시면 언제든지 물어보세요! ```