PRNKPS commited on
Commit
4929642
·
1 Parent(s): 00fa884

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -14
app.py CHANGED
@@ -1,17 +1,15 @@
1
- import streamlit as st
2
- from transformers import pipeline
3
 
4
- classifier = pipeline("question-answering", model="deepset/roberta-base-squad2")
5
- def main():
6
- st.title("English to German")
7
 
8
- with st.form("text_field"):
9
- text = st.text_area('enter some english word:')
10
- # clicked==True only when the button is clicked
11
- clicked = st.form_submit_button("Submit")
12
- if clicked:
13
- results = classifier([text])
14
- st.json(results)
15
 
16
- if __name__ == "__main__":
17
- main()
 
 
1
+ from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
 
2
 
3
+ model_name = "deepset/roberta-base-squad2"
 
 
4
 
5
+ # a) Get predictions
6
+ nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)
7
+ QA_input = {
8
+ 'question': 'Why is model conversion important?',
9
+ 'context': 'The option to convert models between FARM and transformers gives freedom to the user and let people easily switch between frameworks.'
10
+ }
11
+ res = nlp(QA_input)
12
 
13
+ # b) Load model & tokenizer
14
+ model = AutoModelForQuestionAnswering.from_pretrained(model_name)
15
+ tokenizer = AutoTokenizer.from_pretrained(model_name)