Views
No views yet
{'score': 0.9667195081710815, 'start': 101, 'end': 105, 'answer': '1820'}1from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
2
3model_name = "MarcBrun/ixambert-finetuned-squad"
4
5# To get predictions
6context = "Florence Nightingale, known for being the founder of modern nursing, was born in Florence, Italy, in 1820"
7question = "When was Florence Nightingale born?"
8qa = pipeline("question-answering", model=model_name, tokenizer=model_name)
9pred = qa(question=question,context=context)
10
11# To load the model and tokenizer
12model = AutoModelForQuestionAnswering.from_pretrained(model_name)
13tokenizer = AutoTokenizer.from_pretrained(model_name)batch_size = 8
n_epochs = 3
learning_rate = 2e-5
optimizer = AdamW
lr_schedule = linear
max_seq_len = 384
doc_stride = 128