Question Answering
Transformers
Chinese
chat
llm
llama2
chatgpt
Baicai003 commited on
Commit
f50fb30
·
1 Parent(s): aa299e7

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +42 -0
README.md CHANGED
@@ -1,6 +1,48 @@
1
  ---
2
  library_name: peft
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  ## Training procedure
5
 
6
 
 
1
  ---
2
  library_name: peft
3
  ---
4
+
5
+ 在sharegpt_cn数据集上训练得到的llama2 Chinese chat 13b,为减轻文件大小负担这里只放出了qlora的权重
6
+ 请拉取https://huggingface.co/TheBloke/Llama-2-13B-fp16作为基础权重,使用如下脚步进行合并:
7
+ ```python
8
+ from peft import PeftModel
9
+ from transformers import AutoModelForCausalLM, AutoTokenizer
10
+ import torch
11
+ """
12
+ 使用该脚本(引用于firefly项目),将qlora的权重合并大base model中
13
+ """
14
+
15
+
16
+ def merge_lora_to_base_model():
17
+ model_name_or_path = '/data/TheBloke/Llama-2-13B-fp16'
18
+ adapter_name_or_path = '/data/llama2-13b-Chinese-chat'
19
+ save_path = '/data/llama2-13b-Chinese-chat_v1'
20
+
21
+ tokenizer = AutoTokenizer.from_pretrained(
22
+ model_name_or_path,
23
+ trust_remote_code=True
24
+ )
25
+ model = AutoModelForCausalLM.from_pretrained(
26
+ model_name_or_path,
27
+ trust_remote_code=True,
28
+ low_cpu_mem_usage=True,
29
+ torch_dtype=torch.float16,
30
+ device_map='auto'
31
+ )
32
+ print("load model success")
33
+ model = PeftModel.from_pretrained(model, adapter_name_or_path)
34
+ print("load adapter success")
35
+ model = model.merge_and_unload()
36
+ print("merge success")
37
+
38
+ tokenizer.save_pretrained(save_path)
39
+ model.save_pretrained(save_path)
40
+
41
+
42
+ if __name__ == '__main__':
43
+ merge_lora_to_base_model()
44
+
45
+ ```
46
  ## Training procedure
47
 
48