Upload 3 files
Browse files- README.md +48 -0
- adapter_config.json +33 -0
- adapter_model.safetensors +3 -0
README.md
CHANGED
@@ -1,3 +1,51 @@
|
|
1 |
---
|
|
|
|
|
2 |
license: mit
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
library_name: peft
|
3 |
+
base_model: yanolja/EEVE-Korean-Instruct-10.8B-v1.0
|
4 |
license: mit
|
5 |
+
language:
|
6 |
+
- ko
|
7 |
+
- en
|
8 |
+
pipeline_tag: translation
|
9 |
---
|
10 |
+
|
11 |
+
사용 데이터셋: aihub
|
12 |
+
|
13 |
+
훈련 환경: RTX3090 x 8
|
14 |
+
|
15 |
+
epoch: 1
|
16 |
+
|
17 |
+
time: 19시간
|
18 |
+
|
19 |
+
``` python
|
20 |
+
import torch
|
21 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
|
22 |
+
from peft import prepare_model_for_kbit_training, PeftModel, PeftConfig
|
23 |
+
|
24 |
+
model_path = 'yanolja/EEVE-Korean-Instruct-10.8B-v1.0'
|
25 |
+
lora_path = 'qwopqwop/EEVE-ALMA'
|
26 |
+
|
27 |
+
bnb_config = BitsAndBytesConfig(load_in_4bit=True,bnb_4bit_quant_type="nf4",bnb_4bit_compute_dtype=torch.float16,)
|
28 |
+
model = AutoModelForCausalLM.from_pretrained(model_path, quantization_config=bnb_config, trust_remote_code=True)
|
29 |
+
model.config.use_cache = False
|
30 |
+
model = PeftModel.from_pretrained(model, lora_path)
|
31 |
+
model = prepare_model_for_kbit_training(model)
|
32 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path, padding_side='left')
|
33 |
+
|
34 |
+
en_text = 'Hi.'
|
35 |
+
ko_text = '안녕하세요.'
|
36 |
+
|
37 |
+
en_prompt = f"Translate this from English to Korean:\nEnglish: {en_text}\nKorean:"
|
38 |
+
ko_prompt = f"Translate this from Korean to English:\nKorean: {ko_text}\nEnglish:"
|
39 |
+
|
40 |
+
input_ids = tokenizer(en_prompt, return_tensors="pt", padding=True, max_length=256, truncation=True).input_ids.cuda()
|
41 |
+
with torch.no_grad():
|
42 |
+
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)
|
43 |
+
outputs = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
|
44 |
+
print(outputs)
|
45 |
+
|
46 |
+
input_ids = tokenizer(ko_prompt, return_tensors="pt", padding=True, max_length=256, truncation=True).input_ids.cuda()
|
47 |
+
with torch.no_grad():
|
48 |
+
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)
|
49 |
+
outputs = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
|
50 |
+
print(outputs)
|
51 |
+
```
|
adapter_config.json
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"alpha_pattern": {},
|
3 |
+
"auto_mapping": null,
|
4 |
+
"base_model_name_or_path": "yanolja/EEVE-Korean-10.8B-v1.0",
|
5 |
+
"bias": "none",
|
6 |
+
"fan_in_fan_out": false,
|
7 |
+
"inference_mode": true,
|
8 |
+
"init_lora_weights": true,
|
9 |
+
"layers_pattern": null,
|
10 |
+
"layers_to_transform": null,
|
11 |
+
"loftq_config": {},
|
12 |
+
"lora_alpha": 16,
|
13 |
+
"lora_dropout": 0.1,
|
14 |
+
"megatron_config": null,
|
15 |
+
"megatron_core": "megatron.core",
|
16 |
+
"modules_to_save": null,
|
17 |
+
"peft_type": "LORA",
|
18 |
+
"r": 64,
|
19 |
+
"rank_pattern": {},
|
20 |
+
"revision": null,
|
21 |
+
"target_modules": [
|
22 |
+
"k_proj",
|
23 |
+
"o_proj",
|
24 |
+
"up_proj",
|
25 |
+
"q_proj",
|
26 |
+
"v_proj",
|
27 |
+
"gate_proj",
|
28 |
+
"down_proj"
|
29 |
+
],
|
30 |
+
"task_type": "CAUSAL_LM",
|
31 |
+
"use_dora": false,
|
32 |
+
"use_rslora": false
|
33 |
+
}
|
adapter_model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cac94806bf91eb3b57f1f9d7ba427238cb208715e0d73211aced73f5263f4ca9
|
3 |
+
size 503407912
|