varun500 commited on
Commit
e556fdd
1 Parent(s): c6bbd5d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline, AutoTokenizer, AutoModelForQuestionAnswering
3
+
4
+ # Load Flan Alpaca Large model
5
+ model_name = "declare-lab/flan-alpaca-base"
6
+ model = AutoModelForQuestionAnswering.from_pretrained(model_name)
7
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
8
+ qa_pipeline = pipeline("question-answering", model=model, tokenizer=tokenizer)
9
+
10
+ def main():
11
+ # Set app title
12
+ st.title("Flan Alpaca Large Model")
13
+
14
+ # Create input for user's question
15
+ question = st.text_input("Enter your question here:")
16
+
17
+ # Create button to submit question
18
+ if st.button("Submit"):
19
+ # Generate answer using Flan Alpaca Large model
20
+ answer = qa_pipeline(question=question, context="")["answer"]
21
+ # Display answer in output box
22
+ st.write("Answer: ", answer)
23
+
24
+ if __name__ == "__main__":
25
+ main()