MichelBartelsDeepset commited on
Commit
8d6918f
1 Parent(s): 7681ef8

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +128 -0
README.md ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ datasets:
4
+ - squad_v2
5
+ license: cc-by-4.0
6
+ ---
7
+
8
+ # tinyroberta-squad2
9
+
10
+ ## Overview
11
+ **Language model:** tinyroberta-squad2
12
+ **Language:** English
13
+ **Downstream-task:** Extractive QA
14
+ **Training data:** SQuAD 2.0
15
+ **Eval data:** SQuAD 2.0
16
+ **Code:**
17
+ **Infrastructure**: 4x Tesla v100
18
+
19
+ ## Hyperparameters
20
+
21
+ ```
22
+ batch_size = 96
23
+ n_epochs = 4
24
+ base_LM_model = "deepset/tinyroberta-squad2-step1"
25
+ max_seq_len = 384
26
+ learning_rate = 3e-5
27
+ lr_schedule = LinearWarmup
28
+ warmup_proportion = 0.2
29
+ doc_stride = 128
30
+ max_query_length = 64
31
+ distillation_loss_weight = 0.75
32
+ temperature = 1.5
33
+ teacher = "deepset/robert-large-squad2"
34
+ ```
35
+
36
+ ## Performance
37
+ Evaluated on the SQuAD 2.0 dev set with the [official eval script](https://worksheets.codalab.org/rest/bundles/0x6b567e1cf2e041ec80d7098f031c5c9e/contents/blob/).
38
+
39
+ ```
40
+ "exact": 78.19422218478901,
41
+ "f1": 81.41848853895601,
42
+
43
+ "total": 11873,
44
+ "HasAns_exact": 76.51821862348179,
45
+ "HasAns_f1": 82.97599770968706,
46
+ "HasAns_total": 5928,
47
+ "NoAns_exact": 79.86543313709,
48
+ "NoAns_f1": 79.86543313709,
49
+ "NoAns_total": 5945,
50
+
51
+ "best_exact": 79.34810073275499,
52
+ "best_exact_thresh": -4.051729202270508,
53
+ "best_f1": 82.26435201691056,
54
+ "best_f1_thresh": -4.051729202270508
55
+ ```
56
+
57
+ ## Usage
58
+
59
+ ### In Transformers
60
+ ```python
61
+ from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
62
+
63
+ model_name = "deepset/tinyroberta-squad2"
64
+
65
+ # a) Get predictions
66
+ nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)
67
+ QA_input = {
68
+ 'question': 'Why is model conversion important?',
69
+ 'context': 'The option to convert models between FARM and transformers gives freedom to the user and let people easily switch between frameworks.'
70
+ }
71
+ res = nlp(QA_input)
72
+
73
+ # b) Load model & tokenizer
74
+ model = AutoModelForQuestionAnswering.from_pretrained(model_name)
75
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
76
+ ```
77
+
78
+ ### In FARM
79
+
80
+ ```python
81
+ from farm.modeling.adaptive_model import AdaptiveModel
82
+ from farm.modeling.tokenization import Tokenizer
83
+ from farm.infer import Inferencer
84
+
85
+ model_name = "deepset/tinyroberta-squad2"
86
+
87
+ # a) Get predictions
88
+ nlp = Inferencer.load(model_name, task_type="question_answering")
89
+ QA_input = [{"questions": ["Why is model conversion important?"],
90
+ "text": "The option to convert models between FARM and transformers gives freedom to the user and let people easily switch between frameworks."}]
91
+ res = nlp.inference_from_dicts(dicts=QA_input, rest_api_schema=True)
92
+
93
+ # b) Load model & tokenizer
94
+ model = AdaptiveModel.convert_from_transformers(model_name, device="cpu", task_type="question_answering")
95
+ tokenizer = Tokenizer.load(model_name)
96
+ ```
97
+
98
+ ### In haystack
99
+ For doing QA at scale (i.e. many docs instead of single paragraph), you can load the model also in [haystack](https://github.com/deepset-ai/haystack/):
100
+ ```python
101
+ reader = FARMReader(model_name_or_path="deepset/roberta-base-squad2")
102
+ # or
103
+ reader = TransformersReader(model_name_or_path="deepset/roberta-base-squad2",tokenizer="deepset/roberta-base-squad2")
104
+ ```
105
+
106
+
107
+ ## Authors
108
+ Branden Chan: `branden.chan [at] deepset.ai`
109
+ Timo Möller: `timo.moeller [at] deepset.ai`
110
+ Malte Pietsch: `malte.pietsch [at] deepset.ai`
111
+ Tanay Soni: `tanay.soni [at] deepset.ai`
112
+ Michel Bartels: `michel.bartels [at] deepset.ai`
113
+
114
+ ## About us
115
+ ![deepset logo](https://workablehr.s3.amazonaws.com/uploads/account/logo/476306/logo)
116
+ We bring NLP to the industry via open source!
117
+ Our focus: Industry specific language models & large scale QA systems.
118
+
119
+ Some of our work:
120
+ - [German BERT (aka "bert-base-german-cased")](https://deepset.ai/german-bert)
121
+ - [GermanQuAD and GermanDPR datasets and models (aka "gelectra-base-germanquad", "gbert-base-germandpr")](https://deepset.ai/germanquad)
122
+ - [FARM](https://github.com/deepset-ai/FARM)
123
+ - [Haystack](https://github.com/deepset-ai/haystack/)
124
+
125
+ Get in touch:
126
+ [Twitter](https://twitter.com/deepset_ai) | [LinkedIn](https://www.linkedin.com/company/deepset-ai/) | [Slack](https://haystack.deepset.ai/community/join) | [GitHub Discussions](https://github.com/deepset-ai/haystack/discussions) | [Website](https://deepset.ai)
127
+
128
+ By the way: [we're hiring!](http://www.deepset.ai/jobs)