Views
No views yet
1from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
2model_name = "yirenl2/plm_qa"
3# a) Get predictions
4nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)
5QA_input = {
6 'question': 'What is the location of the incident?',
7 'context': 'I was attacked by someone in front of the bus station.'
8}
9res = nlp(QA_input)
10# b) Load model & tokenizer
11model = AutoModelForQuestionAnswering.from_pretrained(model_name)
12tokenizer = AutoTokenizer.from_pretrained(model_name)