--- license: cc-by-nc-sa-4.0 datasets: - nlpai-lab/kullm-v2 language: - ko pipeline_tag: text-generation --- 교육용으로 학습 한 간단한 instruction fine-tuning 모델 - Pretrained model: skt/kogpt2-base-v2 (https://github.com/SKT-AI/KoGPT2) - Training data: kullm-v2(https://huggingface.co/datasets/nlpai-lab/kullm-v2) ```python from transformers import AutoModelForCausalLM from transformers import PreTrainedTokenizerFast tokenizer = PreTrainedTokenizerFast.from_pretrained("hyunjae/skt-kogpt2-kullm-v2", padding_side="right", model_max_length=512) model = AutoModelForCausalLM.from_pretrained('hyunjae/skt-kogpt2-kullm-v2').to('cuda') PROMPT= "### system:사용자의 질문에 맞는 적절한 응답을 생성하세요.\n### 사용자:{instruction}\n### 응답:" text = PROMPT.format_map({'instruction':"안녕? 너가 할 수 있는게 뭐야?"}) input_ids = tokenizer.encode(text, return_tensors='pt').to(model.device) gen_ids = model.generate(input_ids, repetition_penalty=2.0, pad_token_id=tokenizer.pad_token_id, eos_token_id=tokenizer.eos_token_id, bos_token_id=tokenizer.bos_token_id, num_beams=4, no_repeat_ngram_size=4, max_new_tokens=128, do_sample=True, top_k=50, early_stopping=True, use_cache=True) generated = tokenizer.decode(gen_ids[0]) print(generated) ```