Text Generation
Transformers
Safetensors
qwen
custom_code
silk-road commited on
Commit
588869f
·
1 Parent(s): 716506d

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +60 -0
README.md ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - silk-road/ChatHaruhi-Expand-118K
5
+ - silk-road/ChatHaruhi_NovelWriting
6
+ pipeline_tag: text-generation
7
+ ---
8
+
9
+ 本脚本是对千问7B模型的微调和测试,使得Qwen 7B能够有角色扮演的能力
10
+
11
+ This script fine-tunes and tests the Qwen 7B model to give Qwen 7B the capability of role playing.
12
+
13
+ 项目链接 https://github.com/LC1332/Chat-Haruhi-Suzumiya
14
+
15
+ - 118K训练数据由[李鲁鲁](https://github.com/LC1332)收集,
16
+
17
+ - 模型是由[豆角](https://github.com/goodnessSZW)训练的
18
+
19
+ - Qwen inference代码由米唯实编写,
20
+
21
+ - 李鲁鲁编写了ChatHaruhi内部的prompt组织函数
22
+
23
+
24
+ A Harry Potter test see in https://github.com/LC1332/Chat-Haruhi-Suzumiya/blob/main/notebook/Harry_Potter_test_on_Qwen7B.ipynb
25
+
26
+ 使用方法
27
+
28
+ 载入函数
29
+
30
+ ```python
31
+ from transformers import AutoTokenizer, AutoModel, AutoModelForCausalLM
32
+ tokenizer = AutoTokenizer.from_pretrained("silk-road/ChatHaruhi_RolePlaying_qwen_7b", trust_remote_code=True)
33
+ model = AutoModelForCausalLM.from_pretrained("silk-road/ChatHaruhi_RolePlaying_qwen_7b", device_map="auto", trust_remote_code=True)
34
+ model = model.eval()
35
+ ```
36
+
37
+ 具体看https://github.com/LC1332/Chat-Haruhi-Suzumiya/blob/main/notebook/ChatHaruhi_x_Qwen1_8B.ipynb 这个notebook
38
+
39
+ ```python
40
+ from ChatHaruhi import ChatHaruhi
41
+
42
+ chatbot = ChatHaruhi( role_name = 'haruhi', max_len_story = 1000 )
43
+
44
+ prompt = chatbot.generate_prompt(role='阿虚', text = '我看新一年的棒球比赛要开始了!我们要去参加吗?')
45
+
46
+ response, history = model.chat(tokenizer, prompt, history=[])
47
+ print(response)
48
+
49
+ chatbot.append_response(response)
50
+ ```
51
+
52
+ 目前支持
53
+ role_name
54
+
55
+ role_from_hf
56
+
57
+ role_from_jsonl
58
+
59
+ 多种角色格式载入。
60
+