--- library_name: peft base_model: yanolja/EEVE-Korean-Instruct-10.8B-v1.0 license: mit language: - ko - en pipeline_tag: translation --- 사용 데이터셋: aihub 훈련 환경: RTX3090 x 8 epoch: 1 time: 19시간 ``` python import torch from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig from peft import prepare_model_for_kbit_training, PeftModel, PeftConfig model_path = 'yanolja/EEVE-Korean-Instruct-10.8B-v1.0' lora_path = 'qwopqwop/EEVE-ALMA' bnb_config = BitsAndBytesConfig(load_in_4bit=True,bnb_4bit_quant_type="nf4",bnb_4bit_compute_dtype=torch.float16,) model = AutoModelForCausalLM.from_pretrained(model_path, quantization_config=bnb_config, trust_remote_code=True) model.config.use_cache = False model = PeftModel.from_pretrained(model, lora_path) model = prepare_model_for_kbit_training(model) tokenizer = AutoTokenizer.from_pretrained(model_path, padding_side='left') en_text = 'Hi.' ko_text = '안녕하세요.' en_prompt = f"Translate this from English to Korean:\nEnglish: {en_text}\nKorean:" ko_prompt = f"Translate this from Korean to English:\nKorean: {ko_text}\nEnglish:" input_ids = tokenizer(en_prompt, return_tensors="pt", padding=True, max_length=256, truncation=True).input_ids.cuda() with torch.no_grad(): generated_ids = model.generate(input_ids=input_ids, num_beams=5, max_new_tokens=20, do_sample=True, temperature=0.6, top_p=0.9) outputs = tokenizer.batch_decode(generated_ids, skip_special_tokens=True) print(outputs) input_ids = tokenizer(ko_prompt, return_tensors="pt", padding=True, max_length=256, truncation=True).input_ids.cuda() with torch.no_grad(): generated_ids = model.generate(input_ids=input_ids, num_beams=5, max_new_tokens=20, do_sample=True, temperature=0.6, top_p=0.9) outputs = tokenizer.batch_decode(generated_ids, skip_special_tokens=True) print(outputs) ```