Views
No views yet
1from transformers import AutoTokenizer, AutoModelForQuestionAnswering
2from transformers import pipeline
3
4
5model_name = "epatyukova/matscibert-polymer-extractive-QA"
6
7model = AutoModelForQuestionAnswering.from_pretrained(model_name)
8tokenizer = AutoTokenizer.from_pretrained(model_name)
9
10qa = pipeline(
11 "question-answering",
12 model=model,
13 tokenizer=tokenizer,
14 device="mps" # or -1 for CPU
15)
16
17question, context = "What polymerisation method was used for synthesis?", "The polyester was synthesized using polycondensation in the melt from the mixture of monomers quinoline-2,4- dicarboxylic acid and 1,2-Propanediol."
18test={'question': question,'context': context}
19
20qa(test)