def _test_pipeline_forward(self, task, example, quantized: bool = False): try: # test onnx forward nlp = pipeline(task, onnx=True, quantized=quantized) nlp(example) # test torch forward nlp = pipeline(task, onnx=False) assert isinstance(nlp.model, torch.nn.Module) nlp(example) except Exception as e: self.fail(e)
def test_zero_shot_classification_forward(self): sequence = "Who are you voting for in 2020?" candidate_labels = ["economics", "politics", "public health"] try: # test onnx forward nlp = pipeline("zero-shot-classification", onnx=True) nlp(sequence, candidate_labels) # test torch forward nlp = pipeline("zero-shot-classification", onnx=False) assert isinstance(nlp.model, torch.nn.Module) nlp(sequence, candidate_labels) except Exception as e: self.fail(e)
# print(response['slots']) # if intentName == 'GetTeam': # if slots['teamA'] == None: # continue # team = slots['teamA'] # elif intentName == 'GetDate': # if slots['date'] == None: # continue # date = slots['date'] # elif intentName == 'GetSeason': # if slots['season'] == None: # continue # season = slots['season'] # print(team, date, season) # print(get_context({ # 'date': date, # 'team': team, # 'season': season, # })) nlp_qa = pipeline('question-answering', onnx=True) context_text = "the match was played in the city of Hyderabad. the match took place inside Rajiv Gandhi International Stadium, Uppal. Royal Challengers Bangalore decided to field after winning the toss. Sunrisers Hyderabad emerged victorious. the team won by 35 runs. Yuvraj Singh took home the man of the match." question_text = "Where was match played" answer = nlp_qa(context=context_text, question=question_text) print("Answers is ::") print(answer)
def test_onnx_graph_creation(self): try: nlp = pipeline("feature-extraction", onnx=True) assert isinstance(nlp.onnx_model, InferenceSession) except Exception as e: self.fail(e)
def __init__(self): super(App, self).__init__() self.bot = Lexbot() self.qa = pipeline('question-answering', onnx=True)