deepset/roberta-base-squad2-distilled
156.7k
1---2language: en3license: mit4tags:5- exbert6datasets:7- squad_v28thumbnail: https://thumb.tildacdn.com/tild3433-3637-4830-a533-353833613061/-/resize/720x/-/format/webp/germanquad.jpg9model-index:10- name: deepset/roberta-base-squad2-distilled11 results:12 - task:13 type: question-answering14 name: Question Answering15 dataset:16 name: squad_v217 type: squad_v218 config: squad_v219 split: validation20 metrics:21 - type: exact_match22 value: 80.859323 name: Exact Match24 verified: true25 verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiMzVjNzkxNmNiNDkzNzdiYjJjZGM3ZTViMGJhOGM2ZjFmYjg1MjYxMDM2YzM5NWMwNDIyYzNlN2QwNGYyNDMzZSIsInZlcnNpb24iOjF9.Rgww8tf8D7nF2dh2U_DMrFzmp87k8s7RFibrDXSvQyA66PGWXwjlsd1552lzjHnNV5hvHUM1-h3PTuY_5p64BA26 - type: f127 value: 84.010428 name: F129 verified: true30 verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiNTAyZDViNWYzNjA4OWQ5MzgyYmQ2ZDlhNWRhMTIzYTYxYzViMmI4NWE4ZGU5MzVhZTAwNTRlZmRlNWUwMjI0ZSIsInZlcnNpb24iOjF9.Er21BNgJ3jJXLuZtpubTYq9wCwO1i_VLQFwS5ET0e4eAYVVj0aOA40I5FvP5pZac3LjkCnVacxzsFWGCYVmnDA31 - task:32 type: question-answering33 name: Question Answering34 dataset:35 name: squad36 type: squad37 config: plain_text38 split: validation39 metrics:40 - type: exact_match41 value: 86.22542 name: Exact Match43 - type: f144 value: 92.48345 name: F146 - task:47 type: question-answering48 name: Question Answering49 dataset:50 name: adversarial_qa51 type: adversarial_qa52 config: adversarialQA53 split: validation54 metrics:55 - type: exact_match56 value: 29.90057 name: Exact Match58 - type: f159 value: 41.18360 name: F161 - task:62 type: question-answering63 name: Question Answering64 dataset:65 name: squad_adversarial66 type: squad_adversarial67 config: AddOneSent68 split: validation69 metrics:70 - type: exact_match71 value: 79.07172 name: Exact Match73 - type: f174 value: 84.47275 name: F176 - task:77 type: question-answering78 name: Question Answering79 dataset:80 name: squadshifts amazon81 type: squadshifts82 config: amazon83 split: test84 metrics:85 - type: exact_match86 value: 70.73387 name: Exact Match88 - type: f189 value: 83.95890 name: F191 - task:92 type: question-answering93 name: Question Answering94 dataset:95 name: squadshifts new_wiki96 type: squadshifts97 config: new_wiki98 split: test99 metrics:100 - type: exact_match101 value: 82.011102 name: Exact Match103 - type: f1104 value: 91.092105 name: F1106 - task:107 type: question-answering108 name: Question Answering109 dataset:110 name: squadshifts nyt111 type: squadshifts112 config: nyt113 split: test114 metrics:115 - type: exact_match116 value: 84.203117 name: Exact Match118 - type: f1119 value: 91.521120 name: F1121 - task:122 type: question-answering123 name: Question Answering124 dataset:125 name: squadshifts reddit126 type: squadshifts127 config: reddit128 split: test129 metrics:130 - type: exact_match131 value: 72.029132 name: Exact Match133 - type: f1134 value: 83.454135 name: F1136---137 138# roberta-base distilled for Extractive QA 139 140## Overview141**Language model:** deepset/roberta-base-squad2-distilled 142**Language:** English 143**Training data:** SQuAD 2.0 training set 144**Eval data:** SQuAD 2.0 dev set 145**Code:** See [an example extractive QA pipeline built with Haystack](https://haystack.deepset.ai/tutorials/34_extractive_qa_pipeline) 146**Infrastructure**: 4x V100 GPU 147**Published**: Dec 8th, 2021148 149## Details150- haystack's distillation feature was used for training. deepset/roberta-large-squad2 was used as the teacher model.151 152## Hyperparameters153```154batch_size = 80155n_epochs = 4156max_seq_len = 384157learning_rate = 3e-5158lr_schedule = LinearWarmup159embeds_dropout_prob = 0.1160temperature = 1.5161distillation_loss_weight = 0.75162```163 164## Usage165 166### In Haystack167Haystack 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. 168To load and run the model with [Haystack](https://github.com/deepset-ai/haystack/):169```python170# After running pip install haystack-ai "transformers[torch,sentencepiece]"171 172from haystack import Document173from haystack.components.readers import ExtractiveReader174 175docs = [176 Document(content="Python is a popular programming language"),177 Document(content="python ist eine beliebte Programmiersprache"),178]179 180reader = ExtractiveReader(model="deepset/roberta-base-squad2-distilled")181reader.warm_up()182 183question = "What is a popular programming language?"184result = reader.run(query=question, documents=docs)185# {'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),...)]}186```187For 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).188 189### In Transformers190```python191from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline192 193model_name = "deepset/roberta-base-squad2-distilled"194 195# a) Get predictions196nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)197QA_input = {198 'question': 'Why is model conversion important?',199 'context': 'The option to convert models between FARM and transformers gives freedom to the user and let people easily switch between frameworks.'200}201res = nlp(QA_input)202 203# b) Load model & tokenizer204model = AutoModelForQuestionAnswering.from_pretrained(model_name)205tokenizer = AutoTokenizer.from_pretrained(model_name)206```207 208## Performance209```210"exact": 79.8366040596311211"f1": 83.916407079888212```213 214## Authors215**Timo Möller:** timo.moeller@deepset.ai 216**Julian Risch:** julian.risch@deepset.ai 217**Malte Pietsch:** malte.pietsch@deepset.ai 218**Michel Bartels:** michel.bartels@deepset.ai 219 220## About us221 222<div class="grid lg:grid-cols-2 gap-x-4 gap-y-3">223 <div class="w-full h-40 object-cover mb-2 rounded-lg flex items-center justify-center">224 <img alt="" src="https://raw.githubusercontent.com/deepset-ai/.github/main/deepset-logo-colored.png" class="w-40"/>225 </div>226 <div class="w-full h-40 object-cover mb-2 rounded-lg flex items-center justify-center">227 <img alt="" src="https://raw.githubusercontent.com/deepset-ai/.github/main/haystack-logo-colored.png" class="w-40"/>228 </div>229</div>230 231[deepset](http://deepset.ai/) is the company behind the production-ready open-source AI framework [Haystack](https://haystack.deepset.ai/).232 233Some of our other work: 234- [Distilled roberta-base-squad2 (aka "tinyroberta-squad2")](https://huggingface.co/deepset/tinyroberta-squad2)235- [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)236- [deepset Cloud](https://www.deepset.ai/deepset-cloud-product), [deepset Studio](https://www.deepset.ai/deepset-studio)237 238## Get in touch and join the Haystack community239 240<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>. 241 242We also have a <strong><a class="h-7" href="https://haystack.deepset.ai/community">Discord community open to everyone!</a></strong></p>243 244[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)245 246By the way: [we're hiring!](http://www.deepset.ai/jobs)