Branden Chan commited on
Commit
74ab376
1 Parent(s): c4dd241

add model card

Browse files
Files changed (1) hide show
  1. README.md +118 -0
README.md ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ datasets:
3
+ - squad_v2
4
+ ---
5
+
6
+ # xlm-roberta-base for QA
7
+
8
+ ## Overview
9
+ **Language model:** xlm-roberta-base
10
+ **Language:** English
11
+ **Downstream-task:** Extractive QA
12
+ **Training data:** SQuAD 2.0
13
+ **Eval data:** SQuAD 2.0
14
+ **Code:** See [example](https://github.com/deepset-ai/FARM/blob/master/examples/question_answering.py) in [FARM](https://github.com/deepset-ai/FARM/blob/master/examples/question_answering.py)
15
+ **Infrastructure**: 4x Tesla v100
16
+
17
+ ## Hyperparameters
18
+
19
+ ```
20
+ batch_size = 22*4
21
+ n_epochs = 2
22
+ max_seq_len=256,
23
+ doc_stride=128,
24
+ learning_rate=2e-5,
25
+ ```
26
+
27
+ Corresponding experiment logs in mlflow: [link](https://public-mlflow.deepset.ai/#/experiments/2/runs/b25ec75e07614accb3f1ce03d43dbe08)
28
+
29
+
30
+ ## Performance
31
+ Evaluated on the SQuAD 2.0 dev set with the [official eval script](https://worksheets.codalab.org/rest/bundles/0x6b567e1cf2e041ec80d7098f031c5c9e/contents/blob/).
32
+ ```
33
+ "exact": 73.91560683904657
34
+ "f1": 77.14103746689592
35
+ ```
36
+
37
+ Evaluated on German MLQA: test-context-de-question-de.json
38
+ "exact": 33.67279167589108
39
+ "f1": 44.34437105434842
40
+ "total": 4517
41
+
42
+ Evaluated on German XQuAD: xquad.de.json
43
+ "exact": 48.739495798319325
44
+ "f1": 62.552615701071495
45
+ "total": 1190
46
+
47
+
48
+ ## Usage
49
+
50
+ ### In Transformers
51
+ ```python
52
+ from transformers.pipelines import pipeline
53
+ from transformers.modeling_auto import AutoModelForQuestionAnswering
54
+ from transformers.tokenization_auto import AutoTokenizer
55
+
56
+ model_name = "deepset/xlm-roberta-base-squad2"
57
+
58
+ # a) Get predictions
59
+ nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)
60
+ QA_input = {
61
+ 'question': 'Why is model conversion important?',
62
+ 'context': 'The option to convert models between FARM and transformers gives freedom to the user and let people easily switch between frameworks.'
63
+ }
64
+ res = nlp(QA_input)
65
+
66
+ # b) Load model & tokenizer
67
+ model = AutoModelForQuestionAnswering.from_pretrained(model_name)
68
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
69
+ ```
70
+
71
+ ### In FARM
72
+
73
+ ```python
74
+ from farm.modeling.adaptive_model import AdaptiveModel
75
+ from farm.modeling.tokenization import Tokenizer
76
+ from farm.infer import Inferencer
77
+
78
+ model_name = "deepset/xlm-roberta-base-squad2"
79
+
80
+ # a) Get predictions
81
+ nlp = Inferencer.load(model_name, task_type="question_answering")
82
+ QA_input = [{"questions": ["Why is model conversion important?"],
83
+ "text": "The option to convert models between FARM and transformers gives freedom to the user and let people easily switch between frameworks."}]
84
+ res = nlp.inference_from_dicts(dicts=QA_input, rest_api_schema=True)
85
+
86
+ # b) Load model & tokenizer
87
+ model = AdaptiveModel.convert_from_transformers(model_name, device="cpu", task_type="question_answering")
88
+ tokenizer = Tokenizer.load(model_name)
89
+ ```
90
+
91
+ ### In haystack
92
+ 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/):
93
+ ```python
94
+ reader = FARMReader(model_name_or_path="deepset/xlm-roberta-base-squad2")
95
+ # or
96
+ reader = TransformersReader(model="deepset/roberta-base-squad2",tokenizer="deepset/xlm-roberta-base-squad2")
97
+ ```
98
+
99
+
100
+ ## Authors
101
+ Branden Chan: `branden.chan [at] deepset.ai`
102
+ Timo M枚ller: `timo.moeller [at] deepset.ai`
103
+ Malte Pietsch: `malte.pietsch [at] deepset.ai`
104
+ Tanay Soni: `tanay.soni [at] deepset.ai`
105
+
106
+ ## About us
107
+ ![deepset logo](https://raw.githubusercontent.com/deepset-ai/FARM/master/docs/img/deepset_logo.png)
108
+
109
+ We bring NLP to the industry via open source!
110
+ Our focus: Industry specific language models & large scale QA systems.
111
+
112
+ Some of our work:
113
+ - [German BERT (aka "bert-base-german-cased")](https://deepset.ai/german-bert)
114
+ - [FARM](https://github.com/deepset-ai/FARM)
115
+ - [Haystack](https://github.com/deepset-ai/haystack/)
116
+
117
+ Get in touch:
118
+ [Twitter](https://twitter.com/deepset_ai) | [LinkedIn](https://www.linkedin.com/company/deepset-ai/) | [Website](https://deepset.ai)