nikhedward commited on
Commit
2e0f07c
1 Parent(s): fcc1ca4

Added topk and topp

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -23,7 +23,9 @@ The ship was on early Wednesday ordered to return to the Kai Tak Cruise Terminal
23
  sample_texts = [[text_1 ], [text_2]]
24
 
25
  desc = """
26
- <p style='text-align: center; color: #FF7F50'>This is an abstractive text summarizer app using fine-tuned bart-large-cnn model. The abstractive approach involves rephrasing the complete document while capturing the complete meaning of the document. This type of summarization provides more human-like summary. Note: For faster summaries input smaller texts. Sample Text input is provided for you at the bottom!</p>
 
 
27
  """
28
 
29
 
@@ -35,7 +37,7 @@ model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
35
  def summarize(inp):
36
  inp = inp.replace('\n','')
37
  inp = tokenizer.encode(inp, return_tensors='pt', max_length=1024)
38
- summary_ids = model.generate(inp, num_beams=4, max_length=150, early_stopping=True)
39
  summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
40
  return summary
41
 
 
23
  sample_texts = [[text_1 ], [text_2]]
24
 
25
  desc = """
26
+ <p style='text-align: center; color: #FF7F50'>This is an abstractive text summarizer app using fine-tuned bart-large-cnn model. The abstractive approach involves rephrasing the complete document while capturing the complete meaning of the document. This type of summarization provides more human-like summary.
27
+ <p style='text-align: center; color: #FF7F50'> Note: For faster summaries input smaller texts.</'p>
28
+ <p style='text-align: center; color: #FF7F50'>Sample text inputs are provided at the bottom!</p>
29
  """
30
 
31
 
 
37
  def summarize(inp):
38
  inp = inp.replace('\n','')
39
  inp = tokenizer.encode(inp, return_tensors='pt', max_length=1024)
40
+ summary_ids = model.generate(inp, num_beams=4, max_length=150, early_stopping=True, do_sample=True, top_k=50, top_p=0.95)
41
  summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
42
  return summary
43