Update models/qa_model.py
Browse files- models/qa_model.py +2 -2
models/qa_model.py
CHANGED
@@ -4,7 +4,7 @@ import torch.nn as nn
|
|
4 |
from transformers import AutoModelForQuestionAnswering, pipeline
|
5 |
from features.text_utils import post_process_answer
|
6 |
from features.graph_utils import find_best_cluster
|
7 |
-
|
8 |
|
9 |
class QAEnsembleModel(nn.Module):
|
10 |
|
@@ -13,7 +13,7 @@ class QAEnsembleModel(nn.Module):
|
|
13 |
super(QAEnsembleModel, self).__init__()
|
14 |
self.nlps = []
|
15 |
for model_checkpoint in model_checkpoints:
|
16 |
-
model =
|
17 |
model.load_state_dict(torch.load(model_checkpoint, map_location=torch.device('cpu')), strict=False)
|
18 |
nlp = pipeline('question-answering', model=model,
|
19 |
tokenizer=model_name, device=device)
|
|
|
4 |
from transformers import AutoModelForQuestionAnswering, pipeline
|
5 |
from features.text_utils import post_process_answer
|
6 |
from features.graph_utils import find_best_cluster
|
7 |
+
from optimum.onnxruntime import ORTModelForQuestionAnswering
|
8 |
|
9 |
class QAEnsembleModel(nn.Module):
|
10 |
|
|
|
13 |
super(QAEnsembleModel, self).__init__()
|
14 |
self.nlps = []
|
15 |
for model_checkpoint in model_checkpoints:
|
16 |
+
model = ORTModelForQuestionAnswering.from_pretrained(model_name, from_transformers=True)#.half()
|
17 |
model.load_state_dict(torch.load(model_checkpoint, map_location=torch.device('cpu')), strict=False)
|
18 |
nlp = pipeline('question-answering', model=model,
|
19 |
tokenizer=model_name, device=device)
|