Abdulrhman37 commited on
Commit
10ed75c
·
1 Parent(s): 75433c3

token length modified

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -4,9 +4,11 @@ from transformers import pipeline
4
  # Load the summarization pipeline
5
  summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
6
 
7
- # Define the summarization function
8
- def summarize_text(article[:1024]):
9
- summary = summarizer(article, max_length=130, min_length=30, do_sample=False)
 
 
10
  return summary[0]['summary_text']
11
 
12
  # Create the Gradio interface
 
4
  # Load the summarization pipeline
5
  summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
6
 
7
+ # Define the summarization function with truncation
8
+ def summarize_text(article):
9
+ # Truncate the input to 1024 tokens
10
+ truncated_article = article[:1024]
11
+ summary = summarizer(truncated_article, max_length=130, min_length=30, do_sample=False)
12
  return summary[0]['summary_text']
13
 
14
  # Create the Gradio interface