EE21 commited on
Commit
1b4d3f7
·
1 Parent(s): 13ecabc

Update abstractive_summarization.py

Browse files
Files changed (1) hide show
  1. abstractive_summarization.py +3 -3
abstractive_summarization.py CHANGED
@@ -9,14 +9,14 @@ pipe = pipeline("summarization", model="facebook/bart-large-cnn")
9
 
10
  # Define the abstractive summarization function (fine-tuned BART)
11
  def summarize_with_bart_ft(input_text):
12
- inputs = tokenizer.encode("summarize: " + input_text, return_tensors="pt", max_length=2048, truncation=True)
13
  summary_ids = model.generate(inputs, max_length=300, min_length=100, num_beams=1, early_stopping=False, length_penalty=1)
14
  summary = tokenizer.decode(summary_ids[0], skip_special_tokens=False)
15
  return summary
16
 
17
  # Define the abstractive summarization function (BART-large-cnn)
18
  def summarize_with_bart(input_text):
19
- inputs = tokenizer.encode("summarize: " + input_text, return_tensors="pt", max_length=2048, truncation=True)
20
- summary_ids = model.generate(inputs, max_length=300, min_length=100, num_beams=1, early_stopping=True, length_penalty=1)
21
  summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
22
  return summary
 
9
 
10
  # Define the abstractive summarization function (fine-tuned BART)
11
  def summarize_with_bart_ft(input_text):
12
+ inputs = tokenizer.encode("summarize: " + input_text, return_tensors="pt", max_length=1024, truncation=True)
13
  summary_ids = model.generate(inputs, max_length=300, min_length=100, num_beams=1, early_stopping=False, length_penalty=1)
14
  summary = tokenizer.decode(summary_ids[0], skip_special_tokens=False)
15
  return summary
16
 
17
  # Define the abstractive summarization function (BART-large-cnn)
18
  def summarize_with_bart(input_text):
19
+ inputs = tokenizer.encode("summarize: " + input_text, return_tensors="pt", max_length=1024, truncation=True)
20
+ summary_ids = model.generate(inputs, max_length=600, min_length=300, num_beams=1, early_stopping=True, length_penalty=1)
21
  summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
22
  return summary