MendoBERT_QA / app.py
BlueRey's picture
Update app.py
62d9a56
raw
history blame
1.38 kB
import streamlit as st
from transformers import pipeline
model = pipeline("question-answering", model="/home/user/app/MendoBERT/", tokenizer="indolem/indobert-base-uncased")
basemodel = pipeline("question-answering", model="/home/user/app/IndoLEM/", tokenizer="indolem/indobert-base-uncased")
st.title(':blue[MendoBERT] - Question Answering')
if 'context' not in st.session_state:
st.session_state['options'] = ""
if 'question' not in st.session_state:
st.session_state['options'] = ""
def button1_callback():
st.session_state['context'] = "Konteks 1"
st.session_state['question'] = "Pertanyaan 1"
def button2_callback():
st.session_state['context'] = "Konteks 2"
st.session_state['question'] = "Pertanyaan 2"
st.caption('_Examples_')
st.button('Example 1', use_container_width=True, on_click = button1_callback)
st.button('Example 2', use_container_width=True, on_click = button2_callback)
context_placeholder = st.empty()
with context_placeholder:
context = st.text_area('Enter context: ', key = 'context')
question_placeholder = st.empty()
with question_placeholder:
question = st.text_area('Enter question: ', key = 'question')
if text:
st.subheader('MendoBERT')
st.write(model(context=context, question=question))
st.write("\n")
st.subheader('IndoLEM')
st.write(basemodel(context=context, question=question))