README.md
| 1 | --- |
| 2 | language: en |
| 3 | license: cc-by-4.0 |
| 4 | tags: |
| 5 | - deberta |
| 6 | - deberta-v3 |
| 7 | datasets: |
| 8 | - squad_v2 |
| 9 | base_model: microsoft/deberta-v3-base |
| 10 | model-index: |
| 11 | - name: deepset/deberta-v3-base-squad2 |
| 12 | results: |
| 13 | - task: |
| 14 | type: question-answering |
| 15 | name: Question Answering |
| 16 | dataset: |
| 17 | name: squad_v2 |
| 18 | type: squad_v2 |
| 19 | config: squad_v2 |
| 20 | split: validation |
| 21 | metrics: |
| 22 | - type: exact_match |
| 23 | value: 83.8248 |
| 24 | name: Exact Match |
| 25 | verified: true |
| 26 | verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiY2IyZTEyYzNlOTAwZmFlNWRiZTdiNzQzMTUyM2FmZTQ3ZWQwNWZmMzc2ZDVhYWYyMzkxOTUyMGNlMWY0M2E5MiIsInZlcnNpb24iOjF9.y8KvfefMLI977BYun0X1rAq5qudmezW_UJe9mh6sYBoiWaBosDO5TRnEGR1BHzdxmv2EgPK_PSomtZvb043jBQ |
| 27 | - type: f1 |
| 28 | value: 87.41 |
| 29 | name: F1 |
| 30 | verified: true |
| 31 | verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiOWVhNjAwM2Q5N2Y3MGU4ZWY3N2Y0MmNjYWYwYmQzNTdiYWExODhkYmQ1YjIwM2I1ODEzNWIxZDI1ZWQ1YWRjNSIsInZlcnNpb24iOjF9.Jk0v1ZheLRFz6k9iNAgCMMZtPYj5eVwUCku4E76wRYc-jHPmiUuxvNiNkn6NW-jkBD8bJGMqDSjJyVpVMn9pBA |
| 32 | - task: |
| 33 | type: question-answering |
| 34 | name: Question Answering |
| 35 | dataset: |
| 36 | name: squad |
| 37 | type: squad |
| 38 | config: plain_text |
| 39 | split: validation |
| 40 | metrics: |
| 41 | - type: exact_match |
| 42 | value: 84.9678 |
| 43 | name: Exact Match |
| 44 | verified: true |
| 45 | verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiOWUxYTg4MzU3YTdmMDRmMGM0NjFjMTcwNGM3YzljM2RkMTc1ZGNhMDQwMTgwNGI0ZDE4ZGMxZTE3YjY5YzQ0ZiIsInZlcnNpb24iOjF9.KKaJ1UtikNe2g6T8XhLoWNtL9X4dHHyl_O4VZ5LreBT9nXneGc21lI1AW3n8KXTFGemzRpRMvmCDyKVDHucdDQ |
| 46 | - type: f1 |
| 47 | value: 92.2777 |
| 48 | name: F1 |
| 49 | verified: true |
| 50 | verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiNDU0ZTQwMzg4ZDY1ZWYxOGIxMzY2ODljZTBkMTNlYjA0ODBjNjcxNTg3ZDliYWU1YTdkYTM2NTIxOTg1MGM4OCIsInZlcnNpb24iOjF9.8VHg1BXx6gLw_K7MUK2QSE80Y9guiVR8n8K8nX4laGsLibxv5u_yDv9F3ahbUa1eZG_bbidl93TY2qFUiYHtAQ |
| 51 | - task: |
| 52 | type: question-answering |
| 53 | name: Question Answering |
| 54 | dataset: |
| 55 | name: adversarial_qa |
| 56 | type: adversarial_qa |
| 57 | config: adversarialQA |
| 58 | split: validation |
| 59 | metrics: |
| 60 | - type: exact_match |
| 61 | value: 30.733 |
| 62 | name: Exact Match |
| 63 | - type: f1 |
| 64 | value: 44.099 |
| 65 | name: F1 |
| 66 | - task: |
| 67 | type: question-answering |
| 68 | name: Question Answering |
| 69 | dataset: |
| 70 | name: squad_adversarial |
| 71 | type: squad_adversarial |
| 72 | config: AddOneSent |
| 73 | split: validation |
| 74 | metrics: |
| 75 | - type: exact_match |
| 76 | value: 79.295 |
| 77 | name: Exact Match |
| 78 | - type: f1 |
| 79 | value: 86.609 |
| 80 | name: F1 |
| 81 | - task: |
| 82 | type: question-answering |
| 83 | name: Question Answering |
| 84 | dataset: |
| 85 | name: squadshifts amazon |
| 86 | type: squadshifts |
| 87 | config: amazon |
| 88 | split: test |
| 89 | metrics: |
| 90 | - type: exact_match |
| 91 | value: 68.680 |
| 92 | name: Exact Match |
| 93 | - type: f1 |
| 94 | value: 83.832 |
| 95 | name: F1 |
| 96 | - task: |
| 97 | type: question-answering |
| 98 | name: Question Answering |
| 99 | dataset: |
| 100 | name: squadshifts new_wiki |
| 101 | type: squadshifts |
| 102 | config: new_wiki |
| 103 | split: test |
| 104 | metrics: |
| 105 | - type: exact_match |
| 106 | value: 80.171 |
| 107 | name: Exact Match |
| 108 | - type: f1 |
| 109 | value: 90.452 |
| 110 | name: F1 |
| 111 | - task: |
| 112 | type: question-answering |
| 113 | name: Question Answering |
| 114 | dataset: |
| 115 | name: squadshifts nyt |
| 116 | type: squadshifts |
| 117 | config: nyt |
| 118 | split: test |
| 119 | metrics: |
| 120 | - type: exact_match |
| 121 | value: 81.570 |
| 122 | name: Exact Match |
| 123 | - type: f1 |
| 124 | value: 90.644 |
| 125 | name: F1 |
| 126 | - task: |
| 127 | type: question-answering |
| 128 | name: Question Answering |
| 129 | dataset: |
| 130 | name: squadshifts reddit |
| 131 | type: squadshifts |
| 132 | config: reddit |
| 133 | split: test |
| 134 | metrics: |
| 135 | - type: exact_match |
| 136 | value: 66.990 |
| 137 | name: Exact Match |
| 138 | - type: f1 |
| 139 | value: 80.231 |
| 140 | name: F1 |
| 141 | --- |
| 142 | |
| 143 | # deberta-v3-base for Extractive QA |
| 144 | |
| 145 | This is the [deberta-v3-base](https://huggingface.co/microsoft/deberta-v3-base) model, fine-tuned using the [SQuAD2.0](https://huggingface.co/datasets/squad_v2) dataset. It's been trained on question-answer pairs, including unanswerable questions, for the task of Question Answering. |
| 146 | |
| 147 | |
| 148 | ## Overview |
| 149 | **Language model:** deberta-v3-base |
| 150 | **Language:** English |
| 151 | **Downstream-task:** Extractive QA |
| 152 | **Training data:** SQuAD 2.0 |
| 153 | **Eval data:** SQuAD 2.0 |
| 154 | **Code:** See [an example extractive QA pipeline built with Haystack](https://haystack.deepset.ai/tutorials/34_extractive_qa_pipeline) |
| 155 | **Infrastructure**: 1x NVIDIA A10G |
| 156 | |
| 157 | ## Hyperparameters |
| 158 | |
| 159 | ``` |
| 160 | batch_size = 12 |
| 161 | n_epochs = 4 |
| 162 | base_LM_model = "deberta-v3-base" |
| 163 | max_seq_len = 512 |
| 164 | learning_rate = 2e-5 |
| 165 | lr_schedule = LinearWarmup |
| 166 | warmup_proportion = 0.2 |
| 167 | doc_stride = 128 |
| 168 | max_query_length = 64 |
| 169 | ``` |
| 170 | |
| 171 | ## Usage |
| 172 | |
| 173 | ### In Haystack |
| 174 | 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. |
| 175 | To load and run the model with [Haystack](https://github.com/deepset-ai/haystack/): |
| 176 | ```python |
| 177 | # After running pip install haystack-ai "transformers[torch,sentencepiece]" |
| 178 | |
| 179 | from haystack import Document |
| 180 | from haystack.components.readers import ExtractiveReader |
| 181 | |
| 182 | docs = [ |
| 183 | Document(content="Python is a popular programming language"), |
| 184 | Document(content="python ist eine beliebte Programmiersprache"), |
| 185 | ] |
| 186 | |
| 187 | reader = ExtractiveReader(model="deepset/roberta-base-squad2") |
| 188 | reader.warm_up() |
| 189 | |
| 190 | question = "What is a popular programming language?" |
| 191 | result = reader.run(query=question, documents=docs) |
| 192 | # {'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),...)]} |
| 193 | ``` |
| 194 | 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). |
| 195 | |
| 196 | ### In Transformers |
| 197 | ```python |
| 198 | from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline |
| 199 | |
| 200 | model_name = "deepset/roberta-base-squad2" |
| 201 | |
| 202 | # a) Get predictions |
| 203 | nlp = pipeline('question-answering', model=model_name, tokenizer=model_name) |
| 204 | QA_input = { |
| 205 | 'question': 'Why is model conversion important?', |
| 206 | 'context': 'The option to convert models between FARM and transformers gives freedom to the user and let people easily switch between frameworks.' |
| 207 | } |
| 208 | res = nlp(QA_input) |
| 209 | |
| 210 | # b) Load model & tokenizer |
| 211 | model = AutoModelForQuestionAnswering.from_pretrained(model_name) |
| 212 | tokenizer = AutoTokenizer.from_pretrained(model_name) |
| 213 | ``` |
| 214 | |
| 215 | |
| 216 | ## Authors |
| 217 | **Sebastian Lee:** sebastian.lee [at] deepset.ai |
| 218 | **Timo Möller:** timo.moeller [at] deepset.ai |
| 219 | **Malte Pietsch:** malte.pietsch [at] deepset.ai |
| 220 | |
| 221 | ## About us |
| 222 | |
| 223 | <div class="grid lg:grid-cols-2 gap-x-4 gap-y-3"> |
| 224 | <div class="w-full h-40 object-cover mb-2 rounded-lg flex items-center justify-center"> |
| 225 | <img alt="" src="https://raw.githubusercontent.com/deepset-ai/.github/main/deepset-logo-colored.png" class="w-40"/> |
| 226 | </div> |
| 227 | <div class="w-full h-40 object-cover mb-2 rounded-lg flex items-center justify-center"> |
| 228 | <img alt="" src="https://raw.githubusercontent.com/deepset-ai/.github/main/haystack-logo-colored.png" class="w-40"/> |
| 229 | </div> |
| 230 | </div> |
| 231 | |
| 232 | [deepset](http://deepset.ai/) is the company behind the production-ready open-source AI framework [Haystack](https://haystack.deepset.ai/). |
| 233 | |
| 234 | Some of our other work: |
| 235 | - [Distilled roberta-base-squad2 (aka "tinyroberta-squad2")](https://huggingface.co/deepset/tinyroberta-squad2) |
| 236 | - [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) |
| 237 | - [deepset Cloud](https://www.deepset.ai/deepset-cloud-product), [deepset Studio](https://www.deepset.ai/deepset-studio) |
| 238 | |
| 239 | ## Get in touch and join the Haystack community |
| 240 | |
| 241 | <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>. |
| 242 | |
| 243 | We also have a <strong><a class="h-7" href="https://haystack.deepset.ai/community">Discord community open to everyone!</a></strong></p> |
| 244 | |
| 245 | [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) |
| 246 | |
| 247 | By the way: [we're hiring!](http://www.deepset.ai/jobs) |