Chatop commited on
Commit
c4619e3
1 Parent(s): 4c1f6f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -12
app.py CHANGED
@@ -1,25 +1,33 @@
1
- # -*- coding: utf-8 -*-
2
- """Lab10_app.ipynb
 
 
3
 
4
- Automatically generated by Colaboratory.
 
 
5
 
6
- Original file is located at
7
- https://colab.research.google.com/drive/17s4mJEUqE6OCVbdAOw1ROMQOpf4NBAw1
8
- """
9
 
10
- import streamlit as st
11
- from transformers import pipeline
 
 
 
 
 
12
 
13
- classifier = pipeline("question-answering", model="deepset/roberta-base-squad2")
14
  def main():
15
  st.title("Question & Answering")
16
 
17
  with st.form("text_field"):
18
- text = st.text_area('Enter question:')
19
- # clicked==True only when the button is clicked
 
 
20
  clicked = st.form_submit_button("Submit")
21
  if clicked:
22
- results = classifier([text])
23
  st.json(results)
24
 
25
  if __name__ == "__main__":
 
1
+ import streamlit as st
2
+ from transformers.pipelines import pipeline
3
+ from transformers.modeling_auto import AutoModelForQuestionAnswering
4
+ from transformers.tokenization_auto import AutoTokenizer
5
 
6
+ # b) Load model & tokenizer
7
+ #model = AutoModelForQuestionAnswering.from_pretrained(model_name)
8
+ #tokenizer = AutoTokenizer.from_pretrained(model_name)
9
 
10
+ #classifier = pipeline("question-answering", model="deepset/roberta-base-squad2")
 
 
11
 
12
+ #model_name = "deepset/xlm-roberta-base-squad2"
13
+ #nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)
14
+ #QA_input = {
15
+ # 'question': 'Why is model conversion important?',
16
+ # 'context': 'The option to convert models between FARM and transformers gives freedom to the user and let people easily switch between frameworks.'
17
+ #}
18
+ #res = nlp(QA_input)
19
 
 
20
  def main():
21
  st.title("Question & Answering")
22
 
23
  with st.form("text_field"):
24
+ sentence_1= st.text_area('Enter Q1:')
25
+ sentence_2= st.text_area('Enter Q2:')
26
+ QA_input = {'question':sentence_1, 'context':sentence_2}
27
+ #clicked==True only when the button is clicked
28
  clicked = st.form_submit_button("Submit")
29
  if clicked:
30
+ results = nlp(QA_input)
31
  st.json(results)
32
 
33
  if __name__ == "__main__":