File size: 763 Bytes
59b87ad 8562f6b e9d3f14 59b87ad 8562f6b 4458a4d a1e2c6a 4458a4d 04ceae1 4458a4d e9d3f14 d542246 e9d3f14 4458a4d 59b87ad 4458a4d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
import re
import streamlit as st
from qg_pipeline import Pipeline
## Load NLTK
import nltk
nltk.download('punkt')
def preprocess_text(text):
text = re.sub('\[[0-9]+\]', '', text)
text = re.sub('[\s]{2,}', ' ', text)
text = text.strip()
return text
# Add a model selector to the sidebar
q_model = 'ck46/t5-base-hotpot-qa-qg'
a_model = 'ck46/t5-base-hotpot-qa-qg'
st.header('Question-Answer Generation')
st.write(f'Model: {q_model}')
txt = st.text_area('Text for context')
pipeline = Pipeline(
q_model=q_model,
q_tokenizer=q_model,
a_model=a_model,
a_tokenizer=a_model
)
if len(txt) >= 1:
autocards = pipeline(preprocess_text(txt))
else:
autocards = []
st.header('Generated question and answers')
st.write(autocards)
|