File size: 1,939 Bytes
d01fda4 2b1da96 d01fda4 2b1da96 250ceac d01fda4 250ceac 2b1da96 250ceac 2b1da96 250ceac 2b1da96 250ceac 2b1da96 097ade2 250ceac 2b1da96 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
---
library_name: peft
base_model: yanolja/EEVE-Korean-Instruct-10.8B-v1.0
license: mit
language:
- ko
- en
pipeline_tag: translation
datasets:
- qwopqwop/ALMA-R-ko-en
---
원본 peft모델: qwopqwop/ALMA-EEVE-v1
사용 데이터셋: qwopqwop/ALMA-R-ko-en
훈련 환경: A6000
epoch: 1
time: 1시간
``` python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import prepare_model_for_kbit_training, PeftModel, PeftConfig
model_path = 'yanolja/EEVE-Korean-10.8B-v1.0'
lora_path = 'qwopqwop/EEVE-ALMA-R'
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)
``` |