Christian Koch commited on
Commit
0177922
1 Parent(s): e00aee9

fill in the gap, summarization

Browse files
Files changed (2) hide show
  1. app.py +59 -24
  2. requirements.txt +4 -2
app.py CHANGED
@@ -1,32 +1,67 @@
1
  import streamlit as st
2
- from transformers import pipeline
 
 
 
 
 
3
 
4
  st.title('Question Generator by Eddevs')
5
 
6
- left_column, right_column = st.columns(2)
7
- left_column.selectbox('Type', ['Question Generator', 'Paraphrasing'])
8
- right_column.selectbox('Question Generator', ['T5', 'GPT Neo-X'])
9
-
10
- input = st.text_area("Input Text")
11
-
12
- def summarize(text):
13
- # Refer to https://huggingface.co/docs/transformers/v4.18.0/en/main_classes/pipelines#transformers.SummarizationPipeline
14
- # for further information about configuration.
15
- summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
16
- # Refer to https://huggingface.co/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig
17
- # for further configuration of of the
18
- output: list = summarizer(
19
- text,
20
- max_length=130,
21
- min_length=30,
22
- do_sample=False)
23
- return output
24
- #return output[0]['summary_text']
25
-
26
- if st.button('Generate'):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  # st.write(input)
28
- st.write(summarize(input))
29
- st.success("We have generated 105 Questions for you")
30
  # st.snow()
31
  ##else:
32
  ##nothing here
 
 
 
1
  import streamlit as st
2
+ from transformers import pipeline, PegasusForConditionalGeneration, PegasusTokenizer
3
+ from fill_in_summary import FillInSummary
4
+
5
+ def paraphrase(text):
6
+ return text
7
+
8
 
9
  st.title('Question Generator by Eddevs')
10
 
11
+ select = st.selectbox('Type', ['Question Generator', 'Paraphrasing', 'Summarization', 'Fill in the gap'])
12
+
13
+ if select == "Summarization":
14
+ with st.form("summarization"):
15
+ # left_column, right_column = st.columns(2)
16
+ # left_column.selectbox('Type', ['Question Generator', 'Paraphrasing'])
17
+ st.selectbox('Model', ['T5', 'GPT Neo-X'])
18
+
19
+ input = st.text_area("Input Text")
20
+
21
+ submitted = st.form_submit_button("Generate")
22
+
23
+ if submitted:
24
+ st.write(FillInSummary().summarize(input))
25
+
26
+
27
+ if select == "Fill in the gap":
28
+ with st.form("summarization"):
29
+ # left_column, right_column = st.columns(2)
30
+ # left_column.selectbox('Type', ['Question Generator', 'Paraphrasing'])
31
+ st.selectbox('Model', ['T5', 'GPT Neo-X'])
32
+
33
+ input = st.text_area("Input Text")
34
+
35
+ submitted = st.form_submit_button("Generate")
36
+
37
+ if submitted:
38
+ fill = FillInSummary()
39
+ summarized = fill.summarize(input)
40
+ st.write(fill.blank_ne_out(summarized))
41
+
42
+
43
+ if select == "Paraphrasing":
44
+ with st.form("paraphrasing"):
45
+ # left_column, right_column = st.columns(2)
46
+ # left_column.selectbox('Type', ['Question Generator', 'Paraphrasing'])
47
+ st.selectbox('Model', ['T5', 'GPT Neo-X'])
48
+
49
+ input = st.text_area("Input Text")
50
+
51
+ submitted = st.form_submit_button("Generate")
52
+
53
+ if submitted:
54
+ st.write(paraphrase(input))
55
+
56
+
57
+
58
+
59
+
60
+ #if st.button('Generate'):
61
  # st.write(input)
62
+ #st.success("We have generated 105 Questions for you")
 
63
  # st.snow()
64
  ##else:
65
  ##nothing here
66
+
67
+
requirements.txt CHANGED
@@ -1,3 +1,5 @@
1
- transformers
2
  torch
3
- tensorflow
 
 
 
1
+ transformers~=4.18.0
2
  torch
3
+ tensorflow
4
+ streamlit~=1.8.1
5
+ sentencepiece==0.1.96