README.md
6.0 KB · 146 lines · markdown Raw
1 ---
2 license: cc-by-4.0
3 datasets:
4 - squad_v2
5 model-index:
6 - name: deepset/xlm-roberta-base-squad2
7 results:
8 - task:
9 type: question-answering
10 name: Question Answering
11 dataset:
12 name: squad_v2
13 type: squad_v2
14 config: squad_v2
15 split: validation
16 metrics:
17 - type: exact_match
18 value: 74.0354
19 name: Exact Match
20 verified: true
21 verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiMWMxNWQ2ODJkNWIzZGQwOWI4OTZjYjU3ZDVjZGQzMjI5MzljNjliZTY4Mzk4YTk4OTMzZWYxZjUxYmZhYTBhZSIsInZlcnNpb24iOjF9.eEeFYYJ30BfJDd-JYfI1kjlxJrRF6OFtj2GnkTCOO4kqX31inFy8ptDWusVlLFsUphm4dNWfTKXC5e-gytLBDA
22 - type: f1
23 value: 77.1833
24 name: F1
25 verified: true
26 verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiMjg4MjNkOTA4Y2I5OGFlYTk1NWZjMWFlNjI5M2Y0NGZhMThhN2M4YmY2Y2RhZjcwYzU0MGNjN2RkZDljZmJmNiIsInZlcnNpb24iOjF9.TX42YMXpH4e0qu7cC4ARDlZWSkd55dwwyeyFXmOlXERNnEicDuFBCsy8WHLaqQCLUkzODJ22Hw4zhv81rwnlAQ
27 ---
28
29 # Multilingual XLM-RoBERTa base for Extractive QA on various languages
30
31 ## Overview
32 **Language model:** xlm-roberta-base
33 **Language:** Multilingual
34 **Downstream-task:** Extractive QA
35 **Training data:** SQuAD 2.0
36 **Eval data:** SQuAD 2.0 dev set - German MLQA - German XQuAD
37 **Code:** See [an example extractive QA pipeline built with Haystack](https://haystack.deepset.ai/tutorials/34_extractive_qa_pipeline)
38 **Infrastructure**: 4x Tesla v100
39
40 ## Hyperparameters
41
42 ```
43 batch_size = 22*4
44 n_epochs = 2
45 max_seq_len=256,
46 doc_stride=128,
47 learning_rate=2e-5,
48 ```
49
50 Corresponding experiment logs in mlflow: [link](https://public-mlflow.deepset.ai/#/experiments/2/runs/b25ec75e07614accb3f1ce03d43dbe08)
51
52
53 ## Usage
54
55 ### In Haystack
56 Haystack is an AI orchestration framework to build customizable, production-ready LLM applications. You can use this model in Haystack to do extractive question answering on documents.
57 To load and run the model with [Haystack](https://github.com/deepset-ai/haystack/):
58 ```python
59 # After running pip install haystack-ai "transformers[torch,sentencepiece]"
60
61 from haystack import Document
62 from haystack.components.readers import ExtractiveReader
63
64 docs = [
65 Document(content="Python is a popular programming language"),
66 Document(content="python ist eine beliebte Programmiersprache"),
67 ]
68
69 reader = ExtractiveReader(model="deepset/xlm-roberta-base-squad2")
70 reader.warm_up()
71
72 question = "What is a popular programming language?"
73 result = reader.run(query=question, documents=docs)
74 # {'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),...)]}
75 ```
76 For a complete example with an extractive question answering pipeline that scales over many documents, check out the [corresponding Haystack tutorial](https://haystack.deepset.ai/tutorials/34_extractive_qa_pipeline).
77
78 ### In Transformers
79 ```python
80 from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
81
82 model_name = "deepset/xlm-roberta-base-squad2"
83
84 # a) Get predictions
85 nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)
86 QA_input = {
87 'question': 'Why is model conversion important?',
88 'context': 'The option to convert models between FARM and transformers gives freedom to the user and let people easily switch between frameworks.'
89 }
90 res = nlp(QA_input)
91
92 # b) Load model & tokenizer
93 model = AutoModelForQuestionAnswering.from_pretrained(model_name)
94 tokenizer = AutoTokenizer.from_pretrained(model_name)
95 ```
96
97 ## Performance
98 Evaluated on the SQuAD 2.0 dev set with the [official eval script](https://worksheets.codalab.org/rest/bundles/0x6b567e1cf2e041ec80d7098f031c5c9e/contents/blob/).
99 ```
100 "exact": 73.91560683904657
101 "f1": 77.14103746689592
102 ```
103
104 Evaluated on German MLQA: test-context-de-question-de.json
105 "exact": 33.67279167589108
106 "f1": 44.34437105434842
107 "total": 4517
108
109 Evaluated on German XQuAD: xquad.de.json
110 "exact": 48.739495798319325
111 "f1": 62.552615701071495
112 "total": 1190
113
114 ## Authors
115 Branden Chan: `branden.chan [at] deepset.ai`
116 Timo Möller: `timo.moeller [at] deepset.ai`
117 Malte Pietsch: `malte.pietsch [at] deepset.ai`
118 Tanay Soni: `tanay.soni [at] deepset.ai`
119
120 ## About us
121
122 <div class="grid lg:grid-cols-2 gap-x-4 gap-y-3">
123 <div class="w-full h-40 object-cover mb-2 rounded-lg flex items-center justify-center">
124 <img alt="" src="https://raw.githubusercontent.com/deepset-ai/.github/main/deepset-logo-colored.png" class="w-40"/>
125 </div>
126 <div class="w-full h-40 object-cover mb-2 rounded-lg flex items-center justify-center">
127 <img alt="" src="https://raw.githubusercontent.com/deepset-ai/.github/main/haystack-logo-colored.png" class="w-40"/>
128 </div>
129 </div>
130
131 [deepset](http://deepset.ai/) is the company behind the production-ready open-source AI framework [Haystack](https://haystack.deepset.ai/).
132
133 Some of our other work:
134 - [Distilled roberta-base-squad2 (aka "tinyroberta-squad2")](https://huggingface.co/deepset/tinyroberta-squad2)
135 - [German BERT](https://deepset.ai/german-bert), [GermanQuAD and GermanDPR](https://deepset.ai/germanquad), [German embedding model](https://huggingface.co/mixedbread-ai/deepset-mxbai-embed-de-large-v1)
136 - [deepset Cloud](https://www.deepset.ai/deepset-cloud-product), [deepset Studio](https://www.deepset.ai/deepset-studio)
137
138 ## Get in touch and join the Haystack community
139
140 <p>For more info on Haystack, visit our <strong><a href="https://github.com/deepset-ai/haystack">GitHub</a></strong> repo and <strong><a href="https://docs.haystack.deepset.ai">Documentation</a></strong>.
141
142 We also have a <strong><a class="h-7" href="https://haystack.deepset.ai/community">Discord community open to everyone!</a></strong></p>
143
144 [Twitter](https://twitter.com/Haystack_AI) | [LinkedIn](https://www.linkedin.com/company/deepset-ai/) | [Discord](https://haystack.deepset.ai/community) | [GitHub Discussions](https://github.com/deepset-ai/haystack/discussions) | [Website](https://haystack.deepset.ai/) | [YouTube](https://www.youtube.com/@deepset_ai)
145
146 By the way: [we're hiring!](http://www.deepset.ai/jobs)