please provide a example for load model use

#21
by kaiwangfrancais - opened

could anyone provide a example for use afer load model:

from transformers import AutoModelForQuestionAnswering, AutoTokenizer
model = AutoModelForQuestionAnswering.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)

folling code ...?

i tried to input a text directly for prediciton , but some err occured.
thanks a lot

No, just do this:

from transformers import  pipeline
model_name = "deepset/roberta-base-squad2"
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 FARM and transformers gives freedom to the user and let people easily switch between frameworks.'
}
res = nlp(QA_input)
print(res)

Sign up or log in to comment