GuysRGithub commited on
Commit
fd1accb
1 Parent(s): 2e81b54
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -22,6 +22,8 @@ map_words = {
22
  "Hi,": "",
23
  "Hello": "",
24
  "Hi": "",
 
 
25
  }
26
 
27
  word_remove_sentence = [
@@ -45,7 +47,7 @@ def generate_summary(question, model):
45
  input_ids = inputs.input_ids.to(model.device)
46
  attention_mask = inputs.attention_mask.to(model.device)
47
  outputs = model.generate(
48
- input_ids, attention_mask=attention_mask, max_new_tokens=4096, do_sample=True, num_beams=4, top_k=50, early_stopping=True, no_repeat_ngram_size=2, )
49
  output_str = tokenizer.batch_decode(outputs, skip_special_tokens=True)
50
  return outputs, output_str
51
 
@@ -144,14 +146,15 @@ def chat():
144
  def post_process(output):
145
 
146
  output = textwrap.fill(textwrap.dedent(output).strip(), width=120)
147
- lines = output.split("\.")
148
- for line in lines:
149
- for word in word_remove_sentence:
150
- if word in line.lower():
151
- lines.remove(line)
152
- break
 
153
 
154
- output = "\.".join(lines)
155
  for item in map_words.keys():
156
  output = re.sub(item, map_words[item], output, re.I)
157
 
 
22
  "Hi,": "",
23
  "Hello": "",
24
  "Hi": "",
25
+ "Ask A Doctor": "MedForum",
26
+ "H C M": "Med Forum"
27
  }
28
 
29
  word_remove_sentence = [
 
47
  input_ids = inputs.input_ids.to(model.device)
48
  attention_mask = inputs.attention_mask.to(model.device)
49
  outputs = model.generate(
50
+ input_ids, attention_mask=attention_mask, max_new_tokens=4096, do_sample=True, num_beams=4, top_k=50, early_stopping=True, no_repeat_ngram_size=2)
51
  output_str = tokenizer.batch_decode(outputs, skip_special_tokens=True)
52
  return outputs, output_str
53
 
 
146
  def post_process(output):
147
 
148
  output = textwrap.fill(textwrap.dedent(output).strip(), width=120)
149
+ # lines = output.split(".")
150
+ # print(lines)
151
+ # for line in lines:
152
+ # for word in word_remove_sentence:
153
+ # if word in line.lower():
154
+ # lines.remove(line)
155
+ # break
156
 
157
+ # output = "\.".join(lines)
158
  for item in map_words.keys():
159
  output = re.sub(item, map_words[item], output, re.I)
160