Migrate model card from transformers-repo
Browse filesRead announcement at https://discuss.huggingface.co/t/announcement-all-model-cards-will-be-migrated-to-hf-co-model-repos/2755
Original file history: https://github.com/huggingface/transformers/commits/master/model_cards/mrm8488/bert-small-finetuned-squadv2/README.md
README.md
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language: en
|
3 |
+
thumbnail:
|
4 |
+
---
|
5 |
+
|
6 |
+
# BERT-Small fine-tuned on SQuAD v2
|
7 |
+
|
8 |
+
[BERT-Small](https://github.com/google-research/bert/) created by [Google Research](https://github.com/google-research) and fine-tuned on [SQuAD 2.0](https://rajpurkar.github.io/SQuAD-explorer/) for **Q&A** downstream task.
|
9 |
+
|
10 |
+
**Mode size** (after training): **109.74 MB**
|
11 |
+
|
12 |
+
## Details of BERT-Small and its 'family' (from their documentation)
|
13 |
+
|
14 |
+
Released on March 11th, 2020
|
15 |
+
|
16 |
+
This is model is a part of 24 smaller BERT models (English only, uncased, trained with WordPiece masking) referenced in [Well-Read Students Learn Better: On the Importance of Pre-training Compact Models](https://arxiv.org/abs/1908.08962).
|
17 |
+
|
18 |
+
The smaller BERT models are intended for environments with restricted computational resources. They can be fine-tuned in the same manner as the original BERT models. However, they are most effective in the context of knowledge distillation, where the fine-tuning labels are produced by a larger and more accurate teacher.
|
19 |
+
|
20 |
+
## Details of the downstream task (Q&A) - Dataset
|
21 |
+
|
22 |
+
[SQuAD2.0](https://rajpurkar.github.io/SQuAD-explorer/) combines the 100,000 questions in SQuAD1.1 with over 50,000 unanswerable questions written adversarially by crowdworkers to look similar to answerable ones. To do well on SQuAD2.0, systems must not only answer questions when possible, but also determine when no answer is supported by the paragraph and abstain from answering.
|
23 |
+
|
24 |
+
| Dataset | Split | # samples |
|
25 |
+
| -------- | ----- | --------- |
|
26 |
+
| SQuAD2.0 | train | 130k |
|
27 |
+
| SQuAD2.0 | eval | 12.3k |
|
28 |
+
|
29 |
+
## Model training
|
30 |
+
|
31 |
+
The model was trained on a Tesla P100 GPU and 25GB of RAM.
|
32 |
+
The script for fine tuning can be found [here](https://github.com/huggingface/transformers/blob/master/examples/question-answering/run_squad.py)
|
33 |
+
|
34 |
+
## Results:
|
35 |
+
|
36 |
+
| Metric | # Value |
|
37 |
+
| ------ | --------- |
|
38 |
+
| **EM** | **60.49** |
|
39 |
+
| **F1** | **64.21** |
|
40 |
+
|
41 |
+
## Comparison:
|
42 |
+
|
43 |
+
| Model | EM | F1 score | SIZE (MB) |
|
44 |
+
| ------------------------------------------------------------------------------------------- | --------- | --------- | --------- |
|
45 |
+
| [bert-tiny-finetuned-squadv2](https://huggingface.co/mrm8488/bert-tiny-finetuned-squadv2) | 48.60 | 49.73 | **16.74** |
|
46 |
+
| [bert-mini-finetuned-squadv2](https://huggingface.co/mrm8488/bert-mini-finetuned-squadv2) | 56.31 | 59.65 | 42.63 |
|
47 |
+
| [bert-small-finetuned-squadv2](https://huggingface.co/mrm8488/bert-small-finetuned-squadv2) | **60.49** | **64.21** | 109.74 |
|
48 |
+
|
49 |
+
## Model in action
|
50 |
+
|
51 |
+
Fast usage with **pipelines**:
|
52 |
+
|
53 |
+
```python
|
54 |
+
from transformers import pipeline
|
55 |
+
|
56 |
+
qa_pipeline = pipeline(
|
57 |
+
"question-answering",
|
58 |
+
model="mrm8488/bert-small-finetuned-squadv2",
|
59 |
+
tokenizer="mrm8488/bert-small-finetuned-squadv2"
|
60 |
+
)
|
61 |
+
|
62 |
+
qa_pipeline({
|
63 |
+
'context': "Manuel Romero has been working hardly in the repository hugginface/transformers lately",
|
64 |
+
'question': "Who has been working hard for hugginface/transformers lately?"
|
65 |
+
|
66 |
+
})
|
67 |
+
|
68 |
+
# Output:
|
69 |
+
```
|
70 |
+
|
71 |
+
```json
|
72 |
+
{
|
73 |
+
"answer": "Manuel Romero",
|
74 |
+
"end": 13,
|
75 |
+
"score": 0.9939319924374637,
|
76 |
+
"start": 0
|
77 |
+
}
|
78 |
+
```
|
79 |
+
|
80 |
+
### Yes! That was easy 🎉 Let's try with another example
|
81 |
+
|
82 |
+
```python
|
83 |
+
qa_pipeline({
|
84 |
+
'context': "Manuel Romero has been working hardly in the repository hugginface/transformers lately",
|
85 |
+
'question': "For which company has worked Manuel Romero?"
|
86 |
+
})
|
87 |
+
|
88 |
+
# Output:
|
89 |
+
```
|
90 |
+
|
91 |
+
```json
|
92 |
+
{
|
93 |
+
"answer": "hugginface/transformers",
|
94 |
+
"end": 79,
|
95 |
+
"score": 0.6024888734447131,
|
96 |
+
"start": 56
|
97 |
+
}
|
98 |
+
```
|
99 |
+
|
100 |
+
### It works!! 🎉 🎉 🎉
|
101 |
+
|
102 |
+
> Created by [Manuel Romero/@mrm8488](https://twitter.com/mrm8488) | [LinkedIn](https://www.linkedin.com/in/manuel-romero-cs/)
|
103 |
+
|
104 |
+
> Made with <span style="color: #e25555;">♥</span> in Spain
|