Spaces:
Runtime error
Runtime error
Update abstractive_summarization.py
Browse files
abstractive_summarization.py
CHANGED
@@ -7,24 +7,24 @@ model = AutoModelForSeq2SeqLM.from_pretrained("EE21/BART-ToSSimplify")
|
|
7 |
# Function to summarize using the fine-tuned BART model
|
8 |
def summarize_with_bart_ft(input_text):
|
9 |
inputs = tokenizer.encode("summarize: " + input_text, return_tensors="pt", max_length=1024, truncation=True)
|
10 |
-
summary_ids = model.generate(inputs, max_length=300, min_length=100, num_beams=
|
11 |
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
12 |
return summary
|
13 |
|
14 |
# Function to summarize using BART-large-cnn
|
15 |
def summarize_with_bart_cnn(input_text):
|
16 |
pipe = pipeline("summarization", model="facebook/bart-large-cnn")
|
17 |
-
summary = pipe(input_text, max_length=300, min_length=100, num_beams=
|
18 |
return summary
|
19 |
|
20 |
# Function to summarize using led-base-book-summary
|
21 |
def summarize_with_led(input_text):
|
22 |
pipe_led = pipeline("summarization", model="pszemraj/led-base-book-summary")
|
23 |
-
summary = pipe_led(input_text, max_length=300, min_length=100, num_beams=
|
24 |
return summary[0]['summary_text']
|
25 |
|
26 |
# Function to summarize using long-t5-tglobal-base-sci-simplify
|
27 |
def summarize_with_t5(input_text):
|
28 |
pipe_t5 = pipeline("summarization", model="pszemraj/long-t5-tglobal-base-sci-simplify")
|
29 |
-
summary = pipe_t5(input_text, max_length=300, min_length=100, num_beams=
|
30 |
return summary[0]['summary_text']
|
|
|
7 |
# Function to summarize using the fine-tuned BART model
|
8 |
def summarize_with_bart_ft(input_text):
|
9 |
inputs = tokenizer.encode("summarize: " + input_text, return_tensors="pt", max_length=1024, truncation=True)
|
10 |
+
summary_ids = model.generate(inputs, max_length=300, min_length=100, num_beams=2, early_stopping=False, length_penalty=1)
|
11 |
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
12 |
return summary
|
13 |
|
14 |
# Function to summarize using BART-large-cnn
|
15 |
def summarize_with_bart_cnn(input_text):
|
16 |
pipe = pipeline("summarization", model="facebook/bart-large-cnn")
|
17 |
+
summary = pipe(input_text, max_length=300, min_length=100, num_beams=2, early_stopping=False, length_penalty=1)
|
18 |
return summary
|
19 |
|
20 |
# Function to summarize using led-base-book-summary
|
21 |
def summarize_with_led(input_text):
|
22 |
pipe_led = pipeline("summarization", model="pszemraj/led-base-book-summary")
|
23 |
+
summary = pipe_led(input_text, max_length=300, min_length=100, num_beams=2, early_stopping=False, length_penalty=1)
|
24 |
return summary[0]['summary_text']
|
25 |
|
26 |
# Function to summarize using long-t5-tglobal-base-sci-simplify
|
27 |
def summarize_with_t5(input_text):
|
28 |
pipe_t5 = pipeline("summarization", model="pszemraj/long-t5-tglobal-base-sci-simplify")
|
29 |
+
summary = pipe_t5(input_text, max_length=300, min_length=100, num_beams=2, early_stopping=False, length_penalty=1)
|
30 |
return summary[0]['summary_text']
|