sdhanabal1 commited on
Commit
90f2ef6
1 Parent(s): 0b264ed

Update to correct model pipeline

Browse files
Files changed (1) hide show
  1. app.py +23 -16
app.py CHANGED
@@ -1,15 +1,14 @@
1
- from textwrap import wrap
2
-
3
  from transformers import pipeline
4
  import streamlit as st
5
 
6
- st.markdown('# Terms and conditions abstractive summarization model :pencil:')
7
- st.write('This app summarizes the provided terms and conditions. '
8
- 'Terms and conditions Summarization model is based on sshleifer/distilbart-cnn-6-6')
9
 
10
  st.markdown("""
11
  To use this:
12
- - Copy terms and conditions and hit 'Summarize':point_down:""")
13
 
14
 
15
  @st.cache(allow_output_mutation=True,
@@ -18,7 +17,7 @@ To use this:
18
  def load_model():
19
  with st.spinner('Please wait for the model to load...'):
20
  terms_and_conditions_pipeline = pipeline(
21
- 'text2text-generation',
22
  model='ml6team/distilbart-tos-summarizer-tosdr',
23
  tokenizer='ml6team/distilbart-tos-summarizer-tosdr'
24
  )
@@ -30,20 +29,28 @@ tc_pipeline = load_model()
30
  if 'text' not in st.session_state:
31
  st.session_state['text'] = ""
32
 
33
- left_area, right_area = st.columns(2)
34
-
35
- left_area.header("Input")
36
- form = left_area.form(key='terms-and-conditions')
37
  placeholder = form.empty()
38
  placeholder.empty()
39
- tc_text = placeholder.text_area(value=st.session_state.text, label='Terms and conditions text:', key='tc_text')
 
 
 
 
 
 
40
  submit_button = form.form_submit_button(label='Summarize')
41
 
42
- right_area.header("Output")
43
 
44
  if submit_button:
45
  base_text = st.session_state.tc_text
46
- output_text = " ".join([result['generated_text'] for result in tc_pipeline(base_text)])
47
- right_area.markdown('#####')
48
- right_area.text_area(value=output_text, label="Summary:")
 
 
 
 
49
 
 
1
+ from textwrap import wrap
 
2
  from transformers import pipeline
3
  import streamlit as st
4
 
5
+ st.markdown('# Terms & conditions abstractive summarization model :pencil:')
6
+ st.write('This app summarizes the provided terms & conditions.')
7
+ st.write('Information about the model :point_right: https://huggingface.co/ml6team/distilbart-tos-summarizer-tosdr')
8
 
9
  st.markdown("""
10
  To use this:
11
+ - Copy terms & conditions and hit 'Summarize':point_down:""")
12
 
13
 
14
  @st.cache(allow_output_mutation=True,
 
17
  def load_model():
18
  with st.spinner('Please wait for the model to load...'):
19
  terms_and_conditions_pipeline = pipeline(
20
+ task='summarization',
21
  model='ml6team/distilbart-tos-summarizer-tosdr',
22
  tokenizer='ml6team/distilbart-tos-summarizer-tosdr'
23
  )
 
29
  if 'text' not in st.session_state:
30
  st.session_state['text'] = ""
31
 
32
+ st.header("Input")
33
+ form = st.form(key='terms-and-conditions')
 
 
34
  placeholder = form.empty()
35
  placeholder.empty()
36
+ tc_text = placeholder.text_area(
37
+ value=st.session_state.text,
38
+ label='Terms & conditions text:',
39
+ key='tc_text',
40
+ height=240
41
+
42
+ )
43
  submit_button = form.form_submit_button(label='Summarize')
44
 
45
+ st.header("Output")
46
 
47
  if submit_button:
48
  base_text = st.session_state.tc_text
49
+ output_text = " ".join([result['summary_text'] for result in tc_pipeline(wrap(base_text, 2048))])
50
+ st.markdown('#####')
51
+ st.text_area(
52
+ value=output_text,
53
+ label="Summary",
54
+ height=240
55
+ )
56