ClueAI commited on
Commit
f77baf0
1 Parent(s): 8326622

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -0
app.py CHANGED
@@ -9,7 +9,9 @@ model = T5ForConditionalGeneration.from_pretrained("ClueAI/ChatYuan-large-v2")
9
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
10
  model.to(device)
11
 
 
12
  def preprocess(text):
 
13
  text = text.replace("\n", "\\n").replace("\t", "\\t")
14
  return text
15
 
@@ -17,6 +19,7 @@ def postprocess(text):
17
  return text.replace("\\n", "\n").replace("\\t", "\t").replace('%20',' ')#.replace(" ", " ")
18
 
19
 
 
20
  generate_config = {'do_sample': True, 'top_p': 0.9, 'top_k': 50, 'temperature': 0.7,
21
  'num_beams': 1, 'max_length': 1024, 'min_length': 3, 'no_repeat_ngram_size': 5,
22
  'length_penalty': 0.6, 'return_dict_in_generate': True, 'output_scores': True}
 
9
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
10
  model.to(device)
11
 
12
+ base_info = "用户:你是谁?\n小元:我是元语智能公司研发的AI智能助手, 在不违反原则的情况下,我可以回答你的任何问题。"
13
  def preprocess(text):
14
+ text = f"{base_info}{text}"
15
  text = text.replace("\n", "\\n").replace("\t", "\\t")
16
  return text
17
 
 
19
  return text.replace("\\n", "\n").replace("\\t", "\t").replace('%20',' ')#.replace(" ", " ")
20
 
21
 
22
+
23
  generate_config = {'do_sample': True, 'top_p': 0.9, 'top_k': 50, 'temperature': 0.7,
24
  'num_beams': 1, 'max_length': 1024, 'min_length': 3, 'no_repeat_ngram_size': 5,
25
  'length_penalty': 0.6, 'return_dict_in_generate': True, 'output_scores': True}