import streamlit as st import torch from transformers import pipeline st.set_page_config(page_title="Vietnamese Legal Question Answering", page_icon="🧊", layout="centered", initial_sidebar_state="collapsed") @st.cache_data def load_model(model_path): device = 0 if torch.cuda.is_available() else -1 question_answerer = pipeline("question-answering", model=model_path, device=device) return question_answerer def get_answer(model, context, question): return model(context=context, question=question, max_answer_len=512) if 'model' not in st.session_state: st.session_state.model = load_model(model_path='./models/vi-mrc-large/model') st.markdown("