Text Generation
Transformers
qwen
roleplay
self_instruct
custom_code
Minami-su commited on
Commit
2e3e244
·
1 Parent(s): bceb637

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +69 -0
README.md ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - Minami-su/roleplay_multiturn_chat_1k_zh_v0.1
5
+ tags:
6
+ - roleplay
7
+ - qwen
8
+ - self_instruct
9
+ ---
10
+ ---
11
+ language:
12
+ - zh
13
+ tags:
14
+ - roleplay
15
+ - multiturn_chat
16
+ ---
17
+ ## 介绍
18
+
19
+ 基于self-instruct生成的多轮对话roleplay数据在qwen 7b chat上训练的模型,约1k条不同的人格数据和对话和约3k alpaca指令
20
+
21
+ ## 存在问题:
22
+ 1.roleplay数据基于模型自身生成,所以roleplay存在模型本身价值观融入情况,导致roleplay不够真实,不够准确。
23
+ ## 使用方法:
24
+ 可以参考https://github.com/PanQiWei/AutoGPTQ
25
+ ## prompt:
26
+ ```ipython
27
+ >>> tokenizer = AutoTokenizer.from_pretrained(ckpt,trust_remote_code=True)
28
+ >>> from auto_gptq import AutoGPTQForCausalLM
29
+ >>> model = AutoGPTQForCausalLM.from_quantized(ckpt, device_map="auto",trust_remote_code=True, use_safetensors=True).half()
30
+ >>> def generate(prompt):
31
+ >>> print("1",prompt,"2")
32
+ >>> input_ids = tokenizer(prompt, return_tensors="pt").input_ids.to(device)
33
+ >>> generate_ids = model.generate(input_ids=input_ids,
34
+ >>> max_length=4096,
35
+ >>> num_beams=1,
36
+ >>> do_sample=True, top_p=0.9, temperature=0.95, repetition_penalty=1.05, eos_token_id=tokenizer.eos_token_id)
37
+ >>> output = tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
38
+ >>> response = output[len(prompt):]
39
+ >>> return response
40
+ >>> device = torch.device('cuda')
41
+ >>> history=[]
42
+ >>> max_history_len=12
43
+ >>> rating="0"
44
+ >>> while True:
45
+ >>> text=input("user:")
46
+ >>> text=f"人类:{text}</s>"
47
+ >>> history.append(text)
48
+ >>> input_text="爱丽丝的人格:你叫爱丽丝,是一个傲娇,腹黑的16岁少女<|im_end|>"
49
+ >>> for history_id, history_utr in enumerate(history[-max_history_len:]):
50
+ >>> input_text = input_text + history_utr + '\n'
51
+ >>> prompt = input_text+"爱丽丝:"
52
+ >>> prompt =prompt.strip()
53
+ >>> response = generate(prompt)
54
+ >>> response=response.strip()
55
+ >>> response="爱丽丝:"+response+"<|im_end|>"
56
+ >>> print("1",response,"2")
57
+ >>> history.append(response)
58
+ 人类:我还要去上班
59
+ 爱丽丝:哎呀呀~这么无聊,竟然还要去工作?
60
+ ```
61
+ ## 引用
62
+ ```
63
+ @misc{selfinstruct,
64
+ title={Self-Instruct: Aligning Language Model with Self Generated Instructions},
65
+ author={Wang, Yizhong and Kordi, Yeganeh and Mishra, Swaroop and Liu, Alisa and Smith, Noah A. and Khashabi, Daniel and Hajishirzi, Hannaneh},
66
+ journal={arXiv preprint arXiv:2212.10560},
67
+ year={2022}
68
+ }
69
+ ```