a2ran commited on
Commit
5b04d60
·
1 Parent(s): 680147a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +51 -1
README.md CHANGED
@@ -1,7 +1,57 @@
1
  ---
2
  library_name: peft
3
  ---
4
- ## Training procedure
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
 
7
  The following `bitsandbytes` quantization config was used during training:
 
1
  ---
2
  library_name: peft
3
  ---
4
+
5
+ # WIP
6
+
7
+ ## 1. 사용절차
8
+
9
+ * Install model and PEFT parameters
10
+
11
+ ```
12
+ import torch
13
+ from peft import PeftModel, PeftConfig
14
+ from transformers import AutoTokenizer, AutoModelForCausalLM, GPTQConfig
15
+
16
+ model_id = "TheBloke/WizardLM-13B-V1.2-GPTQ"
17
+
18
+ config = PeftConfig.from_pretrained("a2ran/GPTeacher_ko_llama2_13B")
19
+ tokenizer = AutoTokenizer.from_pretrained(model_id, use_fast=True)
20
+ quantization_config_loading = GPTQConfig(bits=4, disable_exllama=True)
21
+
22
+ model = AutoModelForCausalLM.from_pretrained(model_id, quantization_config=quantization_config_loading,
23
+ torch_dtype=torch.float16, device_map="auto")
24
+ model = PeftModel.from_pretrained(model, "a2ran/GPTeacher_ko_llama2_13B")
25
+ ```
26
+
27
+ * How to Generate Tokens
28
+
29
+ ```
30
+ from transformers import TextStreamer
31
+
32
+ streamer = TextStreamer(tokenizer)
33
+
34
+ # your input sentence가 들어갈 곳
35
+ input = """
36
+ ### input @ 미국의 행정시스템에 대해 설명해줘.\n\n### response @"""
37
+
38
+ output = tokenizer.decode(model.cuda().generate(
39
+ **tokenizer(
40
+ input,
41
+ return_tensors='pt',
42
+ ).to(0),
43
+ max_new_tokens = 2048,
44
+ temperature = 1.2,
45
+ top_p = 0.7,
46
+ early_stopping = True,
47
+ eos_token_id = 2,
48
+ do_sample = True,
49
+ repetition_penalty = 1.1,
50
+ streamer = streamer
51
+ )[0]).replace(input+" ", "")
52
+ ```
53
+
54
+ ## 2. Training procedure
55
 
56
 
57
  The following `bitsandbytes` quantization config was used during training: