File size: 767 Bytes
e00c216
 
 
fb27f9f
 
e87d4c5
fb27f9f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import streamlit as st
from transformers import pipeline, AutoModelForSeq2SeqLM, AutoTokenizer


# Load model and tokenizer
model_name = "t5_qa_model.pt"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
qa_pipeline = pipeline("text2text-generation", model=model, tokenizer=tokenizer)

# Streamlit app
st.title("History QA with T5 Model")
st.write("Enter the historical context and your question below:")

context = st.text_area("Context", height=200)
question = st.text_input("Question")

if st.button("Get Answer"):
    input_text = f"question: {question} context: {context}"
    result = qa_pipeline(input_text)
    answer = result[0]['generated_text']
    st.write("**Answer:**")
    st.write(answer)