Nikhil0987 commited on
Commit
6643d01
1 Parent(s): 341f21a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)