nickmuchi commited on
Commit
7483419
1 Parent(s): 6a43aa5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -142,13 +142,16 @@ model_type = st.sidebar.selectbox(
142
  "Model type", options=["Facebook-Bart", "Sshleifer-DistilBart"]
143
  )
144
 
 
 
 
145
  st.markdown(
146
  "Model Source: [Facebook-Bart-large-CNN](https://huggingface.co/facebook/bart-large-cnn) and [Sshleifer-distilbart-cnn-12-6](https://huggingface.co/sshleifer/distilbart-cnn-12-6)"
147
  )
148
 
149
  st.markdown(
150
  """The app supports extractive summarization which aims to identify the salient information that is then extracted and grouped together to form a concise summary.
151
- For documents or text that is more than 500 words long, the app will divide the text into chunks and summarize each chunk.
152
  There are two models available to choose from:""")
153
 
154
  st.markdown("""
@@ -216,7 +219,7 @@ if summarize:
216
  text="Loading Facebook-Bart Model and Extracting summary. This might take a few seconds depending on the length of your text..."
217
  ):
218
  summarizer_model = facebook_model()
219
- summarized_text = summarizer_model(text_to_summarize, max_length=100, min_length=30)
220
  summarized_text = ' '.join([summ['summary_text'] for summ in summarized_text])
221
 
222
  elif model_type == "Sshleifer-DistilBart":
@@ -229,7 +232,7 @@ if summarize:
229
  text="Loading Sshleifer-DistilBart Model and Extracting summary. This might take a few seconds depending on the length of your text..."
230
  ):
231
  summarizer_model = schleifer_model()
232
- summarized_text = summarizer_model(text_to_summarize, max_length=100, min_length=30)
233
  summarized_text = ' '.join([summ['summary_text'] for summ in summarized_text])
234
 
235
  # final summarized output
 
142
  "Model type", options=["Facebook-Bart", "Sshleifer-DistilBart"]
143
  )
144
 
145
+ max_len= st.sidebar.slider("Maximum length of the summarized text, if the total text length is greater than 500 tokens the text will be divided into chunks of 500 and the max length represents the length of each chunk",min_value=100,max_value=500)
146
+ min_len= st.sidebar.slider("Minimum length of the summarized text",min_value=30)
147
+
148
  st.markdown(
149
  "Model Source: [Facebook-Bart-large-CNN](https://huggingface.co/facebook/bart-large-cnn) and [Sshleifer-distilbart-cnn-12-6](https://huggingface.co/sshleifer/distilbart-cnn-12-6)"
150
  )
151
 
152
  st.markdown(
153
  """The app supports extractive summarization which aims to identify the salient information that is then extracted and grouped together to form a concise summary.
154
+ For documents or text that is more than 500 words long, the app will divide the text into chunks and summarize each chunk. Please note when using the sidebar slider, those values represent the min/max text length per chunk of text to be summarized. If your article to be summarized is 1000 words, it will be divided into two chunks of 500 words first then the default max length of 100 words is applied per chunk, resulting in a summarized text with 200 words maximum.
155
  There are two models available to choose from:""")
156
 
157
  st.markdown("""
 
219
  text="Loading Facebook-Bart Model and Extracting summary. This might take a few seconds depending on the length of your text..."
220
  ):
221
  summarizer_model = facebook_model()
222
+ summarized_text = summarizer_model(text_to_summarize, max_length=max_len, min_length=min_len)
223
  summarized_text = ' '.join([summ['summary_text'] for summ in summarized_text])
224
 
225
  elif model_type == "Sshleifer-DistilBart":
 
232
  text="Loading Sshleifer-DistilBart Model and Extracting summary. This might take a few seconds depending on the length of your text..."
233
  ):
234
  summarizer_model = schleifer_model()
235
+ summarized_text = summarizer_model(text_to_summarize, max_length=max_len, min_length=min_len)
236
  summarized_text = ' '.join([summ['summary_text'] for summ in summarized_text])
237
 
238
  # final summarized output