NimaBoscarino commited on
Commit
52cdd25
1 Parent(s): fe4418c

Test cases for deepset/roberta-base-squad2

Browse files
compliance_checks/evaluation.py CHANGED
@@ -84,6 +84,7 @@ class EvaluationCheck(ComplianceCheck):
84
  ("h2", "Benchmarks"),
85
  ("h2", "Results"),
86
  ("h1", "Evaluation data"),
 
87
  ]
88
 
89
  for hX, heading in combos:
 
84
  ("h2", "Benchmarks"),
85
  ("h2", "Results"),
86
  ("h1", "Evaluation data"),
87
+ ("h2", "Performance"),
88
  ]
89
 
90
  for hX, heading in combos:
tests/cards/deepset___roberta-base-squad2.md ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ license: cc-by-4.0
4
+ datasets:
5
+ - squad_v2
6
+ model-index:
7
+ - name: deepset/roberta-base-squad2
8
+ results:
9
+ - task:
10
+ type: question-answering
11
+ name: Question Answering
12
+ dataset:
13
+ name: squad_v2
14
+ type: squad_v2
15
+ config: squad_v2
16
+ split: validation
17
+ metrics:
18
+ - type: exact_match
19
+ value: 79.9309
20
+ name: Exact Match
21
+ verified: true
22
+ verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiMDhhNjg5YzNiZGQ1YTIyYTAwZGUwOWEzZTRiYzdjM2QzYjA3ZTUxNDM1NjE1MTUyMjE1MGY1YzEzMjRjYzVjYiIsInZlcnNpb24iOjF9.EH5JJo8EEFwU7osPz3s7qanw_tigeCFhCXjSfyN0Y1nWVnSfulSxIk_DbAEI5iE80V4EKLyp5-mYFodWvL2KDA
23
+ - type: f1
24
+ value: 82.9501
25
+ name: F1
26
+ verified: true
27
+ verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiMjk5ZDYwOGQyNjNkMWI0OTE4YzRmOTlkY2JjNjQ0YTZkNTMzMzNkYTA0MDFmNmI3NjA3NjNlMjhiMDQ2ZjJjNSIsInZlcnNpb24iOjF9.DDm0LNTkdLbGsue58bg1aH_s67KfbcmkvL-6ZiI2s8IoxhHJMSf29H_uV2YLyevwx900t-MwTVOW3qfFnMMEAQ
28
+ - type: total
29
+ value: 11869
30
+ name: total
31
+ verified: true
32
+ verifyToken: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiMGFkMmI2ODM0NmY5NGNkNmUxYWViOWYxZDNkY2EzYWFmOWI4N2VhYzY5MGEzMTVhOTU4Zjc4YWViOGNjOWJjMCIsInZlcnNpb24iOjF9.fexrU1icJK5_MiifBtZWkeUvpmFISqBLDXSQJ8E6UnrRof-7cU0s4tX_dIsauHWtUpIHMPZCf5dlMWQKXZuAAA
33
+ ---
34
+
35
+ # roberta-base for QA
36
+
37
+ This is the [roberta-base](https://huggingface.co/roberta-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.
38
+
39
+
40
+ ## Overview
41
+ **Language model:** roberta-base
42
+ **Language:** English
43
+ **Downstream-task:** Extractive QA
44
+ **Training data:** SQuAD 2.0
45
+ **Eval data:** SQuAD 2.0
46
+ **Code:** See [an example QA pipeline on Haystack](https://haystack.deepset.ai/tutorials/first-qa-system)
47
+ **Infrastructure**: 4x Tesla v100
48
+
49
+ ## Hyperparameters
50
+
51
+ ```
52
+ batch_size = 96
53
+ n_epochs = 2
54
+ base_LM_model = "roberta-base"
55
+ max_seq_len = 386
56
+ learning_rate = 3e-5
57
+ lr_schedule = LinearWarmup
58
+ warmup_proportion = 0.2
59
+ doc_stride=128
60
+ max_query_length=64
61
+ ```
62
+
63
+ ## Using a distilled model instead
64
+ Please note that we have also released a distilled version of this model called [deepset/tinyroberta-squad2](https://huggingface.co/deepset/tinyroberta-squad2). The distilled model has a comparable prediction quality and runs at twice the speed of the base model.
65
+
66
+ ## Usage
67
+
68
+ ### In Haystack
69
+ Haystack is an NLP framework by deepset. You can use this model in a Haystack pipeline to do question answering at scale (over many documents). To load the model in [Haystack](https://github.com/deepset-ai/haystack/):
70
+ ```python
71
+ reader = FARMReader(model_name_or_path="deepset/roberta-base-squad2")
72
+ # or
73
+ reader = TransformersReader(model_name_or_path="deepset/roberta-base-squad2",tokenizer="deepset/roberta-base-squad2")
74
+ ```
75
+ For a complete example of ``roberta-base-squad2`` being used for Question Answering, check out the [Tutorials in Haystack Documentation](https://haystack.deepset.ai/tutorials/first-qa-system)
76
+
77
+ ### In Transformers
78
+ ```python
79
+ from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
80
+
81
+ model_name = "deepset/roberta-base-squad2"
82
+
83
+ # a) Get predictions
84
+ nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)
85
+ QA_input = {
86
+ 'question': 'Why is model conversion important?',
87
+ 'context': 'The option to convert models between FARM and transformers gives freedom to the user and let people easily switch between frameworks.'
88
+ }
89
+ res = nlp(QA_input)
90
+
91
+ # b) Load model & tokenizer
92
+ model = AutoModelForQuestionAnswering.from_pretrained(model_name)
93
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
94
+ ```
95
+
96
+ ## Performance
97
+ Evaluated on the SQuAD 2.0 dev set with the [official eval script](https://worksheets.codalab.org/rest/bundles/0x6b567e1cf2e041ec80d7098f031c5c9e/contents/blob/).
98
+
99
+ ```
100
+ "exact": 79.87029394424324,
101
+ "f1": 82.91251169582613,
102
+
103
+ "total": 11873,
104
+ "HasAns_exact": 77.93522267206478,
105
+ "HasAns_f1": 84.02838248389763,
106
+ "HasAns_total": 5928,
107
+ "NoAns_exact": 81.79983179142137,
108
+ "NoAns_f1": 81.79983179142137,
109
+ "NoAns_total": 5945
110
+ ```
111
+
112
+ ## Authors
113
+ **Branden Chan:** branden.chan@deepset.ai
114
+ **Timo Möller:** timo.moeller@deepset.ai
115
+ **Malte Pietsch:** malte.pietsch@deepset.ai
116
+ **Tanay Soni:** tanay.soni@deepset.ai
117
+
118
+ ## About us
119
+
120
+ <div class="grid lg:grid-cols-2 gap-x-4 gap-y-3">
121
+ <div class="w-full h-40 object-cover mb-2 rounded-lg flex items-center justify-center">
122
+ <img alt="" src="https://raw.githubusercontent.com/deepset-ai/.github/main/deepset-logo-colored.png" class="w-40"/>
123
+ </div>
124
+ <div class="w-full h-40 object-cover mb-2 rounded-lg flex items-center justify-center">
125
+ <img alt="" src="https://raw.githubusercontent.com/deepset-ai/.github/main/haystack-logo-colored.png" class="w-40"/>
126
+ </div>
127
+ </div>
128
+
129
+ [deepset](http://deepset.ai/) is the company behind the open-source NLP framework [Haystack](https://haystack.deepset.ai/) which is designed to help you build production ready NLP systems that use: Question answering, summarization, ranking etc.
130
+
131
+
132
+ Some of our other work:
133
+ - [Distilled roberta-base-squad2 (aka "tinyroberta-squad2")]([https://huggingface.co/deepset/tinyroberta-squad2)
134
+ - [German BERT (aka "bert-base-german-cased")](https://deepset.ai/german-bert)
135
+ - [GermanQuAD and GermanDPR datasets and models (aka "gelectra-base-germanquad", "gbert-base-germandpr")](https://deepset.ai/germanquad)
136
+
137
+ ## Get in touch and join the Haystack community
138
+
139
+ <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>.
140
+
141
+ We also have a <strong><a class="h-7" href="https://haystack.deepset.ai/community">Discord community open to everyone!</a></strong></p>
142
+
143
+ [Twitter](https://twitter.com/deepset_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://deepset.ai)
144
+
145
+ By the way: [we're hiring!](http://www.deepset.ai/jobs)
tests/conftest.py CHANGED
@@ -14,6 +14,7 @@ expected_check_results = {
14
  "big-science___bloom": [True, True, True, True],
15
  "big-science___t0pp": [True, True, False, True],
16
  "cl-tohoku___bert-base-japanese-whole-word-masking": [False, False, False, False],
 
17
  "distilbert-base-cased-distilled-squad": [True, True, True, True],
18
  "distilbert-base-uncased": [True, True, False, True],
19
  "distilbert-base-uncased-finetuned-sst-2-english": [True, True, False, False],
 
14
  "big-science___bloom": [True, True, True, True],
15
  "big-science___t0pp": [True, True, False, True],
16
  "cl-tohoku___bert-base-japanese-whole-word-masking": [False, False, False, False],
17
+ "deepset___roberta-base-squad2": [False, False, False, True],
18
  "distilbert-base-cased-distilled-squad": [True, True, True, True],
19
  "distilbert-base-uncased": [True, True, False, True],
20
  "distilbert-base-uncased-finetuned-sst-2-english": [True, True, False, False],