File size: 1,016 Bytes
8562f6b
e9d3f14
 
 
 
 
 
8562f6b
4458a4d
e9d3f14
 
 
 
 
 
 
 
4458a4d
 
 
 
 
 
 
e9d3f14
 
 
 
 
 
4458a4d
 
e9d3f14
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
39
import streamlit as st
from qg_pipeline import Pipeline

## Load NLTK
import nltk
nltk.download('punkt')


# Add a model selector to the sidebar
q_model = st.sidebar.selectbox(
    'Select Question Generation Model',
    ('valhalla/t5-small-qg-hl', 'valhalla/t5-base-qg-hl', 'ck46/t5-base-squad-qa-qg', 'ck46/t5-small-squad-qa-qg', 'ck46/t5-base-hotpot-qa-qg', 'ck46/t5-small-hotpot-qa-qg')
)

a_model = st.sidebar.selectbox(
    'Select Answer Extraction Model',
    ('valhalla/t5-small-qa-qg-hl', 'valhalla/t5-base-qa-qg-hl', 'ck46/t5-base-squad-qa-qg', 'ck46/t5-small-squad-qa-qg', 'ck46/t5-base-hotpot-qa-qg', 'ck46/t5-small-hotpot-qa-qg')
)

st.header('Question-Answer Generation')
st.write(f'Model in use: {model}')

txt = st.text_area('Text for context')

pipeline = Pipeline(
    q_model=q_model,
    q_tokenizer=q_model,
    a_model=a_model,
    q_tokenizer=a_model
)

if len(txt) >= 1:
    autocards = pipeline(txt)
else:
    autocards = []

st.header('Generated question and answers')
st.write(autocards)