Views
No views yet
seed=42
batch_size = 32
n_epochs = 5
base_LM_model = "google/electra-base-discriminator"
max_seq_len = 384
learning_rate = 1e-4
lr_schedule = LinearWarmup
warmup_proportion = 0.1
doc_stride=128
max_query_length=64"exact": 77.30144024256717,
"f1": 81.35438272008543,
"total": 11873,
"HasAns_exact": 74.34210526315789,
"HasAns_f1": 82.45961302894314,
"HasAns_total": 5928,
"NoAns_exact": 80.25231286795626,
"NoAns_f1": 80.25231286795626,
"NoAns_total": 59451# After running pip install haystack-ai "transformers[torch,sentencepiece]"
2
3from haystack import Document
4from haystack.components.readers import ExtractiveReader
5
6docs = [
7 Document(content="Python is a popular programming language"),
8 Document(content="python ist eine beliebte Programmiersprache"),
9]
10
11reader = ExtractiveReader(model="deepset/roberta-base-squad2")
12reader.warm_up()
13
14question = "What is a popular programming language?"
15result = reader.run(query=question, documents=docs)
16# {'answers': [ExtractedAnswer(query='What is a popular programming language?', score=0.5740374326705933, data='python', document=Document(id=..., content: '...'), context=None, document_offset=ExtractedAnswer.Span(start=0, end=6),...)]}1from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
2
3model_name = "deepset/roberta-base-squad2"
4
5# a) Get predictions
6nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)
7QA_input = {
8 'question': 'Why is model conversion important?',
9 'context': 'The option to convert models between FARM and transformers gives freedom to the user and let people easily switch between frameworks.'
10}
11res = nlp(QA_input)
12
13# b) Load model & tokenizer
14model = AutoModelForQuestionAnswering.from_pretrained(model_name)
15tokenizer = AutoTokenizer.from_pretrained(model_name)vaishali.pal [at] deepset.aibranden.chan [at] deepset.aitimo.moeller [at] deepset.aimalte.pietsch [at] deepset.aitanay.soni [at] deepset.ai
