from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline

model_name = "recobo/chemical-bert-uncased-squad2"

# a) Get predictions
nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)
QA_input = {
    'question': 'Why is model conversion important?',
    'context': 'The option to convert models between pytorch and transformers gives freedom to the user and let people easily switch between frameworks.'
}
res = nlp(QA_input)

# b) Load model & tokenizer
model = AutoModelForQuestionAnswering.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
Downloads last month
14
Hosted inference API
Question Answering
Examples
Examples
This model can be loaded on the Inference API on-demand.