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/csarron/mobilebert-uncased-squad-v1/README.md
README.md
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language: en
|
3 |
+
thumbnail:
|
4 |
+
license: mit
|
5 |
+
tags:
|
6 |
+
- question-answering
|
7 |
+
- mobilebert
|
8 |
+
datasets:
|
9 |
+
- squad
|
10 |
+
metrics:
|
11 |
+
- squad
|
12 |
+
widget:
|
13 |
+
- text: "Which name is also used to describe the Amazon rainforest in English?"
|
14 |
+
context: "The Amazon rainforest (Portuguese: Floresta Amazônica or Amazônia; Spanish: Selva Amazónica, Amazonía or usually Amazonia; French: Forêt amazonienne; Dutch: Amazoneregenwoud), also known in English as Amazonia or the Amazon Jungle, is a moist broadleaf forest that covers most of the Amazon basin of South America. This basin encompasses 7,000,000 square kilometres (2,700,000 sq mi), of which 5,500,000 square kilometres (2,100,000 sq mi) are covered by the rainforest. This region includes territory belonging to nine nations. The majority of the forest is contained within Brazil, with 60% of the rainforest, followed by Peru with 13%, Colombia with 10%, and with minor amounts in Venezuela, Ecuador, Bolivia, Guyana, Suriname and French Guiana. States or departments in four nations contain \"Amazonas\" in their names. The Amazon represents over half of the planet's remaining rainforests, and comprises the largest and most biodiverse tract of tropical rainforest in the world, with an estimated 390 billion individual trees divided into 16,000 species."
|
15 |
+
- text: "How many square kilometers of rainforest is covered in the basin?"
|
16 |
+
context: "The Amazon rainforest (Portuguese: Floresta Amazônica or Amazônia; Spanish: Selva Amazónica, Amazonía or usually Amazonia; French: Forêt amazonienne; Dutch: Amazoneregenwoud), also known in English as Amazonia or the Amazon Jungle, is a moist broadleaf forest that covers most of the Amazon basin of South America. This basin encompasses 7,000,000 square kilometres (2,700,000 sq mi), of which 5,500,000 square kilometres (2,100,000 sq mi) are covered by the rainforest. This region includes territory belonging to nine nations. The majority of the forest is contained within Brazil, with 60% of the rainforest, followed by Peru with 13%, Colombia with 10%, and with minor amounts in Venezuela, Ecuador, Bolivia, Guyana, Suriname and French Guiana. States or departments in four nations contain \"Amazonas\" in their names. The Amazon represents over half of the planet's remaining rainforests, and comprises the largest and most biodiverse tract of tropical rainforest in the world, with an estimated 390 billion individual trees divided into 16,000 species."
|
17 |
+
---
|
18 |
+
|
19 |
+
## MobileBERT fine-tuned on SQuAD v1
|
20 |
+
|
21 |
+
[MobileBERT](https://arxiv.org/abs/2004.02984) is a thin version of BERT_LARGE, while equipped with bottleneck structures and a carefully designed balance
|
22 |
+
between self-attentions and feed-forward networks.
|
23 |
+
|
24 |
+
This model was fine-tuned from the HuggingFace checkpoint `google/mobilebert-uncased` on [SQuAD1.1](https://rajpurkar.github.io/SQuAD-explorer).
|
25 |
+
|
26 |
+
## Details
|
27 |
+
|
28 |
+
| Dataset | Split | # samples |
|
29 |
+
| -------- | ----- | --------- |
|
30 |
+
| SQuAD1.1 | train | 90.6K |
|
31 |
+
| SQuAD1.1 | eval | 11.1k |
|
32 |
+
|
33 |
+
|
34 |
+
### Fine-tuning
|
35 |
+
- Python: `3.7.5`
|
36 |
+
|
37 |
+
- Machine specs:
|
38 |
+
|
39 |
+
`CPU: Intel(R) Core(TM) i7-6800K CPU @ 3.40GHz`
|
40 |
+
|
41 |
+
`Memory: 32 GiB`
|
42 |
+
|
43 |
+
`GPUs: 2 GeForce GTX 1070, each with 8GiB memory`
|
44 |
+
|
45 |
+
`GPU driver: 418.87.01, CUDA: 10.1`
|
46 |
+
|
47 |
+
- script:
|
48 |
+
|
49 |
+
```shell
|
50 |
+
# after install https://github.com/huggingface/transformers
|
51 |
+
|
52 |
+
cd examples/question-answering
|
53 |
+
mkdir -p data
|
54 |
+
|
55 |
+
wget -O data/train-v1.1.json https://rajpurkar.github.io/SQuAD-explorer/dataset/train-v1.1.json
|
56 |
+
|
57 |
+
wget -O data/dev-v1.1.json https://rajpurkar.github.io/SQuAD-explorer/dataset/dev-v1.1.json
|
58 |
+
|
59 |
+
export SQUAD_DIR=`pwd`/data
|
60 |
+
|
61 |
+
python run_squad.py \
|
62 |
+
--model_type mobilebert \
|
63 |
+
--model_name_or_path google/mobilebert-uncased \
|
64 |
+
--do_train \
|
65 |
+
--do_eval \
|
66 |
+
--do_lower_case \
|
67 |
+
--train_file $SQUAD_DIR/train-v1.1.json \
|
68 |
+
--predict_file $SQUAD_DIR/dev-v1.1.json \
|
69 |
+
--per_gpu_train_batch_size 16 \
|
70 |
+
--per_gpu_eval_batch_size 16 \
|
71 |
+
--learning_rate 4e-5 \
|
72 |
+
--num_train_epochs 5.0 \
|
73 |
+
--max_seq_length 320 \
|
74 |
+
--doc_stride 128 \
|
75 |
+
--warmup_steps 1400 \
|
76 |
+
--output_dir $SQUAD_DIR/mobilebert-uncased-warmup-squad_v1 2>&1 | tee train-mobilebert-warmup-squad_v1.log
|
77 |
+
```
|
78 |
+
|
79 |
+
It took about 3 hours to finish.
|
80 |
+
|
81 |
+
### Results
|
82 |
+
|
83 |
+
**Model size**: `95M`
|
84 |
+
|
85 |
+
| Metric | # Value | # Original ([Table 5](https://arxiv.org/pdf/2004.02984.pdf))|
|
86 |
+
| ------ | --------- | --------- |
|
87 |
+
| **EM** | **82.6** | **82.9** |
|
88 |
+
| **F1** | **90.0** | **90.0** |
|
89 |
+
|
90 |
+
Note that the above results didn't involve any hyperparameter search.
|
91 |
+
|
92 |
+
## Example Usage
|
93 |
+
|
94 |
+
|
95 |
+
```python
|
96 |
+
from transformers import pipeline
|
97 |
+
|
98 |
+
qa_pipeline = pipeline(
|
99 |
+
"question-answering",
|
100 |
+
model="csarron/mobilebert-uncased-squad-v1",
|
101 |
+
tokenizer="csarron/mobilebert-uncased-squad-v1"
|
102 |
+
)
|
103 |
+
|
104 |
+
predictions = qa_pipeline({
|
105 |
+
'context': "The game was played on February 7, 2016 at Levi's Stadium in the San Francisco Bay Area at Santa Clara, California.",
|
106 |
+
'question': "What day was the game played on?"
|
107 |
+
})
|
108 |
+
|
109 |
+
print(predictions)
|
110 |
+
# output:
|
111 |
+
# {'score': 0.7754058241844177, 'start': 23, 'end': 39, 'answer': 'February 7, 2016'}
|
112 |
+
```
|
113 |
+
|
114 |
+
> Created by [Qingqing Cao](https://awk.ai/) | [GitHub](https://github.com/csarron) | [Twitter](https://twitter.com/sysnlp)
|
115 |
+
|
116 |
+
> Made with ❤️ in New York.
|