ck46's picture
added diversity to key sentence extraction
c7a8d6b
raw
history blame
1.06 kB
import streamlit as st
from paraphraser import get_key_sentences, ParaphraseModel
paraphraser = ParaphraseModel()
# Add a model selector to the sidebar:
#model = st.sidebar.selectbox(
# 'Select Model',
# ('T5-base', 'DistilT5-base', 'T5-small')
#)
top_n = st.sidebar.slider('Top_n', 1, 20, 5)
diversity = st.sidebar.slider('Diversity', 0.0, 1.0, 0.6)
top_k = st.sidebar.slider('Top_K', 100, 300, 168)
top_p = st.sidebar.slider('Top_P', 0.0, 1.0, 0.95)
st.header("Bullet-point Summarization")
#st.write(f'Model in use: {model}')
txt = st.text_area('Text to analyze', )
if len(txt) >= 1:
key_sentences = get_key_sentences(txt, top_n=top_n, diversity=('mmr', diversity))
sentences = []
for i in sorted(key_sentences):
sentences.append(key_sentences[i])
paraphrased_sentences = paraphraser(sentences, top_k=top_k, top_p=top_p, num_sequences=1)
else:
sentences = []
paraphrased_sentences = []
st.header('Extracted Key Sentences')
st.write(sentences)
st.header('Paraphrase results')
st.write(paraphrased_sentences)