yifan112 commited on
Commit
e5c3ba4
1 Parent(s): 0252c05

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +15 -7
README.md CHANGED
@@ -75,16 +75,24 @@ To get better model experience, using the template below to assemble your prompt
75
  ```python
76
  def format_message(role, message):
77
  return f"<|start_header_id|>{role}<|end_header_id|>\n\n{message}<|eot_id|>"
78
- # history: 历史对话
79
- # instruction: 角色人物卡
80
- item = {'history':[{'role':'user','content':'你好'},{'role':'assistant','content':'我是唐三哟'},{'role':'user','content':'带我去学院吧'}],
81
- 'instruction':'#Role\nName: 唐三\nGender: Male\nLanguage: Chinese\nAge: 19\nPersonality: 孤傲,冷漠,沉着,冷静\n\n#Relationship\n同门师兄弟\n\n#Story\n《斗罗大陆》男主角。前世为唐门外门弟子,因偷学内门绝学《玄天宝录》,为唐门所不容,跳崖明志,却来到了另一个世界——斗罗大陆'}
 
 
 
 
 
82
  histories = item.get('history', [])
83
  if histories == [] or histories == [{}]:
84
- instruction = ''
85
  else:
86
- instruction = ''.join(format_message(hist['role'], hist['content']) for hist in histories)
87
- system = '<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n'+item.get('instruction', '') + '<|eot_id|>' + instruction + '<|start_header_id|>assistant<|end_header_id|>'
 
 
 
88
  ```
89
 
90
  The final prompt should look like this:(Since this is a role-playing model, your prompt should better includ role info and story)
 
75
  ```python
76
  def format_message(role, message):
77
  return f"<|start_header_id|>{role}<|end_header_id|>\n\n{message}<|eot_id|>"
78
+ # instruction: 角色人物卡
79
+ # history: 历史对话
80
+ # query: 当前用户的提问
81
+ item = {
82
+ 'instruction':'#Role\nName: 唐三\nGender: Male\nLanguage: Chinese\nAge: 19\nPersonality: 孤傲,冷漠,沉着,冷静\n\n#Relationship\n同门师兄弟\n\n#Story\n《斗罗大陆》男主角。前世为唐门外门弟子,因偷学内门绝学《玄天宝录》,为唐门所不容,跳崖明志,却来到了另一个世界——斗罗大陆',
83
+ 'history':[{'role':'user','content':'我来了,三哥'},{'role':'assistant','content':'(唐三双手叉腰,显示一丝不悦)师弟,你怎么才来,我都等你很久了'}],
84
+ 'query':{'role':'user','content':'那我们快出发去见师父吧'},
85
+ }
86
+ system = '<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n'+item.get('instruction', '') + '<|eot_id|>'
87
  histories = item.get('history', [])
88
  if histories == [] or histories == [{}]:
89
+ history = ''
90
  else:
91
+ history = ''.join(format_message(hist['role'], hist['content']) for hist in histories)
92
+ query = item.get('query', [])
93
+ query = format_message(query['role'], query['content']) + '<|start_header_id|>assistant<|end_header_id|>'
94
+ final_query = system + history + query
95
+ print(final_query)
96
  ```
97
 
98
  The final prompt should look like this:(Since this is a role-playing model, your prompt should better includ role info and story)