[51873b]: / docproduct / inference_question_to_topk.py

Download this file

17 lines (13 with data), 686 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
from docproduct.predictor import RetreiveQADoc
pretrained_path = 'pubmed_pmc_470k/'
ffn_weight_file = None
bert_ffn_weight_file = 'models/bertffn_crossentropy/bertffn'
embedding_file = 'qa_embeddings/bertffn_crossentropy.pkl'
doc = RetreiveQADoc(pretrained_path=pretrained_path,
ffn_weight_file=None,
bert_ffn_weight_file=bert_ffn_weight_file,
embedding_file=embedding_file)
print(doc.predict('my eyes hurts and i have a headache.',
search_by='answer', topk=5, answer_only=True))
print(doc.predict('my eyes hurts and i have a headache.',
search_by='question', topk=5, answer_only=True))