Geerath commited on
Commit
31d0434
verified
1 Parent(s): 4a37d77

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +69 -3
README.md CHANGED
@@ -19,18 +19,84 @@ It achieves the following results on the evaluation set:
19
 
20
  ## Model description
21
 
22
- More information needed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  ## Intended uses & limitations
25
 
26
- More information needed
27
 
28
  ## Training and evaluation data
29
 
30
- More information needed
31
 
32
  ## Training procedure
33
 
 
 
 
 
 
 
34
  ### Training hyperparameters
35
 
36
  The following hyperparameters were used during training:
 
19
 
20
  ## Model description
21
 
22
+ The DistilBERT model was proposed in the blog post Smaller, faster, cheaper, lighter: Introducing DistilBERT, adistilled version of BERT, and the paper DistilBERT, adistilled version of BERT: smaller, faster, cheaper and lighter. DistilBERT is a small, fast, cheap and light Transformer model trained by distilling BERT base. It has 40% less parameters than bert-base-uncased, runs 60% faster while preserving over 95% of BERT's performances as measured on the GLUE language understanding benchmark.
23
+
24
+ This model is a fine-tune checkpoint of DistilBERT-base-uncased, fine-tuned using (a second step of) knowledge distillation on SQuAD v1.1.
25
+ ## Results are my own reproduction of the development by Hugging Face.
26
+
27
+ ## How to Get Started with the Model
28
+ Use the code below:
29
+
30
+ from transformers import pipeline
31
+ question_answerer = pipeline("question-answering", model='distilbert-base-uncased-distilled-squad')
32
+
33
+ context = r"""
34
+ Extractive Question Answering is the task of extracting an answer from a text given a question. An example of a
35
+ question answering dataset is the SQuAD dataset, which is entirely based on that task. If you would like to fine-tune
36
+ a model on a SQuAD task, you may leverage the examples/pytorch/question-answering/run_squad.py script.
37
+ """
38
+
39
+ result = question_answerer(question="What is a good example of a question answering dataset?", context=context)
40
+ print(
41
+ f"Answer: '{result['answer']}', score: {round(result['score'], 4)}, start: {result['start']}, end: {result['end']}"
42
+
43
+ # Here is how to use this model in PyTorch:
44
+
45
+ from transformers import DistilBertTokenizer, DistilBertForQuestionAnswering
46
+ import torch
47
+ tokenizer = DistilBertTokenizer.from_pretrained('distilbert-base-uncased-distilled-squad')
48
+ model = DistilBertForQuestionAnswering.from_pretrained('distilbert-base-uncased-distilled-squad')
49
+
50
+ question, text = "Who was Jim Henson?", "Jim Henson was a nice puppet"
51
+
52
+ inputs = tokenizer(question, text, return_tensors="pt")
53
+ with torch.no_grad():
54
+ outputs = model(**inputs)
55
+
56
+ answer_start_index = torch.argmax(outputs.start_logits)
57
+ answer_end_index = torch.argmax(outputs.end_logits)
58
+
59
+ predict_answer_tokens = inputs.input_ids[0, answer_start_index : answer_end_index + 1]
60
+ tokenizer.decode(predict_answer_tokens)
61
+
62
+ # And in TensorFlow:
63
+
64
+ from transformers import DistilBertTokenizer, TFDistilBertForQuestionAnswering
65
+ import tensorflow as tf
66
+
67
+ tokenizer = DistilBertTokenizer.from_pretrained("distilbert-base-uncased-distilled-squad")
68
+ model = TFDistilBertForQuestionAnswering.from_pretrained("distilbert-base-uncased-distilled-squad")
69
+
70
+ question, text = "Who was Jim Henson?", "Jim Henson was a nice puppet"
71
+
72
+ inputs = tokenizer(question, text, return_tensors="tf")
73
+ outputs = model(**inputs)
74
+
75
+ answer_start_index = int(tf.math.argmax(outputs.start_logits, axis=-1)[0])
76
+ answer_end_index = int(tf.math.argmax(outputs.end_logits, axis=-1)[0])
77
+
78
+ predict_answer_tokens = inputs.input_ids[0, answer_start_index : answer_end_index + 1]
79
+ tokenizer.decode(predict_answer_tokens)
80
+
81
+ ## Uses:
82
+ This model can be used for question answering.
83
 
84
  ## Intended uses & limitations
85
 
86
+ CONTENT WARNING: Readers should be aware that language generated by this model can be disturbing or offensive to some and can propagate historical and current stereotypes.
87
 
88
  ## Training and evaluation data
89
 
90
+ This model reaches a F1 score of 82.75539002485876 and 'exact_match': 73.66130558183538 on the [SQuAD v1.1] dev set (for comparison, Bert bert-base-uncased version reaches a F1 score of 88.5).d
91
 
92
  ## Training procedure
93
 
94
+ Preprocessing
95
+ See the distilbert-base-uncased model card for further details.
96
+
97
+ Pretraining
98
+ See the distilbert-base-uncased model card for further details.
99
+
100
  ### Training hyperparameters
101
 
102
  The following hyperparameters were used during training: