Views
No views yet
1from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
2
3model_name = "ilmariky/bert-base-finnish-cased-squad2-fi"
4
5# a) Get predictions
6nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)
7QA_input = {
8 'question': 'Mikä tämä on?',
9 'context': 'Tämä on testi.'
10}
11res = nlp(QA_input)
12
13# b) Load model & tokenizer
14model = AutoModelForQuestionAnswering.from_pretrained(model_name)
15tokenizer = AutoTokenizer.from_pretrained(model_name){
"exact": 55.53157042633567,
"f1": 61.869335312255835,
"total": 7412,
"HasAns_exact": 51.26503525508088,
"HasAns_f1": 61.006950090095565,
"HasAns_total": 4822,
"NoAns_exact": 63.47490347490348,
"NoAns_f1": 63.47490347490348,
"NoAns_total": 2590
}