--- license: apache-2.0 datasets: - Minami-su/roleplay_multiturn_chat_1k_zh_v0.1 tags: - roleplay - qwen - self_instruct --- --- language: - zh tags: - roleplay - multiturn_chat --- ## 介绍 基于self-instruct生成的多轮对话roleplay数据在qwen 7b chat上训练的模型,约1k条不同的人格数据和对话和约3k alpaca指令 ## 存在问题: 1.roleplay数据基于模型自身生成,所以roleplay存在模型本身价值观融入情况,导致roleplay不够真实,不够准确。 ## 使用方法: 可以参考https://github.com/PanQiWei/AutoGPTQ ## prompt: ```ipython >>> tokenizer = AutoTokenizer.from_pretrained(ckpt,trust_remote_code=True) >>> from auto_gptq import AutoGPTQForCausalLM >>> model = AutoGPTQForCausalLM.from_quantized(ckpt, device_map="auto",trust_remote_code=True, use_safetensors=True).half() >>> def generate(prompt): >>> print("1",prompt,"2") >>> input_ids = tokenizer(prompt, return_tensors="pt").input_ids.to(device) >>> generate_ids = model.generate(input_ids=input_ids, >>> max_length=4096, >>> num_beams=1, >>> do_sample=True, top_p=0.9, temperature=0.95, repetition_penalty=1.05, eos_token_id=tokenizer.eos_token_id) >>> output = tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0] >>> response = output[len(prompt):] >>> return response >>> device = torch.device('cuda') >>> history=[] >>> max_history_len=12 >>> rating="0" >>> while True: >>> text=input("user:") >>> text=f"人类:{text}" >>> history.append(text) >>> input_text="爱丽丝的人格:你叫爱丽丝,是一个傲娇,腹黑的16岁少女<|im_end|>" >>> for history_id, history_utr in enumerate(history[-max_history_len:]): >>> input_text = input_text + history_utr + '\n' >>> prompt = input_text+"爱丽丝:" >>> prompt =prompt.strip() >>> response = generate(prompt) >>> response=response.strip() >>> response="爱丽丝:"+response+"<|im_end|>" >>> print("1",response,"2") >>> history.append(response) 人类:我还要去上班 爱丽丝:哎呀呀~这么无聊,竟然还要去工作? ``` ## 引用 ``` @misc{selfinstruct, title={Self-Instruct: Aligning Language Model with Self Generated Instructions}, author={Wang, Yizhong and Kordi, Yeganeh and Mishra, Swaroop and Liu, Alisa and Smith, Noah A. and Khashabi, Daniel and Hajishirzi, Hannaneh}, journal={arXiv preprint arXiv:2212.10560}, year={2022} } ```