ClueAI commited on
Commit
00e8a53
1 Parent(s): 5a2c5be

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +2 -2
README.md CHANGED
@@ -101,9 +101,10 @@ def preprocess(text):
101
  def postprocess(text):
102
  return text.replace("\\n", "\n").replace("\\t", "\t").replace('%20',' ')
103
 
104
- def answer(text, sample=True, top_p=1, temperature=0.7):
105
  '''sample:是否抽样。生成任务,可以设置为True;
106
  top_p:0-1之间,生成的内容越多样'''
 
107
  text = preprocess(text)
108
  encoding = tokenizer(text=[text], truncation=True, padding=True, max_length=512, return_tensors="pt").to(device)
109
  if not sample:
@@ -129,7 +130,6 @@ input_text7 = "根据标题生成文章:标题:屈臣氏里的化妆品到
129
  input_text8 = "帮我对比几款GPU,列出详细参数对比,并且给出最终结论"
130
  input_list = [input_text0, input_text1, input_text2, input_text3, input_text4, input_text5, input_text6, input_text7, input_text8]
131
  for i, input_text in enumerate(input_list):
132
- input_text = "用户:" + input_text + "\n小元:"
133
  print(f"示例{i}".center(50, "="))
134
  output_text = answer(input_text)
135
  print(f"{input_text}{output_text}")
 
101
  def postprocess(text):
102
  return text.replace("\\n", "\n").replace("\\t", "\t").replace('%20',' ')
103
 
104
+ def answer(text, sample=True, top_p=1, temperature=0.7, context=""):
105
  '''sample:是否抽样。生成任务,可以设置为True;
106
  top_p:0-1之间,生成的内容越多样'''
107
+ text = f"{context}\n用户:{text}\n小元:"
108
  text = preprocess(text)
109
  encoding = tokenizer(text=[text], truncation=True, padding=True, max_length=512, return_tensors="pt").to(device)
110
  if not sample:
 
130
  input_text8 = "帮我对比几款GPU,列出详细参数对比,并且给出最终结论"
131
  input_list = [input_text0, input_text1, input_text2, input_text3, input_text4, input_text5, input_text6, input_text7, input_text8]
132
  for i, input_text in enumerate(input_list):
 
133
  print(f"示例{i}".center(50, "="))
134
  output_text = answer(input_text)
135
  print(f"{input_text}{output_text}")